Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Select row instead of cell in a Tree NatTable
Select row instead of cell in a Tree NatTable [message #1774568] Tue, 17 October 2017 12:09 Go to next message
Felix S is currently offline Felix SFriend
Messages: 7
Registered: November 2014
Junior Member
Hi,

how can I achive, that NatTable selects a row instead of a column, if the underlying bodyLayerStack is based on a TreeList? I used the _5053_SelectionEventsExample and _5052_RowSelectionExample as base. But adding the RowSelectionModel and afterwards add the DefaultRowSelectionLayerConfiguration takes no effect.

The DataLayer is built as follows:
List<EObject> values;
eventList = GlazedLists.eventList(values);
// some other list wrappers to add filter and sorting
treeList = new TreeList(filterList, new MyCustomTreeFormat(), TreeList.NODES_START_EXPANDED);
bodyDataProvider = new ListDataProvider<>(treeList, columnPropertyAccessor);

The bodyDataProvider is passed to the selection model. Did I missed something?

Also I noticed, that the row positions in a selection event (when listening to LayerEvents of a NatTable) differ from the actual row in a tree. I assume, this is related to my row selection issue?

I found this post, but it didn't work for me: https://www.eclipse.org/forums/index.php/t/458087/

Kind regards,
Felix
Re: Select row instead of cell in a Tree NatTable [message #1774577 is a reply to message #1774568] Tue, 17 October 2017 13:27 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2614
Registered: July 2012
Senior Member
Not sure what you are trying to achieve and how you are doing it. So I can't tell what you are doing wrong so it does not work for you. And of course the row position in a LayerEvent on the NatTable layer is different from what it is in the underlying list. At least if you are using a GridLayer and a ViewportLayer. That is related to the index-position transformation.
Re: Select row instead of cell in a Tree NatTable [message #1774586 is a reply to message #1774577] Tue, 17 October 2017 14:40 Go to previous messageGo to next message
Felix S is currently offline Felix SFriend
Messages: 7
Registered: November 2014
Junior Member
Dirk Fauth wrote on Tue, 17 October 2017 13:27
Not sure what you are trying to achieve and how you are doing it.

I have a list of objects, that can be rendered as Tree, like
* Obj1
** SubObj11
* Obj2
** SubObj21
** SubObj22
etc.
The TreeList is (correctly) displayed in a NatTable (just like noted above). I want to achive a full row selection, when I click in the NatTable. By default, only a single cell is selected. To achive that, I added the before mentioned RowSelectionModel as it is done in the examples. This works for a list based NatTable (i.e. without tree layer), but not for the tree list based one.

Dirk Fauth wrote on Tue, 17 October 2017 13:27
And of course the row position in a LayerEvent on the NatTable layer is different from what it is in the underlying list. At least if you are using a GridLayer and a ViewportLayer. That is related to the index-position transformation.

I added an ILayerListener to the natTable, listening for RowSelectionEvents. The wrong row position comes from the selection event. E.g. calling cellEvent.getRowPosition() for the tree returns something like this
* Obj1 -> 2
** SubObj11 -> 3
* Obj2 -> 4
** SubObj21 -> 2
** SubObj22 -> 3

In my understanding, the CellSelectionEvent (or at least the viewportlayer) should be aware of the correct row position of the underlying data, since I passed the TreeList into the RowSelectionModel. So something like
public void handleLayerEvent(ILayerEvent event) {
	if (event instanceof CellSelectionEvent) {
		CellSelectionEvent cellEvent = (CellSelectionEvent) event;
		EObject element = bodyLayerStack.getBodyDataProvider()).getRowObject(cellEvent.getRowPosition());
		if (element != null)
			selectionService.setSelection(element);
	}
}
should return the selected object, shouldn't it?

Kind regards,
Felix
Re: Select row instead of cell in a Tree NatTable [message #1774596 is a reply to message #1774586] Tue, 17 October 2017 16:07 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2614
Registered: July 2012
Senior Member
No it shouldn't because the row position is relativ to the layer. You are interested in the row index
Re: Select row instead of cell in a Tree NatTable [message #1774652 is a reply to message #1774596] Wed, 18 October 2017 10:37 Go to previous message
Felix S is currently offline Felix SFriend
Messages: 7
Registered: November 2014
Junior Member
Thanks for the hint to convert the row position to row index. Wasn't aware of that. I also got the full row selection in the tree table working, I was confused by some additional layers i added for testing :/
Previous Topic:Strange celleditor behavior on Mac
Next Topic:groupBy nattable
Goto Forum:
  


Current Time: Mon Sep 24 11:58:13 GMT 2018

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

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

Back to the top