Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Select a row after including a new one
Select a row after including a new one [message #1736303] Tue, 28 June 2016 10:30 Go to next message
Nico Linder is currently offline Nico LinderFriend
Messages: 8
Registered: June 2016
Junior Member
Hey guys!

We use NatTable in our project and added and option to a rightclick-menu, which inserts a new row. We wanted this new row to be selected, but this selection is only flickering shortly.

Here is the code for adding the row and selecting it. I removed some code for calculating row indizes for example.
..
CompoundCommand command = new CompoundCommand();	
..
command.append(new AddCommand(editingDomain, ((HaraGlazedListsDataProvider<HazardAndRiskAssessmentRow>) this.dataProvider).getEList(), row));
..
editingDomain.getCommandStack().execute(command);
..
natTable.doCommand(new ShowRowInViewportCommand(this.bodyLayerStack.getViewportLayer(), min));
natTable.doCommand(new SelectRowsCommand(this.bodyLayerStack.getSelectionLayer(), 0, rows, false, false, min));

I also added a gif of the flickering row in the attachments.

Has anyone an idea how to make this selection to stay?
Thank you!
Re: Select a row after including a new one [message #1736310 is a reply to message #1736303] Tue, 28 June 2016 11:11 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Without knowing your layer stack it is hard to tell. I suppose you are using GlazedLists and the GlazedListsEventLayer. This one triggers a RowStructuralRefreshEvent for updating the layer stack. This is necessary to tell everybody that a new row was inserted so the indexes can be updated. To avoid too noisy event handling, the GlazedListsEventLayer conflates all upcoming events within 100ms. By default the SelectionLayer clears the selection if there are structural changes without detail information. If my assumption is correct you are too fast. You are selecting the new row and that selection gets cleared because of the update triggered by the GlazedListsEventLayer.

There are different solutions possible:
- Use the RowSelectionModel or PreserveSelectionModel that is able to restore the selection based on IDs
- Use the DetailGlazedListsEventLayer which sends more detailed update events instead of only a general update event
- Implement the selection of the row in a reactive way. This could be registering an ILayerListener for the RowStructuralRefreshEvent on a high level (e.g. NatTable) that triggers the selection and afterwards unregisters itself again.

Dependent on your requirements I would go for the first option, as keeping the selection is a common requested feature (e.g. the selection should remain on sorting). If the content is not updating often also the second option could be fine. Not sure on the performance impact and whether you have huge data sets. The last one is conceptual interesting, but could be complicated to implement in combination with different other components.
icon10.gif  Re: Select a row after including a new one [message #1736325 is a reply to message #1736310] Tue, 28 June 2016 12:35 Go to previous message
Nico Linder is currently offline Nico LinderFriend
Messages: 8
Registered: June 2016
Junior Member
Thank you very much!
I used a PreserveSelectionModel and it works just fine.
Previous Topic:Column Group Header Rename
Next Topic:Hiding a Column Using NAT TABLE API
Goto Forum:
  


Current Time: Fri Apr 26 23:46:48 GMT 2024

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

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

Back to the top