Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Collapse All Rows in TreeLayer(help)
Collapse All Rows in TreeLayer [message #1133107] Fri, 11 October 2013 12:08 Go to next message
Evan O\'Connell is currently offline Evan O\'Connell
Messages: 10
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 07:32]

Report message to a moderator

Re: Collapse All Rows in TreeLayer [message #1133302 is a reply to message #1133107] Fri, 11 October 2013 15:27 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1213
Registered: July 2012
Senior Member
I'm not really sure, but maybe it is a race condition. Maybe it is necessary to lock the list prior collapsing.

At least in GlazedListTreeData there needs to be a null check.

Could you please file a ticket in bugzilla? This needs to be investigated in more detail. It would be great if you could provide a small running example with the ticket so it is easier for us to start the investigation.
Re: Collapse All Rows in TreeLayer [message #1137450 is a reply to message #1133302] Mon, 14 October 2013 09:59 Go to previous messageGo to next message
Evan O\'Connell is currently offline Evan O\'Connell
Messages: 10
Registered: August 2013
Junior Member
Done. Bug 419366
Re: Collapse All Rows in TreeLayer [message #1220150 is a reply to message #1133302] Tue, 10 December 2013 01:45 Go to previous messageGo to next message
P P is currently offline P P
Messages: 3
Registered: December 2013
Junior Member
Hi Dirk,
I checked on the Bug 419366 in Bugzilla and that it is fixed. I wanted to check when this would be available i.e. the next targeted release for NatTable?

Thanks,
Prerna
Re: Collapse All Rows in TreeLayer [message #1220165 is a reply to message #1220150] Tue, 10 December 2013 02:30 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1213
Registered: July 2012
Senior Member
We haven't scheduled a time for releasing 1.1. But we are on our way.
Re: Collapse All Rows in TreeLayer [message #1220171 is a reply to message #1220165] Tue, 10 December 2013 03:17 Go to previous message
P P is currently offline P P
Messages: 3
Registered: December 2013
Junior Member
Thanks for the quick update Smile
Previous Topic:Create Body Context Menu in E4 with NatTable
Next Topic:How to validate data by the use of commands through code directly.
Goto Forum:
  


Current Time: Thu Jul 24 11:38:57 EDT 2014

Powered by FUDForum. Page generated in 0.01990 seconds