Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Reset to original order (PopupMenuBuilder)(I want to implement a context menu item that enables the user to reset reordering made)
Reset to original order (PopupMenuBuilder) [message #1778601] Mon, 18 December 2017 14:36 Go to next message
Michel Pittelkow is currently offline Michel PittelkowFriend
Messages: 8
Registered: October 2017
Junior Member
Hi there,

I am currently working on the intration of NatTable into an application.
As I came across the ReorderCommands I added the context menu items for the different cases (hide column/row & show all columns/rows).

The next step in development was the integration of the two different ReorderLayers.

As a next step I wanted to create context menu items for "reset order to original state" or something like that. But this functionality is not there yet.

Therefore my question:

Does anybody know, how I can achieve this? Do I need to work with different states or is it possible to "reset" the order in the Row/Column-ReorderLayers?

Best regards,
Michel
Re: Reset to original order (PopupMenuBuilder) [message #1778606 is a reply to message #1778601] Mon, 18 December 2017 15:30 Go to previous messageGo to next message
Michel Pittelkow is currently offline Michel PittelkowFriend
Messages: 8
Registered: October 2017
Junior Member
Update:

I just added a ContributionItem to the PopupMenu that does only call refresh() on the NatTable instance.
This would work, but the question that remains is: What else is getting reset with this call?
Re: Reset to original order (PopupMenuBuilder) [message #1778631 is a reply to message #1778606] Tue, 19 December 2017 06:57 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
At the moment there is no direct API to reset the column/row reordering to the original state. The methods that could be used for this would be populateIndexOrder() and invalidateCache() which are actually private. We could of course add a new public method reset() to those layers that perform the necessary actions. Feel free to create an enhancement ticket and provide a patch. Should be easy.

The workaround of using NatTable#refresh() you are using would actually reset everything that can not be re-calculated. The idea of this method is that the whole underlying data structure has changed, and therefore the all layer states are invalid (e.g. you have hidden some columns that are not existing in the new data model you want to show). So I would not recommend to misuse refresh() for resetting values.

Without adding a new reset() method to the layers, the way of doing it would be to use the layer states. For this you would initially (before any user changes) call loadState() and remember the result. Dependent on what you want to store for a state, you could even filter the resulting Properties file. For resetting you would then simply call loadState() with the remembered Properties. This way you can also reset additional states to an original state. This is also how the NatTable state persistence works in general. With the integrated view configuration the initial state is for example automatically available to go back to the state when the NatTable instance was created. More information on that can be found in my small tutorial here: http://www.vogella.com/tutorials/NatTableStatePersistence/article.html
Re: Reset to original order (PopupMenuBuilder) [message #1778727 is a reply to message #1778631] Wed, 20 December 2017 13:24 Go to previous message
Michel Pittelkow is currently offline Michel PittelkowFriend
Messages: 8
Registered: October 2017
Junior Member
Thanks for clarification!

I will file tickets then after I've finished the work on the NatTableFactory as maybe other cases will need an enhancement ticket.
Previous Topic:Is that possible select a cell in a FixedSummaryRowLayer and copy it?
Next Topic:ColumnOverrideLabelAccumulator - addLabel for entire row to set row border
Goto Forum:
  


Current Time: Tue Apr 23 06:32:06 GMT 2024

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

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

Back to the top