DefaultScope() and ConfigurationScope() are not working as they should. [message #308168] |
Thu, 14 September 2006 19:53  |
Eclipse User |
|
|
|
Originally posted by: bnegrao.gmail.com
Hi,
From reading the documentation I believed that ConfigurationScope() nodes
would find the preferences it did not find in the DefaultScope() analogous
nodes. But this is not hapenning. (did I understand wrong?)
To prove this doesn't work i made the following test inside the "public
void initializeDefaultPreferences()" of the PreferenceInitializer class of
my plugin:
/* test with eclipse preferences */
// get a node on the default scope:
IEclipsePreferences defScopeNode = new DefaultScope().getNode("TOPNODE");
// put a default value
defScopeNode.put("HELLO", "WORLD");
// try to get that default using the configuration scope node:
IEclipsePreferences confScopeNode =
new ConfigurationScope().getNode("TOPNODE");
System.out.println(confScopeNode.get("HELLO", "HELL"));
It prints HELL instead of WORLD!
Did i misunderstood the documentation? Isn't this behaviour the planned
behaviour?
thank you,
bruno
|
|
|
|
Re: DefaultScope() and ConfigurationScope() are not working as they should. [message #308177 is a reply to message #308168] |
Fri, 15 September 2006 01:59   |
Eclipse User |
|
|
|
Dear Bruno,
The (new) preference handling tripped me too. I expected that the
<code>PreferenceInitializer</code> is somehow involved in all this
matter. It is, but just in one case...
Bruno Negrao schrieb:
> Hi,
>
> From reading the documentation I believed that ConfigurationScope()
> nodes would find the preferences it did not find in the DefaultScope()
> analogous nodes. But this is not hapenning. (did I understand wrong?)
Yes, I think this is a intended behaviour. It's the option/duty of the
user to specify whether there is an relation.
> To prove this doesn't work i made the following test inside the "public
> void initializeDefaultPreferences()" of the PreferenceInitializer class
> of my plugin:
Here is a way to have our expected behaviour:
<code>
IPreferencesService service = Platform.getPreferencesService();
Preferences configurationNode =
new ConfigurationScope().getNode("TOPNODE");
Preferences defaultNode = new DefaultScope().getNode("TOPNODE");
Preferences[] nodes = new Preferences[]{configurationNode,defaultNode};
String location = service.get("TOPNODE","",nodes);
</code>
By including the DefaultScope into the search the Initializer gets
triggered.
>
> /* test with eclipse preferences */
> // get a node on the default scope: IEclipsePreferences defScopeNode =
> new DefaultScope().getNode("TOPNODE");
> // put a default value
> defScopeNode.put("HELLO", "WORLD");
> // try to get that default using the configuration scope node:
> IEclipsePreferences confScopeNode = new
> ConfigurationScope().getNode("TOPNODE");
> System.out.println(confScopeNode.get("HELLO", "HELL"));
>
> It prints HELL instead of WORLD!
Working on one scope alone, does just that. There is (no longer) any
magic involved to check also the default if nothing is found.
==> You have to specify whether you want to have default value or not by
including the DefaultScope in your query. If you do, the initializer is
called to setup the default values.
> Did i misunderstood the documentation? Isn't this behaviour the planned
> behaviour?
I think the documentation could be more precise and explain the new
usage of the Scopes (and filed an enhancement request on that).
Bye
Günther
|
|
|
|
|
|
Re: DefaultScope() and ConfigurationScope() are not working as they should. [message #308242 is a reply to message #308204] |
Mon, 18 September 2006 07:06   |
Eclipse User |
|
|
|
Dear Bruno,
Bruno Negrao schrieb:
> ...
>>> From reading the documentation I believed that ConfigurationScope()
>>> nodes would find the preferences it did not find in the
>>> DefaultScope() analogous nodes. But this is not hapenning. (did I
>>> understand wrong?)
>
>> Yes, I think this is a intended behaviour. It's the option/duty of the
>> user to specify whether there is an relation.
>
> Guenther, I cannot fully agree when you said "It's the option/duty of
> the user to specify whether there is an relation."
>
> I just posted a bug in https://bugs.eclipse.org/bugs/show_bug.cgi?id=157539
>
> That proves that the ScopedPreferenceStore class, the one that actually
Here is I think the problem located: The DefaultScope() and other
Scopes() are the building blocks for the ScopedPreferenceStore() and
other services.
The Scopes just operate on their own data, higher service comes into
play via ScopedPreferenceStore or other services. They define the search
sequence and other things.
With the underlaying building blocks (=classes) being visible and
documented it's the programmers choice to select the right service level.
In my case I needed a installation wide setting therefore I chose
ConfigurationScope and DefaultScope which is not the standard use case.
In your case maybe it's more recommended to avoid the Scopes altogether
and use the preference store that can be obtained from the plug-in.
> stores all the preferences, makes searches on the DefaultScope() for
> every preference set before saving a new value on the
> ConfigurationScope. If you see the source code of ScopedPreferenceStore
> you'll see that this class searches for preferences on the DefaultScope
> before changing the ConfigurationScope.
>
> So there is already a relation, I believe this relation is not well set
> up through all the framework.
>
> Should I open a bug on this?...
IMHO, it works like it is designed for but I understand your point quite
well that it's not obvious how to use these classes/services.
Bye,
Günther
|
|
|
Re: DefaultScope() and ConfigurationScope() are not working as they should. [message #308334 is a reply to message #308242] |
Tue, 19 September 2006 19:38  |
Eclipse User |
|
|
|
Originally posted by: bnegrao.gmail.com
Hi Guenther, I think now I better understand your point.
> In your case maybe it's more recommended to avoid the Scopes altogether
> and use the preference store that can be obtained from the plug-in.
Could you give me an example of how to use the preference store?
My book, the Eclipse Rich Client Platform doesn't say nothing about it.
Thank you,
Bruno.
|
|
|
Powered by
FUDForum. Page generated in 0.05382 seconds