Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse GMF Guide
Previous Page Home Next Page

Tutorial: Diagram Preferences

Version: 0.1

Date: July 13, 2005

Contents

· Overview

· References

· Introduction

· Creating the Preference Page Classes

· Registering the Preference Page Classes

· Creating the Preferences Initializer

· Registering the Preferences Initializer

· Registering the Preference Store

· Summary

Overview

[ back to top]

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.

References

[ back to top]

This tutorial references the following extension points:

org.eclipse.ui.editors org.eclipse.ui.preferencePages org.eclipse.core.runtime.preferences

More information about these extension points can be found in the Eclipse documentation.

Introduction

[ back to top]

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 ExampleGuide.

Creating the Preference Page Classes

[ back to top]

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()); } }

Registering the Preference Page Classes

[ back to top]

Add an extension to register each preference page.

<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>

Creating the Preferences Initializer

[ back to top]

Create a subclass of the diagram preference initializer and in its constructor, set the preference store to be that from your plug-in.

public class LogicPreferencesInitializer extends DiagramPreferenceInitializer { protected IPreferenceStore getPreferenceStore() { return LogicDiagramPlugin.getInstance().getPreferenceStore(); } }

Registering the Preferences Initializer

[ back to top]

Add an extension to register the preference initializer.

<extension point="org.eclipse.core.runtime.preferences"> <initializer class="org.eclipse.gmf.examples.runtime.diagram.logic.internal.preferences.LogicPreferencesInitializer" /> </extension>

Registering the Preference Store

[ back to top]

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()); }
The editor id was defined in the Logic Diagram Example plugin.xml file:

<extension point="org.eclipse.ui.editors"> <editor ... id="LogicEditor"> </editor> </extension>

Summary

[ back to top]

In this tutorial, we did the following:

  1. Created the preference page classes.
  2. Registered the preference page classes.
  3. Created the preference initializer.
  4. Registered the preference initializer.
  5. Registered the preference store.


Copyright (c) 2000,2005 IBM Corporation and others. All Rights Reserved.








 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire