Runtime

## org.eclipse.gmf.runtime.diagram.ui.parts
Class DiagramEditor

    java.lang.Object
      org.eclipse.core.commands.common.EventManager
          org.eclipse.ui.part.WorkbenchPart
              org.eclipse.ui.part.EditorPart
                  org.eclipse.gef.ui.parts.GraphicalEditor
                      org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor

All Implemented Interfaces:
  CommandStackListener, IAdaptable, IDiagramWorkbenchPart, IEditorPart, IExecutableExtension, ISaveablePart, ISelectionListener, IShowInSource, ITabbedPropertySheetPageContributor, IWorkbenchPart, IWorkbenchPart2, IWorkbenchPartOrientation

Direct Known Subclasses:
  DiagramEditorWithFlyOutPalette

public abstract class DiagramEditor
extends GraphicalEditor
implements IDiagramWorkbenchPart, ITabbedPropertySheetPageContributor, IShowInSource

Field Summary
`protected static int` `ID_OUTLINE` teh ID of the outline
`protected static int` `ID_OVERVIEW` the id of the over view
`protected PreferenceStore` `workspaceViewerPreferenceStore` the work space viewer preference store

Fields inherited from interface org.eclipse.ui.IWorkbenchPart
`PROP_TITLE`

Fields inherited from interface org.eclipse.ui.IEditorPart
`PROP_DIRTY, PROP_INPUT`

Constructor Summary
`DiagramEditor()` Creates a new DiagramEditor instance

Method Summary
`protected void` `addDefaultPreferences()` Adds the default preferences to the workspace viewer preference store.
`static void` `addDefaultPreferences(PreferenceStore store, PreferencesHint preferencesHint)` Adds the default preferences to the specified preference store.
`protected void` `clearGraphicalViewerContents()` Clears the contents of the graphical viewer
`protected void` `closeEditor(boolean save)` A utility to close the editor
`protected void` `configureDiagramEditDomain()` Configures my diagram edit domain with its command stack.
`protected void` `configureGraphicalViewer()` Configures the graphical viewer (the primary viewer of the editor)
`protected ActionManager` `createActionManager()`
`protected void` `createActions()` Do nothing
`protected void` `createDiagramEditDomain()` Creates a diagram edit domain
`protected void` `createGraphicalViewer(Composite parent)`
`protected IOperationHistoryListener` `createHistoryListener()` Gets my operation history listener.
`protected IOperationHistory` `createOperationHistory()` Create my operation history.
`protected ScrollingGraphicalViewer` `createScrollingGraphicalViewer()` Creates a ScrollingGraphicalViewer without the drop adapter which excludes drag and drop functionality from other defined views (XML) Subclasses must override this method to include the DnD functionality
`void` `dispose()` Disposes this editor by: 3.
`protected ActionManager` `getActionManager()` Gets the action manager for this diagram editor.
`java.lang.Object` `getAdapter(java.lang.Class type)`
`java.lang.String` `getContributorId()`
`protected int` `getDefaultOutlineViewMode()` Returns this editor's outline-page default display mode.
`Diagram` `getDiagram()` Method getDiagram.
`IDiagramEditDomain` `getDiagramEditDomain()` Method getEditDomain.
`DiagramEditPart` `getDiagramEditPart()` Method getDiagramEditPart.
`IDiagramGraphicalViewer` `getDiagramGraphicalViewer()` Method getDiagramGraphicalViewer.
`org.eclipse.emf.transaction.TransactionalEditingDomain` `getEditingDomain()` Gets my editing domain derived from my diagram editor input.
`protected java.util.List` `getElements(ISelection selection)` Returns the elements in the given selection.
`protected Control` `getGraphicalControl()`
`protected KeyHandler` `getKeyHandler()` Returns the KeyHandler with common bindings for both the Outline and Graphical Views.
`protected IOperationHistory` `getOperationHistory()` Returns the operation history from my action manager.
`protected EditPartFactory` `getOutlineViewEditPartFactory()` Creates edit part factory that will be creating tree edit parts in the tree viewer
`protected PreferencesHint` `getPreferencesHint()` Gets the preferences hint that will be used to determine which preference store to use when retrieving diagram preferences for this diagram editor.
`protected RulerComposite` `getRulerComposite()`
`ShowInContext` `getShowInContext()`
`IWorkbenchPartSite` `getSite()`
`protected IUndoContext` `getUndoContext()` Gets my undo context.
`PreferenceStore` `getWorkspaceViewerPreferenceStore()` Returns the workspace viewer `PreferenceStore`
`protected ZoomManager` `getZoomManager()` A utility method to return the zoom manager from the graphical viewer's root
`void` `init(IEditorSite site, IEditorInput input)`
`protected void` `initializeGraphicalViewer()`
`protected void` `initializeGraphicalViewerContents()`
`boolean` `isWritable()` Returns false if the editor is read only and returns true if the editor is writable.
`void` `persistViewerSettings()` Persists the viewer settings to which this RootEditPart belongs.
`protected void` `setInput(IEditorInput input)`
`protected void` `setRulerComposite(RulerComposite rulerComp)`
`protected void` `setSite(IWorkbenchPartSite site)`
`protected void` `setUndoContext(IUndoContext context)` Sets my undo context
`protected boolean` `shouldAddUndoContext(IUndoableOperation operation)` Answers whether or not I should add my undo context to the undoable `operation`, thereby making the operation available from my undo menu.
`protected void` `startListening()` Installs all the listeners needed by the editor
`protected void` `stopListening()` Removes all the listeners used by the editor

Methods inherited from class org.eclipse.gef.ui.parts.GraphicalEditor
`commandStackChanged, createPartControl, doSaveAs, firePropertyChange, getActionRegistry, getCommandStack, getEditDomain, getGraphicalViewer, getPropertyActions, getSelectionActions, getSelectionSynchronizer, getStackActions, hookGraphicalViewer, initializeActionRegistry, isDirty, isSaveAsAllowed, selectionChanged, setActionRegistry, setEditDomain, setFocus, setGraphicalViewer, updateActions`

Methods inherited from class org.eclipse.ui.part.EditorPart
`checkSite, doSave, getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setInputWithNotify, setPartName`

Methods inherited from class org.eclipse.ui.part.WorkbenchPart
`addPropertyListener, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getTitle, getTitleImage, removePropertyListener, setTitle, setTitleImage, setTitleToolTip, showBusy`

Methods inherited from class org.eclipse.core.commands.common.EventManager
`addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.eclipse.ui.IWorkbenchPart
`addPropertyListener, createPartControl, getTitle, getTitleImage, getTitleToolTip, removePropertyListener, setFocus`

Field Detail

### ID_OUTLINE

    protected static final int ID_OUTLINE

  teh ID of the outline

  See Also:
    Constant Field Values

### ID_OVERVIEW

    protected static final int ID_OVERVIEW

  the id of the over view

  See Also:
    Constant Field Values

### workspaceViewerPreferenceStore

    protected PreferenceStore workspaceViewerPreferenceStore

  the work space viewer preference store

Constructor Detail

### DiagramEditor

    public DiagramEditor()

  Creates a new DiagramEditor instance

Method Detail

### getDefaultOutlineViewMode

    protected int getDefaultOutlineViewMode()

  Returns this editor's outline-page default display mode.

  Returns:
    int the integer value indicating the content-outline-page dispaly mode

### getRulerComposite

    protected RulerComposite getRulerComposite()

  Returns:
    Returns the rulerComp.

### setRulerComposite

    protected void setRulerComposite(RulerComposite rulerComp)

  Parameters:
    `rulerComp` - The rulerComp to set.

### createHistoryListener

    protected IOperationHistoryListener createHistoryListener()

  Gets my operation history listener. By default it adds my undo context to operations that have affected my editing domain.

  Subclasses may override this method to return a different history listener, or to return `null` if they do not want to listen to the operation history.

  Returns:
    my operation history listener

### shouldAddUndoContext

    protected boolean shouldAddUndoContext(IUndoableOperation operation)

  Answers whether or not I should add my undo context to the undoable `operation`, thereby making the operation available from my undo menu.

  The default implementation adds my context to any operation that affected the same editing domain that has loaded the resource that contains my diagram element. Subclasses can override this method if they wish to add their context to operations for different reasons.

  Parameters:
    `operation` - the operation
  Returns:
    `true` if the operation should appear on my undo menu, `false` otherwise.

### getDiagramEditDomain

    public IDiagramEditDomain getDiagramEditDomain()

  Description copied from interface: `IDiagramWorkbenchPart`
  Method getEditDomain.

  Specified by:
    `getDiagramEditDomain` in interface `IDiagramWorkbenchPart`
  Returns:
    DefaultEditDomain
  See Also:
    `IDiagramWorkbenchPart.getDiagramEditDomain()`

### getDiagramGraphicalViewer

    public IDiagramGraphicalViewer getDiagramGraphicalViewer()

  Description copied from interface: `IDiagramWorkbenchPart`
  Method getDiagramGraphicalViewer.

  Specified by:
    `getDiagramGraphicalViewer` in interface `IDiagramWorkbenchPart`
  Returns:
    IDiagramGraphicalViewer
  See Also:
    `IDiagramWorkbenchPart.getDiagramGraphicalViewer()`

### getDiagram

    public Diagram getDiagram()

  Description copied from interface: `IDiagramWorkbenchPart`
  Method getDiagram.

  Specified by:
    `getDiagram` in interface `IDiagramWorkbenchPart`
  Returns:
    Diagram
  See Also:
    `IDiagramWorkbenchPart.getDiagram()`

### getDiagramEditPart

    public DiagramEditPart getDiagramEditPart()

  Description copied from interface: `IDiagramWorkbenchPart`
  Method getDiagramEditPart.

  Specified by:
    `getDiagramEditPart` in interface `IDiagramWorkbenchPart`
  Returns:
    DiagramEditPart
  See Also:
    `IDiagramWorkbenchPart.getDiagramEditPart()`

### getAdapter

    public java.lang.Object getAdapter(java.lang.Class type)

  Specified by:
    `getAdapter` in interface `IAdaptable`
  See Also:
    `IAdaptable.getAdapter(Class)`

### init

    public void init(IEditorSite site,
                     IEditorInput input)
              throws PartInitException

  Specified by:
    `init` in interface `IEditorPart`
  Throws:
    `PartInitException`
  See Also:
    `IEditorPart.init(IEditorSite, IEditorInput)`

### dispose

    public void dispose()

  Disposes this editor by:
  3. Stops all registered listeners

  Specified by:
    `dispose` in interface `IWorkbenchPart`
  See Also:
    `IWorkbenchPart.dispose()`

### getKeyHandler

    protected KeyHandler getKeyHandler()

  Returns the KeyHandler with common bindings for both the Outline and Graphical Views. For example, delete is a common action.

  Returns:
    KeyHandler

### createGraphicalViewer

    protected void createGraphicalViewer(Composite parent)

  See Also:
    `GraphicalEditor.createGraphicalViewer(Composite)`

### createScrollingGraphicalViewer

    protected ScrollingGraphicalViewer createScrollingGraphicalViewer()

  Creates a ScrollingGraphicalViewer without the drop adapter which excludes drag and drop functionality from other defined views (XML) Subclasses must override this method to include the DnD functionality

  Returns:
    ScrollingGraphicalViewer

### configureGraphicalViewer

    protected void configureGraphicalViewer()

  Configures the graphical viewer (the primary viewer of the editor)

### initializeGraphicalViewer

    protected void initializeGraphicalViewer()

  See Also:
    `GraphicalEditor.initializeGraphicalViewer()`

### initializeGraphicalViewerContents

    protected void initializeGraphicalViewerContents()

  See Also:
    `GraphicalEditor.initializeGraphicalViewer()`

### createDiagramEditDomain

    protected void createDiagramEditDomain()

  Creates a diagram edit domain

### configureDiagramEditDomain

    protected void configureDiagramEditDomain()

  Configures my diagram edit domain with its command stack.

### createActionManager

    protected ActionManager createActionManager()

### createOperationHistory

    protected IOperationHistory createOperationHistory()

  Create my operation history.

  Returns:
    my operation history

### setInput

    protected void setInput(IEditorInput input)

  See Also:
    `EditorPart.setInput(IEditorInput)`

### createActions

    protected void createActions()

  Do nothing

  See Also:
    `GraphicalEditor.initializeActionRegistry()`

### closeEditor

    protected void closeEditor(boolean save)

  A utility to close the editor

  Parameters:
    `save` -

### startListening

    protected void startListening()

  Installs all the listeners needed by the editor

### stopListening

    protected void stopListening()

  Removes all the listeners used by the editor

### clearGraphicalViewerContents

    protected void clearGraphicalViewerContents()

  Clears the contents of the graphical viewer

### getActionManager

    protected ActionManager getActionManager()

  Gets the action manager for this diagram editor. The action manager's command manager is used by my edit domain's command stack when executing commands. This is the action manager that is returned when I am asked to adapt to an `ActionManager`.

  Returns:
    the action manager

### getZoomManager

    protected ZoomManager getZoomManager()

  A utility method to return the zoom manager from the graphical viewer's root

  Returns:
    the zoom manager

### getOperationHistory

    protected IOperationHistory getOperationHistory()

  Returns the operation history from my action manager.

  Returns:
    the operation history

### getEditingDomain

    public org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain()

  Gets my editing domain derived from my diagram editor input.

  If subclasses have a known editing domain, they should override this method to return that editing domain as that will be more efficient that the generic implementation provided here.

  Returns:
    my editing domain

### getUndoContext

    protected IUndoContext getUndoContext()

  Gets my undo context. Lazily initializes my undo context if it has not been set.

  Returns:
    my undo context

### setUndoContext

    protected void setUndoContext(IUndoContext context)

  Sets my undo context

  Parameters:
    `context` - the undo context

### getGraphicalControl

    protected Control getGraphicalControl()

  Returns:
    The getRulerComposite(), which is the graphical control

### getSite

    public IWorkbenchPartSite getSite()

  Specified by:
    `getSite` in interface `IWorkbenchPart`
  See Also:
    `IWorkbenchPart.getSite()`

### setSite

    protected void setSite(IWorkbenchPartSite site)

  See Also:
    `WorkbenchPart.setSite(IWorkbenchPartSite)`

### getContributorId

    public java.lang.String getContributorId()

  Specified by:
    `getContributorId` in interface `ITabbedPropertySheetPageContributor`

### addDefaultPreferences

    public static void addDefaultPreferences(PreferenceStore store,
                                             PreferencesHint preferencesHint)

  Adds the default preferences to the specified preference store.

  Parameters:
    `store` - store to use
    `preferencesHint` - The preference hint that is to be used to find the appropriate preference store from which to retrieve diagram preference values. The preference hint is mapped to a preference store in the preference registry <@link DiagramPreferencesRegistry>.

### getWorkspaceViewerPreferenceStore

    public PreferenceStore getWorkspaceViewerPreferenceStore()

  Returns the workspace viewer `PreferenceStore`

  Returns:
    the workspace viewer `PreferenceStore`

### addDefaultPreferences

    protected void addDefaultPreferences()

  Adds the default preferences to the workspace viewer preference store.

### persistViewerSettings

    public void persistViewerSettings()

  Persists the viewer settings to which this RootEditPart belongs. This method should be called when the diagram is being disposed.

### getElements

    protected java.util.List getElements(ISelection selection)

  Returns the elements in the given selection.

  Parameters:
    `selection` - the selection
  Returns:
    a list of `EObject`

### getShowInContext

    public ShowInContext getShowInContext()

  Specified by:
    `getShowInContext` in interface `IShowInSource`

### getPreferencesHint

    protected PreferencesHint getPreferencesHint()

  Gets the preferences hint that will be used to determine which preference store to use when retrieving diagram preferences for this diagram editor. The preference hint is mapped to a preference store in the preference registry <@link DiagramPreferencesRegistry>. By default, this method returns a preference hint configured with the id of the editor. If a preference store has not been registered against this editor id in the diagram preferences registry, then the default values will be used.

  Returns:
    the preferences hint to be used to configure the `RootEditPart`

### isWritable

    public boolean isWritable()

  Returns false if the editor is read only and returns true if the editor is writable. By default, edit parts have their edit mode enabled and this method returns true. Subclasses may override and disable the edit mode on parts.

  Returns:
    false if the editor is read only and returns true if the editor is writable.
  See Also:
    `org.eclipse.gmf.runtime.diagram.ui.internal.editparts.IEditableEditPart.`

### getOutlineViewEditPartFactory

    protected EditPartFactory getOutlineViewEditPartFactory()

  Creates edit part factory that will be creating tree edit parts in the tree viewer

  Returns:
    `EditPartFactory` factory for the tree viewer

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.