Confusing PreferenceStore [message #494987] |
Tue, 03 November 2009 13:24 |
Timothy Marc Messages: 547 Registered: July 2009 |
Senior Member |
|
|
Hi all,
i've read about the different preferences scopes in Eclipse. So i've
defined a PreferenceInitializer like this:
IPreferencesService service = Platform.getPreferencesService();
final IEclipsePreferences prefs = new
DefaultScope().getNode("de.fraunhofer.fokus.testing.mbttool.ui.preferences ");
prefs.put(...);
...
service.applyPreferences(prefs, null);
This works quite well, but now i'm getting really confused. I've created
a simple FieldEditorPage and in the constructor, the PreferenceStore
should be applied?! How can i get the PreferenceStore from the
PreferenceService?
One option might be Activator.getDefault().getPreferenceStore, but is
this store exactly the same store, where all the initialization values
are stored? Well, may be, i mix some things... as mentioned, i'm a bit
confused actually.
Thanks
Timothy
|
|
|
Re: Confusing PreferenceStore [message #494991 is a reply to message #494987] |
Tue, 03 November 2009 13:44 |
|
Hmm i just create a new one... that works for me.
store = new ScopedPreferenceStore(new InstanceScope(), "myNodeId");
setPreferenceStore(store);
to get my Value then i do:
IEclipsePreferences pluginNode = new InstanceScope().getNode("myNodeId");
boolean b =pluginNode.getBoolean("myParameter", false);
Hope this helps you
Greetz
Thomas
|
|
|
|
Re: Confusing PreferenceStore [message #495196 is a reply to message #495192] |
Wed, 04 November 2009 07:07 |
|
Hey Timothy,
did you read the java doc?
Quote: | Returns the preference store used for publicly settable workbench preferences. Constants for these preferences are defined on org.eclipse.ui.IWorkbenchPreferenceConstants.
Returns:
the workbench public preference store
|
So it seems that this store will be used by the eclipse developers to store some workbench configurations.
If you create one or more Preference stores depends on your use cases. Are there some preferences which depends logically on the same topic i would suggest to create only one Preference store.
Also consider that i use an InstanceScope here, but there are also a DefaultScope and a Configuration Scope. You should think about which one you choose for your preferences.
Greetz
Thomas
|
|
|
Powered by
FUDForum. Page generated in 0.03110 seconds