Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » empty selection returned while selecting a complete row
empty selection returned while selecting a complete row [message #1407535] Tue, 12 August 2014 21:29 Go to next message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 184
Registered: July 2009
Senior Member
Hi all,
I've built a NatTable with several layers. I have the following stack
(only the important parts, no complete java code):

GlazedLists.eventList;
gridLayer = ListViewGridLayer (with FilterList on eventList);
tableDataLayer = gridLayer.getBodyDataLayer();
listEventLayer = new GlazedListsEventLayer<MyObject>(tableDataLayer,
eventList);
bodyLayer = new DefaultBodyLayerStack(listEventLayer);
selectionLayer = bodyLayer.getSelectionLayer();

selectionLayer.addConfiguration(new
RowOnlySelectionConfiguration<MyObject>());
RowSelectionModel<MyObject> selectionModel = new
RowSelectionModel<MyObject>(selectionLayer,
gridLayer.getBodyDataProvider(), new IRowIdAccessor<MyObject>() {

public Serializable getRowId(MyObject rowObject) {
return rowObject.getId();
}

}, false);
selectionLayer.setSelectionModel(selectionModel);


Now, if I click into the table, only the cell is selected, not the whole
row. For testing purposes I've added a natTable.addLayerListener(). This
showed me that selecting a single cell fires an event, but selecting
(marking) a whole row does nothing. Therefore the collection for the
selected objects is empty.

The goal of this exercise is simply to get the selected object
(MyObject) from the table for further using outside nattable.

What's wrong with this configuration? I tried out the
RowSelectionExample, but it didn't enlighten my mind...

TIA,
Ralf.
Re: empty selection returned while selecting a complete row [message #1407683 is a reply to message #1407535] Wed, 13 August 2014 07:54 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2525
Registered: July 2012
Senior Member
I'm not sure. Maybe the default configuration must be avoided.

But if you need the selected object, why don't you use the RowSelectionProvider? This way you have the same mechanism as with SWT default.
Re: empty selection returned while selecting a complete row [message #1407981 is a reply to message #1407683] Thu, 14 August 2014 00:21 Go to previous messageGo to next message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 184
Registered: July 2009
Senior Member
Am 13.08.2014 um 09:54 schrieb Dirk Fauth:
> I'm not sure. Maybe the default configuration must be avoided.
> But if you need the selected object, why don't you use the
> RowSelectionProvider? This way you have the same mechanism as with SWT
> default.

Ok, I've checked _5054_SelectionProviderExample once again and modified
my code according to the example. Also I used a RowSelectionProvider for
the row selection. But now, the filtering (which was working before) and
a column with icons (which was working too) are out of order. I found
out that it has to do with the CompositeLayer and its use in the
creation of NatTable. But I don't know what's wrong with this (what is,
e.g., the "setChildLayer" method for?). Maybe its only a wrong ordering
of my layers. I'd be glad if anyone could give me a hint about the
correct ordering or (the better one) a working example for this use case
(single row selection, column with an icon and filtering using a
GlazedList filter layer). And, btw., if I click on a column header, the
whole table is selected (but I think I've heard about this).

TIA,
Ralf.
Re: empty selection returned while selecting a complete row [message #1408092 is a reply to message #1407981] Thu, 14 August 2014 07:58 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2525
Registered: July 2012
Senior Member
The CompositeLayer is used to compose layer stacks next to each other.

Maybe you shouldn't use the DefaulBodyLayerStack.
Previous Topic:Refreshing NatTable with GlazedLists
Next Topic:auto row resize
Goto Forum:
  


Current Time: Mon Nov 20 18:59:20 GMT 2017

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

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