]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/GETreeRowModel.java
Sync git svn branch with SVN repository r33334.
[simantics/platform.git] / bundles / org.simantics.browsing.ui.nattable / src / org / simantics / browsing / ui / nattable / GETreeRowModel.java
index ebfb962db7a129cf7af9cdc93e7f64f433d2585c..762b47ce008ab29f1e96d8ed520ba402d0e685d5 100644 (file)
@@ -22,7 +22,7 @@ import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
 public class GETreeRowModel<T> implements ITreeRowModel<T>{\r
        //private final HashSet<Integer> parentIndexes = new HashSet<Integer>();\r
        //private final TIntHashSet parentIndexes = new TIntHashSet(1000, 0.8f);\r
-       private final IntOpenHashSet parentIndexes = new IntOpenHashSet();\r
+       private final IntOpenHashSet expandedIndexes = new IntOpenHashSet();\r
 \r
        private final Collection<ITreeRowModelListener> listeners = new HashSet<ITreeRowModelListener>();\r
 \r
@@ -59,11 +59,11 @@ public class GETreeRowModel<T> implements ITreeRowModel<T>{
        }\r
        \r
        public boolean isCollapsed(int index) {\r
-               return this.parentIndexes.contains(index);\r
+               return !this.expandedIndexes.contains(index);\r
        }\r
 \r
        public void clear() {\r
-               this.parentIndexes.clear();\r
+               this.expandedIndexes.clear();\r
        }\r
        \r
        @Override\r
@@ -73,16 +73,18 @@ public class GETreeRowModel<T> implements ITreeRowModel<T>{
 \r
        @Override\r
        public List<Integer> collapse(int index) {\r
-               this.parentIndexes.add(index);\r
+               this.expandedIndexes.remove(index);\r
                notifyListeners();\r
-               return getChildIndexes(index);\r
+               List<Integer> list = getChildIndexes(index);\r
+               //this.parentIndexes.addAll(list);\r
+               return list;\r
        }\r
        \r
        \r
 \r
        @Override\r
        public List<Integer> expand(int index) {\r
-               this.parentIndexes.remove(index);\r
+               this.expandedIndexes.add(index);\r
                notifyListeners();\r
                List<Integer> children = getExpandedChildIndexes(index);\r
                return children;\r
@@ -90,7 +92,6 @@ public class GETreeRowModel<T> implements ITreeRowModel<T>{
        \r
        @Override\r
        public List<Integer> collapseAll() {\r
-               // TODO Auto-generated method stub\r
                return null;\r
        }\r
        \r
@@ -195,7 +196,7 @@ public class GETreeRowModel<T> implements ITreeRowModel<T>{
                        int index = this.treeData.indexOf(child);\r
                        if (index >= 0) {\r
                                result.add(index);\r
-                               if (!parentIndexes.contains(index))\r
+                               if (expandedIndexes.contains(index))\r
                                        result.addAll(getExpandedChildIndexes(index));\r
                        } else {\r
                                result.addAll(getExpandedChildIndexes(child));\r
@@ -211,7 +212,7 @@ public class GETreeRowModel<T> implements ITreeRowModel<T>{
                        int index = this.treeData.indexOf(child);\r
                        if (index >= 0) {\r
                                result.add(index);\r
-                               if (!parentIndexes.contains(index))\r
+                               if (expandedIndexes.contains(index))\r
                                        result.addAll(getExpandedChildIndexes(index));\r
                        } else {\r
                                result.addAll(getExpandedChildIndexes(child));\r