How to work with preferences

From Bioclipse
Jump to: navigation, search
Development tutorial
Responsible author:Ola
Bioclipse version:N/A
"N/A" is not a number.
Last updated:2009-10-10
Tags:


Set a preference item

IEclipsePreferences node = new DefaultScope().getNode("net.bioclipse.ui");
String pref=node.put("test", "weehow");

Get a preference item

IEclipsePreferences node = new DefaultScope().getNode("net.bioclipse.ui");
String pref=node.get("test", null);

Create a PreferenceInitializer

Add in plugin.xml:

<extension
   point="org.eclipse.core.runtime.preferences">
   <initializer class="net.bioclipse.ui.prefs.BioclipsePreferenceInitializer"/>
</extension>

And implement the class:

public class BioclipsePreferenceInitializer extends AbstractPreferenceInitializer {
  @Override
  public void initializeDefaultPreferences() {
    IEclipsePreferences node = new DefaultScope().getNode("net.bioclipse.ui");
    node.put("test", "weehow");
  }
}


Create a PreferencePage

See the following pages:

Listen for changes in preference

It is common that plugins update their UI items depending on preferences. They can register themselves and listen for preference changes via the IPreferenceChangeListener interface.

TBC