| PDE: Preferences: default values not available [message #148504] |
Thu, 23 October 2003 11:27  |
|
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 #148538 is a reply to message #148521] |
Thu, 23 October 2003 11:52   |
|
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 #148571 is a reply to message #148555] |
Thu, 23 October 2003 12:10   |
|
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 #148587 is a reply to message #148579] |
Thu, 23 October 2003 12:36   |
|
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 #148615 is a reply to message #148602] |
Thu, 23 October 2003 12:52   |
|
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 #148729 is a reply to message #148631] |
Thu, 23 October 2003 16:15  |
|
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...
|
|
|
Powered by
FUDForum. Page generated in 0.02481 seconds