Collapse All Rows in TreeLayer [message #1133107] |
Fri, 11 October 2013 16:08 |
Evan O\'Connell Messages: 14 Registered: August 2013 |
Junior Member |
|
|
I need to add Expand All and Collapse All functionality to the TreeLayer.
I have tried the following code to Collapse All rows in the TreeLayer. It only works when all nodes are expanded, otherwise it throws a NullPointerException.
int parentIndex = 0;
ITreeRowModel treeModel = treeLayer.getModel();
List<Integer> childIndexes = treeModel.getChildIndexes(parentIndex);
Collections.reverse(childIndexes);
childIndexes.add(parentIndex);
System.out.println(childIndexes);
for (Integer index : childIndexes) {
if (treeModel.isCollapsed(index) == false) {
treeLayer.collapseTreeRow(index);
}
}
If I have the following tree structure:
-[-] A
|
+--[-] B
| |
| +-- z
|
+--[-] C
| |
| +-- y
|
Running my collapse all code will successfully collapse A,B,C. But if I were to expand all of them and manually collapse C, then running the code will throw a NullPointerException on the following method: treeModel.getChildIndexes(parentIndex);
ie:
-[-] A
|
+--[-] B
| |
| +-- z
|
+--[+] C
|
Stack Trace:
java.lang.NullPointerException
at ca.odell.glazedlists.impl.adt.barcode2.FourColorTree.get(FourColorTree.java:169)
at ca.odell.glazedlists.TreeList.getTreeNode(TreeList.java:302)
at org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeData.getChildren(GlazedListTreeData.java:76)
at org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeRowModel.getChildIndexes(GlazedListTreeRowModel.java:89)
at org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeRowModel.getChildIndexes(GlazedListTreeRowModel.java:93)
at org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeRowModel.getChildIndexes(GlazedListTreeRowModel.java:93)
Any ideas?
[Updated on: Mon, 14 October 2013 11:32] Report message to a moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03569 seconds