From: Antti Villberg Date: Thu, 16 Nov 2017 11:42:12 +0000 (+0200) Subject: TreeGridWidget performance X-Git-Tag: v1.31.0~31 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F31%2F1231%2F2;p=simantics%2Fplatform.git TreeGridWidget performance refs #7623 Change-Id: I6853827a98b3663d16d292e89741667c6be95014 --- diff --git a/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCell.java b/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCell.java index 1849273d1..4e1dd0bd1 100644 --- a/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCell.java +++ b/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCell.java @@ -2,7 +2,9 @@ package org.simantics.document.server.io; public interface ITreeTableCell extends ITableCell { + @Deprecated int getParent(); + Object getParentData(); Object getData(); boolean isEditable(); diff --git a/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCellStyleClass.java b/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCellStyleClass.java new file mode 100644 index 000000000..3e6590d5e --- /dev/null +++ b/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCellStyleClass.java @@ -0,0 +1,7 @@ +package org.simantics.document.server.io; + +public interface ITreeTableCellStyleClass extends ITableCellStyleClass { + + Object getData(); + +} diff --git a/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TreeTableCell.java b/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TreeTableCell.java index 299c7c796..1f5b8a221 100644 --- a/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TreeTableCell.java +++ b/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TreeTableCell.java @@ -22,6 +22,7 @@ import org.simantics.document.server.io.SimpleFont; public class TreeTableCell extends TableCell implements ITreeTableCell { private int parent = -1; + private Object parentData; private boolean editable = true; private Object data; @@ -29,10 +30,11 @@ public class TreeTableCell extends TableCell implements ITreeTableCell { public TreeTableCell() { } - public TreeTableCell(String text, Object data, Object font, int parent, int row, int column, boolean editable) { + public TreeTableCell(String text, Object data, Object font, Object parentData, int parent, int row, int column, boolean editable) { super(column, row, 0, 0, text, (IFont)font, null, null, false, 1, 1); this.editable = editable; this.parent = parent; + this.parentData = parentData; this.data = data; } @@ -47,9 +49,13 @@ public class TreeTableCell extends TableCell implements ITreeTableCell { } public static TreeTableCell createTreeTableCell(String text, Object data, Object font, int parent, int row, int column, boolean editable) { - return new TreeTableCell(text, data, extractIFont(font), parent, row, column, editable); + return new TreeTableCell(text, data, extractIFont(font), null, parent, row, column, editable); } + public static TreeTableCell createTreeTableCell2(String text, Object data, Object font, Object parentData, int row, int column, boolean editable) { + return new TreeTableCell(text, data, extractIFont(font), parentData, -1, row, column, editable); + } + private static IFont extractIFont(Object font) { if(font instanceof FontDescriptor) { FontDescriptor descriptor = (FontDescriptor)font; @@ -71,6 +77,11 @@ public class TreeTableCell extends TableCell implements ITreeTableCell { this.parent = parent; } + @Override + public Object getParentData() { + return parentData; + } + @Override public int getParent() { return parent; @@ -86,4 +97,45 @@ public class TreeTableCell extends TableCell implements ITreeTableCell { return editable; } + @Override + public int hashCode() { + + final int prime = 31; + + int result = super.hashCode(); + + result = data != null ? prime * result + data.hashCode() : parent; + result = parentData != null ? prime * result + parentData.hashCode() : result; + result = prime * result + Integer.hashCode(parent); + result = prime * result + Boolean.hashCode(editable); + + return result; + + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TreeTableCell other = (TreeTableCell) obj; + if (data == null) { + if (other.data != null) + return false; + } else if (!data.equals(other.data)) + return false; + if (parentData == null) { + if (other.parentData != null) + return false; + } else if (!parentData.equals(other.parentData)) + return false; + if (parent != other.parent) + return false; + if (editable != other.editable) + return false; + return super.equals(obj); + } + } diff --git a/bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl b/bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl index 88d8e47aa..8898ce10a 100644 --- a/bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl +++ b/bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl @@ -14,6 +14,8 @@ importJava "org.simantics.spreadsheet.common.TreeTableCell" where getTreeTableCellData :: TreeTableCell -> a createTreeTableCell :: String -> a -> Maybe b -> Integer -> Integer -> Integer -> Boolean -> TreeTableCell + + createTreeTableCell2 :: String -> a -> Maybe b -> a -> Integer -> Integer -> Boolean -> TreeTableCell @JavaName getText treeTableCellText :: TreeTableCell -> String