
|
Version: 0.1 |
Date: July 13, 2005 |
· Overview
· Creating the Preference Page Classes
· Registering the Preference Page Classes
· Creating the Preferences Initializer
· Registering the Preferences Initializer
· Registering the Preference Store
· Summary
This tutorial provides the reader with the steps to setup diagram preferences for a diagram client. The following diagram preferences can be configured for your diagram so that the user can configure certain aspects of a diagram.
org.eclipse.ui.editors
org.eclipse.ui.preferencePages
org.eclipse.core.runtime.preferencesMore information about these extension points can be found in the Eclipse documentation.
In this tutorial, we will use the Logic Diagram Example to illustrate how to configure diagram preferences for a logic diagram. To gain familiarity with the Logic Diagram Example, refer to the Logic Example Guide.
Create a subclass of the diagram preference page that you wish to expose to your diagram users. In the constructor of each subclass, set the preference store to be that from your plug-in.
public class LogicAppearancePreferencePage
extends AppearancePreferencePage {
public LogicAppearancePreferencePage() {
super();
setPreferenceStore(LogicDiagramPlugin.getInstance().getPreferenceStore());
}
}<extension point="org.eclipse.ui.preferencePages">
<page
name="%PreferencePage.Root.Diagrams"
class="org.eclipse.gmf.examples.runtime.diagram.logic.internal.preferences.LogicDiagramsPreferencePage"
id="org.eclipse.gmf.examples.runtime.diagram.logic.internal.preferences.LogicDiagramsPreferencePage">
</page>
<page
name="%PreferencePage.Appearance"
category="org.eclipse.gmf.examples.runtime.diagram.logic.internal.preferences.LogicDiagramsPreferencePage"
class="org.eclipse.gmf.examples.runtime.diagram.logic.internal.preferences.LogicAppearancePreferencePage"
id="org.eclipse.gmf.examples.runtime.diagram.logic.internal.preferences.LogicAppearancePreferencePage">
</page>
<page
name="%PreferencePage.Connections"
category="org.eclipse.gmf.examples.runtime.diagram.logic.internal.preferences.LogicAppearancePreferencePage"
class="org.eclipse.gmf.examples.runtime.diagram.logic.internal.preferences.LogicConnectionsPreferencePage"
id="org.eclipse.gmf.examples.runtime.diagram.logic.internal.preferences.LogicConnectionsPreferencePage">
</page>
<page
name="%PreferencePage.RulerGrid"
category="org.eclipse.gmf.examples.runtime.diagram.logic.internal.preferences.LogicAppearancePreferencePage"
class="org.eclipse.gmf.examples.runtime.diagram.logic.internal.preferences.LogicRulerGridPreferencePage"
id="org.eclipse.gmf.examples.runtime.diagram.logic.internal.preferences.LogicRulerGridPreferencePage">
</page>
</extension>public class LogicPreferencesInitializer
extends DiagramPreferenceInitializer {
protected IPreferenceStore getPreferenceStore() {
return LogicDiagramPlugin.getInstance().getPreferenceStore();
}
}<extension point="org.eclipse.core.runtime.preferences">
<initializer class="org.eclipse.gmf.examples.runtime.diagram.logic.internal.preferences.LogicPreferencesInitializer" />
</extension>Register the preference store against a preference hint with the editor id of the diagram editor. The Logic Diagram Example registers its preference store in its plug-in's doStartUp() method.
public void doStartup() {
super.doStartup();
PreferencesHint.registerPreferenceStore(
new PreferencesHint("LogicEditor"), getPreferenceStore());
}<extension point="org.eclipse.ui.editors">
<editor
...
id="LogicEditor">
</editor>
</extension>In this tutorial, we did the following:
Copyright (c) 2000,2005 IBM Corporation and others. All Rights Reserved.