Skip to main content


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 16:08 Go to next message
Evan O\'Connell is currently offline Evan O\'ConnellFriend
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

Re: Collapse All Rows in TreeLayer [message #1133302 is a reply to message #1133107] Fri, 11 October 2013 19:27 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
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 13:59 Go to previous messageGo to next message
Evan O\'Connell is currently offline Evan O\'ConnellFriend
Messages: 14
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 06:45 Go to previous messageGo to next message
P P is currently offline P PFriend
Messages: 6
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 07:30 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
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 08:17 Go to previous message
P P is currently offline P PFriend
Messages: 6
Registered: December 2013
Junior Member
Thanks for the quick update Smile
Previous Topic:Avoid flickering when resize a table
Next Topic:Row numbers are also changed , when rows are reordered using row reorder layer
Goto Forum:
  


Current Time: Sat Apr 20 01:32:22 GMT 2024

Powered by FUDForum. Page generated in 0.03569 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top