using Preferences [message #462449] |
Mon, 29 January 2007 17:18 |
Eclipse User |
|
|
|
Originally posted by: georg.moleque.com.br
Hi all,
I got a bit confused of how to use Preferences with RCP (SDK
3.2.1/Windows XP) correctly.
I would like to save user specific preferences persistently.
Following "Eclipse: Building Commercial-Quality Plug-ins" (Clayberg,
Rubel), I have my own MyPlugin.class extending AbstractUIPlugin. In my
Preference Page, I set the Preference store in the constructor:
GeneralPreferencePage()
{
setPreferenceStore(MyPlugin.getDefault().getPreferenceStore( ));
}
It doesn´t seem to work for me, though. If I change some property, next
time I start the plugin, retrieving this property with
MyPlugin.getDefault().getPluginPreferences().getString(...)
always returns the default value, no changes were saved.
What works for me, is to save and retrieve preferences using
new ScopedPreferenceStore( new ConfigurationScope(),MyPlugin.PLUGIN_ID),
but as I understood from the book, the preferred way should be to use
getPreferenceStore() from MyPlugin. So why it doesn´t work?
Thanks for anyone who could enlight me here,
Georg
|
|
|
Re: using Preferences [message #462459 is a reply to message #462449] |
Mon, 29 January 2007 18:24 |
Snjezana Peco Messages: 789 Registered: July 2009 |
Senior Member |
|
|
Are you using MyPlugin.getDefault().getPreferenceStore().setValue(...) ?
Snjeza
Georg von Bülow wrote:
> Hi all,
>
> I got a bit confused of how to use Preferences with RCP (SDK
> 3.2.1/Windows XP) correctly.
>
> I would like to save user specific preferences persistently.
> Following "Eclipse: Building Commercial-Quality Plug-ins" (Clayberg,
> Rubel), I have my own MyPlugin.class extending AbstractUIPlugin. In my
> Preference Page, I set the Preference store in the constructor:
>
> GeneralPreferencePage()
> {
> setPreferenceStore(MyPlugin.getDefault().getPreferenceStore( ));
> }
>
> It doesn´t seem to work for me, though. If I change some property, next
> time I start the plugin, retrieving this property with
>
> MyPlugin.getDefault().getPluginPreferences().getString(...)
>
> always returns the default value, no changes were saved.
>
> What works for me, is to save and retrieve preferences using
> new ScopedPreferenceStore( new ConfigurationScope(),MyPlugin.PLUGIN_ID),
> but as I understood from the book, the preferred way should be to use
> getPreferenceStore() from MyPlugin. So why it doesn´t work?
>
> Thanks for anyone who could enlight me here,
>
> Georg
>
>
>
>
>
|
|
|
Re: using Preferences [message #462462 is a reply to message #462459] |
Mon, 29 January 2007 18:56 |
Eclipse User |
|
|
|
Originally posted by: georg.moleque.com.br
Snjezana Peco escreveu:
> Are you using MyPlugin.getDefault().getPreferenceStore().setValue(...) ?
>
> Snjeza
No, I thought changes in the PreferencePage should be saved automatically.
What I just found out is that it works when I export and run the product
outside eclipse. So it´s only not working during development in eclipse.
Somehow it has to do with that the PreferenceStore is "Instance scoped",
though I have to admit that I haven´t understood 100% yet why i
doesn´t work.
> Georg von Bülow wrote:
>> Hi all,
>>
>> I got a bit confused of how to use Preferences with RCP (SDK
>> 3.2.1/Windows XP) correctly.
>>
>> I would like to save user specific preferences persistently.
>> Following "Eclipse: Building Commercial-Quality Plug-ins" (Clayberg,
>> Rubel), I have my own MyPlugin.class extending AbstractUIPlugin. In my
>> Preference Page, I set the Preference store in the constructor:
>>
>> GeneralPreferencePage()
>> {
>> setPreferenceStore(MyPlugin.getDefault().getPreferenceStore( ));
>> }
>>
>> It doesn´t seem to work for me, though. If I change some property,
>> next time I start the plugin, retrieving this property with
>>
>> MyPlugin.getDefault().getPluginPreferences().getString(...)
>>
>> always returns the default value, no changes were saved.
>>
>> What works for me, is to save and retrieve preferences using
>> new ScopedPreferenceStore( new
>> ConfigurationScope(),MyPlugin.PLUGIN_ID), but as I understood from the
>> book, the preferred way should be to use getPreferenceStore() from
>> MyPlugin. So why it doesn´t work?
>>
>> Thanks for anyone who could enlight me here,
>>
>> Georg
>>
>>
>>
>>
>>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03257 seconds