Background
I am working on a plugin for uDig, a project build on Eclipse RCP. My plugin contains a table that gets populated with data from the Workbench selection. The table data can be grouped, sorted and filtered by the user. When the workbench selection changes the group, sort and filter information is reset and the new selection data loaded into the table.
Question
How do I save values to he workbench so I can access them later?
When the workbench selection gets changed I wish to save the group, sort and filter state out to the Workbench so that if the workbench selection ever changes back to the saved selection I can restore the state.
Research
I have looked at IViewPart.saveState(IMemento memento) but get the feeling this is only useful when you are adding and removing a view.
I have also looked at using preferences but feel this is an incorrect usage of this resource.
IEclipsePreferences node = InstanceScope.INSTANCE.getNode(PluginUI.PLUGIN_ID);
node.put(key, value);
Finally
I am some what new to Eclipse RCP and may be attacking this problem the wrong way. If there is a better way to save and load this information please feel free to share.
From your description, it sounds like you have a view with the table. The text book way to save state for a view, is via
IMemento. You can see the code to use this interface in this presentation. As an alternative, you can also use theIPreferenceStore.You usually use preferences when the state has a global scope and memento when they are specific to a view.