![]() |
The implementation of a preference page requires that you define an
extension in your plug-in and provide an implementation of the
extension. The plugin.xml
defines two preference page
extensions. One is a custom page implemented as a subclass of PreferencePage
that implements IWorkbenchPreferencePage
.
The second page is built using the FieldEditor framework, so it is a
subclass of FieldEditorPreferencePage
.
When using the FieldEditor framework the user interface constructed with
controls implemented using FieldEditor
subtypes.
To run the example, launch the run-time instance of Eclipse (Run > Run As > Run-time Workbench).
MyPrefPageBasic
class:initializeDefaultPreferences
method as part of the preference store life cycle. performOk
method will store the values in the plug-in's preference store. MyPrefPageFieldEditor
class. This example preference page shows how you can quickly create simple pages that handle much of the layout, retrieval, and saving of preferences using the field editors preference page framework: MyPrefPageControl
class that will report when preferences in the com.ibm.soln.dialogs
plug-in have changed:noDefaultAndApplyButton
method to
hide those buttons). This page exists to provide a convenient place to demonstrate the code that
interact with the preference store.Note: The preference values are not saved on disk until you
shut down Eclipse, unless you have added save processing logic to your
preference page implementation. By default, this example plug-in will
save the preference store as part of the shutdown
method
inherited from AbstractUIPlugin
.
\.metadata\.plugins\com.ibm.lab.soln.dialogs\pref_store.inThe .ini file will contain something like this:
#Sun Feb 02 23:45:06 EST 2003 BOOLEAN_KEY=true Recent_Edits_Limit=12 text_field_key=qrs FILE_KEY=E\:\\aEclipseBase\\edu.jar COLOR_KEY=128,0,128 DIR_KEY=D\:\\Eclipse_Jumpstart
This example includes two preference page extensions that demonstrate two ways of building the user interface. It also demonstrates the use of a plug-in's preference store, and the ability to determine when preference store values change. The extension definitions can be found in the plugin.xml. The classes that implement these extensions and capabilities are shown below.
Extension / Object | Implementation |
---|---|
Preference page extensions | The Basic preference page is implemented by the MyPrefPageBasic
class. |
The field editor preference page is implemented by the MyPrefPageFieldEditor
class. |
|
The control preference page, which is only used to start and stop
a preference change listener and force the save of preference store
values, is implemented by the MyPrefPageControl
class. |
|
Preference Value Change Listener | The property change listener for preference changes is
implemented by PreferenceListener ,
a DialogsPlugin
inner class. |
© Copyright International Business Machines Corporation, 2003.
All rights reserved.