Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Preference not re-injected if changed in ConfigurationScope(Preference not re-injected if changed in ConfigurationScope)
Preference not re-injected if changed in ConfigurationScope [message #1691303] Sun, 05 April 2015 04:53 Go to next message
Michael Bartl is currently offline Michael BartlFriend
Messages: 14
Registered: July 2009
Junior Member
HI,

For whatever reason the following code is not executed:

@Inject
private void setNotationFont(@Preference(nodePath = "PCDB", value = PreferenceConstants.NOTATIONFONT) String notationFont)
{
/* do something */
}

after changing the font in the ConfigurationScope with the following:

private static Preferences configurationPreferences = ConfigurationScope.INSTANCE.getNode("PCDB");
configurationPreferences.put(key, value);
try
{
configurationPreferences.flush();
} catch (BackingStoreException e)
{
e.printStackTrace();
}

Interestingly it's executed when changed in the InstanceScope.

Is this known behaviour? If yes, why, because it leads to a lot of code duplication.

Br,
Michael
Re: Preference not re-injected if changed in ConfigurationScope [message #1691304 is a reply to message #1691303] Sun, 05 April 2015 08:21 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
I'm not sure, but it sounds like there is a value in instance and in configuration scope. Changing the value in configuration scope doesn't automatically change the value in the instance scope. And the value in instance scope "wins" over the value in configuration scope. Therefore only changing the value in configuration scope doesn't trigger a re-injection because the preference value hasn't changed for the current running instance.

But I haven't looked at this case in detail. It is just an assumption.
Re: Preference not re-injected if changed in ConfigurationScope [message #1691306 is a reply to message #1691304] Sun, 05 April 2015 09:01 Go to previous messageGo to next message
Michael Bartl is currently offline Michael BartlFriend
Messages: 14
Registered: July 2009
Junior Member
Well, that is true. At first I didn't even want to use the InstanceScop, but if I don't change the value there either it won't re-inject.
So what is the use then or how should it be done, because honestly I only have Configuration Scoped Preferences (as probably 90% of all use-cases for preferences).
Re: Preference not re-injected if changed in ConfigurationScope [message #1691307 is a reply to message #1691306] Sun, 05 April 2015 09:03 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
No I mean, is the value also in instance scope at startup? Not sure how to avoid this if you only want to use the configuration scope.
Re: Preference not re-injected if changed in ConfigurationScope [message #1691375 is a reply to message #1691306] Mon, 06 April 2015 18:02 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
@Preference is bound to instance scope - just look at the
ExtendedObjectSupplier.

Tom

On 05.04.15 11:01, Michael Bartl wrote:
> Well, that is true. At first I didn't even want to use the InstanceScop,
> but if I don't change the value there either it won't re-inject.
> So what is the use then or how should it be done, because honestly I
> only have Configuration Scoped Preferences (as probably 90% of all
> use-cases for preferences).
Previous Topic:Managing Perspective Lifecycle in Eclipse 4
Next Topic:HelpContextId for command in the application model
Goto Forum:
  


Current Time: Mon Sep 23 09:05:11 GMT 2024

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

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

Back to the top