A more useful alternative to the Memento pattern is DialogSettings
, which provides a properties-like interface for storing strings and other basic primitive values. This stores its information in an XML file, and can be acquired as a standard extension to the UI plug-in or created from a file location. The settings store is used to store values persistently, and is saved automatically when the plug-in shuts down. At startup, it is loaded automatically. Perform the following steps:
To migrate the settings for the last tab selected to use
DialogSettings
, remove theinit()
andsave()
methods from theTimeZoneView
and replace them with the following in thecreatePartControl()
:final IDialogSettings settings =Activator.getDefault().getDialogSettings(); lastTabSelected = settings.get("lastTabSelected");
The call to
getDialogSettings()
comes from theUIPlugin
class. Once theDialogSettings
have been acquired, it can be used to store and retrieve values. Update...