Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » PDE: Preferences: default values not available
PDE: Preferences: default values not available [message #148504] Thu, 23 October 2003 11:27 Go to next message
Eclipse UserFriend
Originally posted by: tcn.spamgourmet.com

Hi!

myplugin.getPreferenceStore().getInt(Preferences.P_BLAH);

returns 0, i.e. the default value for an int.

This is because I did not change the default of P_BLAH which is 5000. So, if
I change the value of P_BLAH on the preference page the above call will
return 5000. Or: If I open the preference page prior to the above call it
will also return 5000.

Well, how am I going to do this correctly?

Thanks
Timo
Re: Preferences: default values not available [message #148521 is a reply to message #148504] Thu, 23 October 2003 11:36 Go to previous messageGo to next message
Eclipse UserFriend
If I understand what you are trying to do shouldn't you be using
IPreferenceStrore.getDefaultInt(Preferences.P_BLAH)?

HTH
Darins

"Timo Nentwig" <tcn@spamgourmet.com> wrote in message
news:bn8s0v$k8p$1@eclipse.org...
> Hi!
>
> myplugin.getPreferenceStore().getInt(Preferences.P_BLAH);
>
> returns 0, i.e. the default value for an int.
>
> This is because I did not change the default of P_BLAH which is 5000. So,
if
> I change the value of P_BLAH on the preference page the above call will
> return 5000. Or: If I open the preference page prior to the above call it
> will also return 5000.
>
> Well, how am I going to do this correctly?
>
> Thanks
> Timo
Re: Preferences: default values not available [message #148538 is a reply to message #148521] Thu, 23 October 2003 11:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tcn.spamgourmet.com

Darin Swanson wrote:

> If I understand what you are trying to do shouldn't you be using
> IPreferenceStrore.getDefaultInt(Preferences.P_BLAH)?

This returns the default value of P_BLAH, doesn't it?

Of course I want to get the value the user entered. But if the user didn't
change it I want the dafault value, of course...
Re: Preferences: default values not available [message #148555 is a reply to message #148538] Thu, 23 October 2003 12:01 Go to previous messageGo to next message
Eclipse UserFriend
Sounds like you want to set the default value for your preference.
IPreferenceStore.setDefault(Preferences.P_BLAH, int)

Darins

"Timo Nentwig" <tcn@spamgourmet.com> wrote in message
news:bn8tfe$lv8$1@eclipse.org...
> Darin Swanson wrote:
>
> > If I understand what you are trying to do shouldn't you be using
> > IPreferenceStrore.getDefaultInt(Preferences.P_BLAH)?
>
> This returns the default value of P_BLAH, doesn't it?
>
> Of course I want to get the value the user entered. But if the user didn't
> change it I want the dafault value, of course...
Re: Preferences: default values not available [message #148571 is a reply to message #148555] Thu, 23 October 2003 12:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tcn.spamgourmet.com

Darin Swanson wrote:

> Sounds like you want to set the default value for your preference.
> IPreferenceStore.setDefault(Preferences.P_BLAH, int)

?? No.

I want to get it. The default values are automatically set when the
preference page is once opened:

public Preferences() {
super(GRID);
setPreferenceStore(Plugin.getDefault().getPreferenceStore()) ;
setDescription("A demonstration of a preference page implementation");
initializeDefaults();
}

private void initializeDefaults() {
IPreferenceStore store = getPreferenceStore();
store.setDefault(P_BLAH, 5000);

}

But initializeDefaults() is only called when I open the preferenc page,
right? So, I don't know how eclipse does handle this internally or how it
does make changes to the preferences persistent, but the sense of a
preference page is to change the values, not to be called each time I want
to know them in order to use them...

I just need the value of P_BLAH in order for the plugin to work.
Re: Preferences: default values not available [message #148579 is a reply to message #148571] Thu, 23 October 2003 12:30 Go to previous messageGo to next message
Eclipse UserFriend
You need to move your initialization out of being tied to opening the
preference page.

We initialize our preferences (as all plugins should) using
AbstractUIPlugin.initializeDefaultPreferences(IPreferenceSto re) or
Plugin.initializeDefaultPluginPreferences depending on which type hierarchy
your plugin is involved with.

Darins

"Timo Nentwig" <tcn@spamgourmet.com> wrote in message
news:bn8ug4$n0n$1@eclipse.org...
> Darin Swanson wrote:
>
> > Sounds like you want to set the default value for your preference.
> > IPreferenceStore.setDefault(Preferences.P_BLAH, int)
>
> ?? No.
>
> I want to get it. The default values are automatically set when the
> preference page is once opened:
>
> public Preferences() {
> super(GRID);
>
setPreferenceStore(Plugin.getDefault().getPreferenceStore()) ;
> setDescription("A demonstration of a preference page
implementation");
> initializeDefaults();
> }
>
> private void initializeDefaults() {
> IPreferenceStore store = getPreferenceStore();
> store.setDefault(P_BLAH, 5000);
>
> }
>
> But initializeDefaults() is only called when I open the preferenc page,
> right? So, I don't know how eclipse does handle this internally or how it
> does make changes to the preferences persistent, but the sense of a
> preference page is to change the values, not to be called each time I want
> to know them in order to use them...
>
> I just need the value of P_BLAH in order for the plugin to work.
Re: Preferences: default values not available [message #148587 is a reply to message #148579] Thu, 23 October 2003 12:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tcn.spamgourmet.com

Darin Swanson wrote:

> You need to move your initialization out of being tied to opening the
> preference page.
>
> We initialize our preferences (as all plugins should) using
> AbstractUIPlugin.initializeDefaultPreferences(IPreferenceSto re) or
> Plugin.initializeDefaultPluginPreferences depending on which type
> hierarchy your plugin is involved with.

public Plugin(IPluginDescriptor descriptor)
{
super(descriptor);
plugin = this;
// neither this
initializeDefaultPluginPreferences();
// nor that
initializeDefaultPreferences(getPreferenceStore());
// does help :-(
Re: Preferences: default values not available [message #148602 is a reply to message #148587] Thu, 23 October 2003 12:50 Go to previous messageGo to next message
Eclipse UserFriend
You do not need to call these methods...part of the plugin lifecycle.
What does your implementation of these methods look like?

Darins

"Timo Nentwig" <tcn@spamgourmet.com> wrote in message
news:bn9028$op0$1@eclipse.org...
> Darin Swanson wrote:
>
> > You need to move your initialization out of being tied to opening the
> > preference page.
> >
> > We initialize our preferences (as all plugins should) using
> > AbstractUIPlugin.initializeDefaultPreferences(IPreferenceSto re) or
> > Plugin.initializeDefaultPluginPreferences depending on which type
> > hierarchy your plugin is involved with.
>
> public Plugin(IPluginDescriptor descriptor)
> {
> super(descriptor);
> plugin = this;
> // neither this
> initializeDefaultPluginPreferences();
> // nor that
> initializeDefaultPreferences(getPreferenceStore());
> // does help :-(
Re: Preferences: default values not available [message #148615 is a reply to message #148602] Thu, 23 October 2003 12:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tcn.spamgourmet.com

Darin Swanson wrote:
> You do not need to call these methods...part of the plugin lifecycle.
> What does your implementation of these methods look like?

Now I'm completely confused :-) You mean, I need to implement
initializeDefaultPluginPreferences() myself?? And what shall I do within
it? I canno call the initialize method of the Preference class...

Can you post a simple example snippet?
Re: Preferences: default values not available [message #148623 is a reply to message #148615] Thu, 23 October 2003 12:58 Go to previous messageGo to next message
Eclipse UserFriend
Use the source...see DebugUIPlugin

Darins

"Timo Nentwig" <tcn@spamgourmet.com> wrote in message
news:bn90uo$pec$1@eclipse.org...
> Darin Swanson wrote:
> > You do not need to call these methods...part of the plugin lifecycle.
> > What does your implementation of these methods look like?
>
> Now I'm completely confused :-) You mean, I need to implement
> initializeDefaultPluginPreferences() myself?? And what shall I do within
> it? I canno call the initialize method of the Preference class...
>
> Can you post a simple example snippet?
Re: Preferences: default values not available [message #148631 is a reply to message #148623] Thu, 23 October 2003 13:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tcn.spamgourmet.com

Darin Swanson wrote:

> Use the source...see DebugUIPlugin

Thanks.

It's somewhat strange code that's being generated by eclipse' wizard.

And how besides newbies does use wizards??

Anyway...
Re: Preferences: default values not available [message #148729 is a reply to message #148631] Thu, 23 October 2003 16:15 Go to previous message
Eclipse UserFriend
Originally posted by: bob.objfac.com

Here's a snippet. In your plugin class:

protected void initializeDefaultPreferences(IPreferenceStore store) {
PreferenceConverter.setDefault(store, Constants.ID_COMMENT,
Constants.COMMENT_RGB);
//...
store.setDefault(Constants.ID_TAB_WIDTH, 2);
}

Bob Foster

"Timo Nentwig" <tcn@spamgourmet.com> wrote in message
news:bn92an$r09$1@eclipse.org...
> Darin Swanson wrote:
>
> > Use the source...see DebugUIPlugin
>
> Thanks.
>
> It's somewhat strange code that's being generated by eclipse' wizard.
>
> And how besides newbies does use wizards??
>
> Anyway...
Previous Topic:How to distribute native DLLs with my pligin.
Next Topic:Scroll to line in TextEditor
Goto Forum:
  


Current Time: Mon Jul 14 08:35:47 EDT 2025

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

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

Back to the top