]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
TreeGridWidget performance 31/1231/2
authorAntti Villberg <antti.villberg@semantum.fi>
Thu, 16 Nov 2017 11:42:12 +0000 (13:42 +0200)
committerJani Simomaa <jani.simomaa@semantum.fi>
Thu, 16 Nov 2017 12:46:36 +0000 (14:46 +0200)
refs #7623

Change-Id: I6853827a98b3663d16d292e89741667c6be95014

bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCell.java
bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCellStyleClass.java [new file with mode: 0644]
bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TreeTableCell.java
bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl

index 1849273d1d59bf41e693a46ad640dac4800698ac..4e1dd0bd124482d5a50ccca386383be248d59abd 100644 (file)
@@ -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 (file)
index 0000000..3e6590d
--- /dev/null
@@ -0,0 +1,7 @@
+package org.simantics.document.server.io;
+
+public interface ITreeTableCellStyleClass extends ITableCellStyleClass {
+
+       Object getData();
+
+}
index 299c7c7964955e4c47b2aa1beab214342ae35c39..1f5b8a2215702248f71f7595db8d8435ffe409d9 100644 (file)
@@ -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);
+       }
+       
 }
index 88d8e47aad2448cc299e3721bded398f92dcccd7..8898ce10a9a306d58b0ea796e6d96653987fd132 100644 (file)
@@ -14,6 +14,8 @@ importJava "org.simantics.spreadsheet.common.TreeTableCell" where
     getTreeTableCellData :: TreeTableCell -> <Proc> a
     
     createTreeTableCell :: String -> a -> Maybe b -> Integer -> Integer -> Integer -> Boolean -> <Proc> TreeTableCell
+
+    createTreeTableCell2 :: String -> a -> Maybe b -> a -> Integer -> Integer -> Boolean -> <Proc> TreeTableCell
     
     @JavaName getText
     treeTableCellText :: TreeTableCell -> <Proc> String