Source

lispdev / org.lispdev.preferences /

Filename Size Date modified Message
..
.settings
META-INF
src/org/lispdev/preferences
376 B
684 B
109 B
326 B
1.7 KB
How to use preferences:

Instantiate PreferencesService class with the name of language (for example "CL").
In editor plugin the class is instantiated at plugin startup. Also right after
PreferenceService initialization call init() function of Preference class (see
next para) to register default values.

Create enum class to keep preference items (see Preference class: org.lispdev.editor.preferences.Preference).
This class creates preference items. Each item has preference id, name, tooltip, type and default value.
Type is one of the PreferenceType.

Create preference page by extending ItemPreferencesPage. The page have to implement createFieldEditors, which
should populate protected itemEditors list. There are two ways to add editors - one is creating an editor
manually and adding it to the list. The other, much simpler is to call addDefaultItemField function with
a corresponding item. Depending on item type its default editor will be created and associated with the item.
Add extension to org.eclipse.ui.preferencePages extension point. In extension refer to
the class of this page.

Register and unregister objects with preference items. An object should implement ItemListener interface.
To add object to an item listener, get hold of the corresponding enum, get item from it, and add the object as a
listener at creation or when necessary:
     Preference.COLOR_INNER.item().addListener(EditorPlugin.get().getPreferences(), this);
Preference change events are processed by handleChange function of ItemListener interface.
Finally cleanup by unregistering the object from items it listens to:
    Preference.COLOR_INNER.item().removeListener(this);