Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » using Preferences
using Preferences [message #462449] Mon, 29 January 2007 17:18 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Snjezana Peco is currently offline Snjezana PecoFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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
>>
>>
>>
>>
>>
Re: using Preferences [message #462535 is a reply to message #462449] Tue, 30 January 2007 10:15 Go to previous message
Patrick Godeau is currently offline Patrick GodeauFriend
Messages: 64
Registered: July 2009
Member
Hi,

Maybe you could check this link:
http://wiki.eclipse.org/index.php/FAQ_How_do_I_load_and_save _plug-in_preferences%3F
Previous Topic:Class loading and serialization
Next Topic:Reusing workbench messages
Goto Forum:
  


Current Time: Sun Sep 08 03:49:38 GMT 2024

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

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

Back to the top