Source

lispdev / org.lispdev.preferences /

Filename Size Date modified Message
..
.settings
META-INF
src
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);

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.