Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Confusing PreferenceStore
Confusing PreferenceStore [message #494987] Tue, 03 November 2009 13:24 Go to next message
Timothy Marc is currently offline 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 Go to previous messageGo to next message
T. Wilhelm is currently offline T. Wilhelm
Messages: 129
Registered: July 2009
Senior Member
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 #495192 is a reply to message #494991] Wed, 04 November 2009 06:09 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy Marc
Messages: 547
Registered: July 2009
Senior Member
Thomas,

well, i've done it in a similar way, but for what purpose exists the
PlatformUI.getPreferenceStore()?! I supposed, that this is a general or
global store for all bundles. Is it a best practice to create an
individual store for each plugin concern?

Thanks
Timothy

T. Wilhelm schrieb:
> 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 Go to previous message
T. Wilhelm is currently offline T. Wilhelm
Messages: 129
Registered: July 2009
Senior Member
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
Previous Topic:Menu, commands, actions, and OSX
Next Topic:Initializing preferences when creating a new workspace
Goto Forum:
  


Current Time: Tue Sep 30 13:54:44 GMT 2014

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

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