Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Confusing PreferenceStore
Confusing PreferenceStore [message #494987] Tue, 03 November 2009 08:24 Go to next message
Eclipse UserFriend
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 08:44 Go to previous messageGo to next message
Eclipse UserFriend
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 01:09 Go to previous messageGo to next message
Eclipse UserFriend
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 02:07 Go to previous message
Eclipse UserFriend
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 Jul 22 19:30:24 EDT 2025

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

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

Back to the top