Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » DefaultScope() and ConfigurationScope() are not working as they should.
DefaultScope() and ConfigurationScope() are not working as they should. [message #308168] Thu, 14 September 2006 19:53 Go to next message
Eclipse UserFriend
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 #308169 is a reply to message #308168] Thu, 14 September 2006 19:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bnegrao.gmail.com

The formatting wasn't clear, so this is the code snipped I posted

IEclipsePreferences defScopeNode = new DefaultScope().getNode("TOPNODE");
defScopeNode.put("HELLO", "WORLD");
IEclipsePreferences confScopeNode = new
ConfigurationScope().getNode("TOPNODE");
System.out.println(confScopeNode.get("HELLO", "HELL"));


this prints HELL instead of WORLD.
Re: DefaultScope() and ConfigurationScope() are not working as they should. [message #308177 is a reply to message #308168] Fri, 15 September 2006 01:59 Go to previous messageGo to next message
Eclipse UserFriend
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&uuml;nther
Re: DefaultScope() and ConfigurationScope() are not working as they should. [message #308192 is a reply to message #308177] Fri, 15 September 2006 08:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bnegrao.gmail.com

Thank you Guenther!

I'll test this tonigth and I'll post here my results.

I still believe that the ConfigurationScope() should search in
DefaultScope() for us.
Maybe they should change the constructor of the ConfigurationScope()
object to accept a DefaultScope() object as a paramenter, to indicate that
on that object the ConfigurationScope() can search for its defaults. This
would be a much clearer usage.

Like this:
DefaultScope defScopeNode = new DefaultScope().getNode("PLUGIN_ID");
// initialize defScopeNode with preferences...
// ...
ConfigurationScope confScopeNode = new
ConfigurationScope(defScopeNode).getNode("PLUGIN_ID");

bye,
bruno.
Re: DefaultScope() and ConfigurationScope() are not working as they should. [message #308204 is a reply to message #308177] Fri, 15 September 2006 19:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bnegrao.gmail.com

>> 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
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?...
Re: DefaultScope() and ConfigurationScope() are not working as they should. [message #308230 is a reply to message #308177] Sun, 17 September 2006 14:58 Go to previous messageGo to next message
Eclipse UserFriend
I've also had trouble with preferences and default scope. The Eclipse
3.1 help documentation provides this statement under Platform Plug-in
Developer's Guide --> Programmer's Guide --> Runtime overview -->
Runtime preferences regarding the IPreferencesService.getBoolean method:

====== Begin Quote ======
The last parameter in the query method is an array of scope contexts to
use when searching for the preference node. If the array is null, then
the platform assumes that the default scope search order should be used
and guesses the appropriate preference node. If an array of scopes
contexts is passed, then this determines the scope lookup order that
should be used to find the preference node. The default scope lookup
order is always consulted if no node can be found using the specified
scopes.
====== End Quote ======

Earlier it describes the default look-up order as instance,
configuration and then default.

Guenther Koegel wrote:
>> 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.
Re: DefaultScope() and ConfigurationScope() are not working as they should. [message #308242 is a reply to message #308204] Mon, 18 September 2006 07:06 Go to previous messageGo to next message
Eclipse UserFriend
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&uuml;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 Go to previous message
Eclipse UserFriend
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.
Previous Topic:update colors in a text editor
Next Topic:UML2 Update site is broken?
Goto Forum:
  


Current Time: Wed Jul 23 05:01:48 EDT 2025

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

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

Back to the top