Select row instead of cell in a Tree NatTable [message #1774568] |
Tue, 17 October 2017 12:09 |
Felix S Messages: 10 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 #1774586 is a reply to message #1774577] |
Tue, 17 October 2017 14:40 |
Felix S Messages: 10 Registered: November 2014 |
Junior Member |
|
|
Dirk Fauth wrote on Tue, 17 October 2017 13:27Not 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:27And 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04509 seconds