| problem with Preferences [message #308182] |
Fri, 15 September 2006 05:30 |
Eclipse User |
|
|
|
I'm trying to move from old preferences code to the new
PreferenceService based preferences but it seems I am having trouble
with that.
I can change values on the preference page and they stay same across
sessions, but somehow the code that is supposed to read these values
does not get values that are displayed on the preference page...
I'm sure I'm doing something wrong here - could anybody please help me
out here and point me to the right direction?
BTW - the target platform of my RCP is 3.1.2
I initialize my defaults with a code that looks roughly like this:
>>> PreferenceInitializer.java:
public void initializeDefaultPreferences() {
IEclipsePreferences node = new DefaultScope().getNode("my.plugin.id");
node.putInt("ComPort/port", 1);
... etc.
}
....
In the preference page I use the code that looks roughly like this:
>>> PreferencePage.java
public class PrinterPreferencePage extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
...
public static final String id = "my.plugin.id";
...
public PrinterPreferencePage() {
super(GRID);
IScopeContext scope = new ConfigurationScope();
IPreferenceStore store = new ScopedPreferenceStore(scope, id);
setPreferenceStore(store);
...
}
...
public void createFieldEditors() {
addField(comPort = new IntegerFieldEditor("ComPort/port",
"COM Port number:", getFieldEditorParent()));
...
}
...
}
The code that should read this preference looks like this:
>>> MyClass.java:
...
public int getComPort() {
IScopeContext scopes = new IScopeContext[]{
new ConfigurationScope(), new DefaultScope()};
IPreferencesService service = Platform.getPreferencesService();
return service.getInt("my.plugin.id", "ComPort/port", 1, scopes);
}
...
--
Roland Tepp
|
|
|
Powered by
FUDForum. Page generated in 0.04251 seconds