Runtime

org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts
Class DiagramDocumentEditor

java.lang.Object
  extended byorg.eclipse.core.commands.common.EventManager
      extended byorg.eclipse.ui.part.WorkbenchPart
          extended byorg.eclipse.ui.part.EditorPart
              extended byorg.eclipse.gef.ui.parts.GraphicalEditor
                  extended byorg.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor
                      extended byorg.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFlyOutPalette
                          extended byorg.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor
All Implemented Interfaces:
CommandStackListener, IAdaptable, IDiagramWorkbenchPart, IDocumentEditor, IEditorPart, IExecutableExtension, IReusableEditor, ISaveablePart, ISelectionListener, IShowInSource, ITabbedPropertySheetPageContributor, IWorkbenchPart, IWorkbenchPart2, IWorkbenchPartOrientation
Direct Known Subclasses:
IDEDiagramDocumentEditor

public class DiagramDocumentEditor
extends DiagramEditorWithFlyOutPalette
implements IDocumentEditor, IReusableEditor

A Diagram Editor with optional flyout palette.


Nested Class Summary
 
Nested classes inherited from class org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFlyOutPalette
DiagramEditorWithFlyOutPalette.CustomPalettePage
 
Field Summary
protected  java.lang.String fErrorLabel
          The error message shown in the status line in case of failed information look up.
 
Fields inherited from class org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFlyOutPalette
COLLAPSED, UNCOLLAPSED_PINNED
 
Fields inherited from class org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor
ID_OUTLINE, ID_OVERVIEW, workspaceViewerPreferenceStore
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
DiagramDocumentEditor(boolean hasFlyoutPalette)
          Constructs a diagram editor with optional flyout palette.
 
Method Summary
 boolean askUserReload()
           
 int askUserSaveClose()
           
 boolean askUserSaveOverwrite()
           
 void close(boolean save)
          Closes this text editor after optionally saving changes.
protected  void configureDiagramEditDomain()
          Configures my diagram edit domain with its command stack.
protected  ActionManager createActionManager()
           
protected  org.eclipse.emf.transaction.TransactionalEditingDomain createEditingDomain()
          Gets an editing domain from the editing domain registry using the id returned from DiagramDocumentEditor.getEditingDomainID() if an editing domain has been registered already with this id.
protected  IOperationHistory createOperationHistory()
          Create my operation history.
 void createPartControl(Composite parent)
          Creates a splitter composite that will contain 2 parts one is for the diagram and the other is for the palette.
 void dispose()
          Disposes this editor by:
3.
protected  void disposeDocumentProvider()
          Disposes of the connection with the document provider.
 void doSave(IProgressMonitor progressMonitor)
          The AbstractDiagramEditor implementation of this IEditorPart method may be extended by subclasses.
 void doSaveAs()
          The AbstractDiagramEditor implementation of this IEditorPart method calls performSaveAs.
 void doSetInput(IEditorInput input, boolean releaseEditorContents)
           
protected  void editorSaved()
          Hook which gets called when the editor has been saved.
protected  void enableSanityChecking(boolean enable)
          Enables/disables sanity checking.
protected  void enableStateValidation(boolean enable)
          Enables/disables state validation.
protected  void firePropertyChange(int property)
           
 java.lang.Object getAdapter(java.lang.Class type)
          Adapts to PalettePage.class PaletteViewer.class other wise delegates to super.getAdapter()
protected  java.lang.Object getDefaultPaletteContent()
          Gets the palette content to be sent to the palette service when creating the palette.
 Diagram getDiagram()
          Method getDiagram.
 IDiagramDocument getDiagramDocument()
           
 IDocumentProvider getDocumentProvider()
          Returns this text editor's document provider.
protected  IDocumentProvider getDocumentProvider(IEditorInput input)
          Hook method for setting the document provider for the given input.
 org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain()
          Gets my editing domain derived from my diagram editor input.
protected  java.lang.String getEditingDomainID()
          Returns an editing domain id used to retrive an editing domain from the editing domain registry.
protected  IEditorDescriptor getEditorDescriptor()
          Retrieves the descriptor for this editor
protected  IProgressMonitor getProgressMonitor()
          Returns the progress monitor related to this editor.
protected  void handleEditorInputChanged()
          Handles an external change of the editor's input element.
protected  void handleElementContentAboutToBeReplaced()
          Performs any additional action necessary to perform after the input document's content has been replaced.
protected  void handleElementContentReplaced()
          Performs any additional action necessary to perform after the input document's content has been replaced.
protected  void handleExceptionOnSave(CoreException exception, IProgressMonitor progressMonitor)
          Handles the given exception.
 void init(IEditorSite site, IEditorInput input)
           
 boolean isDirty()
           
 boolean isEditable()
          Returns whether the text in this text editor can be changed by the user.
 boolean isEditorInputModifiable()
          Returns whether the editor's input can be persistently be modified.
 boolean isEditorInputReadOnly()
          Returns whether the editor's input is read-only.
 boolean isSaveAsAllowed()
          The AbstractDiagramEditor implementation of this IEditorPart method returns false.
protected  void performSave(boolean overwrite, IProgressMonitor progressMonitor)
          Performs the save and handles errors appropriately.
protected  void performSaveAs(IProgressMonitor progressMonitor)
          Performs a save as and reports the result state back to the given progress monitor.
protected  void releaseInput()
          refreshes the editor with the given file by: 0 - resets resource modification stamp 1- Flushing the command stack 2- Clearing the graphical viewer's contents 3- Setting the new File input 4- Setting the new graphical viewer's contents 5- Clearing the graphical viewer's selection
protected  boolean reuseDiagramOnMove()
           
protected  void safelySanityCheckState(IEditorInput input)
          Checks the state of the given editor input if sanity checking is enabled.
protected  void sanityCheckState(IEditorInput input)
          Checks the state of the given editor input.
 void selectionChanged(IWorkbenchPart part, ISelection selection)
           
protected  void setDocumentProvider(IDocumentProvider provider)
          Sets this editor's document provider.
protected  void setDocumentProvider(IEditorInput input)
          Hook method for setting the document provider for the given input.
 void setInput(IEditorInput input)
           
protected  void setSite(IWorkbenchPartSite site)
           
protected  void updateState(IEditorInput input)
          Updates the state of the given editor input such as read-only flag.
 boolean validateEditorInputState()
          Validates the state of the given editor input.
protected  void validateState(IEditorInput input)
          Validates the state of the given editor input.
 
Methods inherited from class org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFlyOutPalette
configurePaletteViewer, createPaletteRoot, createPaletteViewerProvider, getInitialPaletteSize, getInitialPaletteState, getPaletteViewerProvider, handlePaletteDefaultStateChanged, handlePaletteResized, initializeGraphicalViewer, setEditDomain, setFocus, startListening, stopListening
 
Methods inherited from class org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor
addDefaultPreferences, addDefaultPreferences, clearGraphicalViewerContents, closeEditor, configureGraphicalViewer, createActions, createDiagramEditDomain, createGraphicalViewer, createHistoryListener, createScrollingGraphicalViewer, getActionManager, getContributorId, getDefaultOutlineViewMode, getDiagramEditDomain, getDiagramEditPart, getDiagramGraphicalViewer, getElements, getGraphicalControl, getKeyHandler, getOperationHistory, getOutlineViewEditPartFactory, getPreferencesHint, getRulerComposite, getShowInContext, getSite, getUndoContext, getWorkspaceViewerPreferenceStore, getZoomManager, initializeGraphicalViewerContents, isWritable, persistViewerSettings, setRulerComposite, setUndoContext, shouldAddUndoContext
 
Methods inherited from class org.eclipse.gef.ui.parts.GraphicalEditor
commandStackChanged, getActionRegistry, getCommandStack, getEditDomain, getGraphicalViewer, getPropertyActions, getSelectionActions, getSelectionSynchronizer, getStackActions, hookGraphicalViewer, initializeActionRegistry, setActionRegistry, setGraphicalViewer, updateActions
 
Methods inherited from class org.eclipse.ui.part.EditorPart
checkSite, 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.IEditorPart
getEditorInput, getEditorSite
 
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener, setFocus
 
Methods inherited from interface org.eclipse.ui.ISaveablePart
isSaveOnCloseNeeded
 

Field Detail

fErrorLabel

protected final java.lang.String fErrorLabel
The error message shown in the status line in case of failed information look up.

Constructor Detail

DiagramDocumentEditor

public DiagramDocumentEditor(boolean hasFlyoutPalette)
Constructs a diagram editor with optional flyout palette.

Parameters:
hasFlyoutPalette - creates a palette if true, else no palette
Method Detail

getAdapter

public java.lang.Object getAdapter(java.lang.Class type)
Description copied from class: DiagramEditorWithFlyOutPalette
Adapts to
  • PalettePage.class
  • PaletteViewer.class other wise delegates to super.getAdapter()

    Specified by:
    getAdapter in interface IAdaptable
    Overrides:
    getAdapter in class DiagramEditorWithFlyOutPalette

  • init

    public void init(IEditorSite site,
                     IEditorInput input)
              throws PartInitException
    Specified by:
    init in interface IEditorPart
    Overrides:
    init in class DiagramEditor
    Throws:
    PartInitException
    See Also:
    IEditorPart.init(IEditorSite, IEditorInput)

    setSite

    protected final void setSite(IWorkbenchPartSite site)
    Overrides:
    setSite in class DiagramEditor
    See Also:
    WorkbenchPart.setSite(IWorkbenchPartSite)

    dispose

    public void dispose()
    Description copied from class: DiagramEditor
    Disposes this editor by:
    3. Stops all registered listeners

    Specified by:
    dispose in interface IWorkbenchPart
    Overrides:
    dispose in class DiagramEditor
    See Also:
    IWorkbenchPart.dispose()

    getDiagram

    public Diagram getDiagram()
    Description copied from interface: IDiagramWorkbenchPart
    Method getDiagram.

    Specified by:
    getDiagram in interface IDiagramWorkbenchPart
    Overrides:
    getDiagram in class DiagramEditor
    See Also:
    IDiagramWorkbenchPart.getDiagram()

    getDiagramDocument

    public IDiagramDocument getDiagramDocument()

    askUserSaveOverwrite

    public boolean askUserSaveOverwrite()

    askUserSaveClose

    public int askUserSaveClose()

    askUserReload

    public boolean askUserReload()

    configureDiagramEditDomain

    protected void configureDiagramEditDomain()
    Description copied from class: DiagramEditor
    Configures my diagram edit domain with its command stack.

    Overrides:
    configureDiagramEditDomain in class DiagramEditor
    See Also:
    DiagramEditor.configureDiagramEditDomain()

    createActionManager

    protected ActionManager createActionManager()
    Overrides:
    createActionManager in class DiagramEditor

    createOperationHistory

    protected IOperationHistory createOperationHistory()
    Create my operation history.

    Overrides:
    createOperationHistory in class DiagramEditor
    Returns:
    my operation history

    getDefaultPaletteContent

    protected java.lang.Object getDefaultPaletteContent()
    Description copied from class: DiagramEditorWithFlyOutPalette
    Gets the palette content to be sent to the palette service when creating the palette.

    Specified by:
    getDefaultPaletteContent in class DiagramEditorWithFlyOutPalette
    Returns:
    the palette content

    selectionChanged

    public void selectionChanged(IWorkbenchPart part,
                                 ISelection selection)
    Specified by:
    selectionChanged in interface ISelectionListener

    getDocumentProvider

    public IDocumentProvider getDocumentProvider()
    Description copied from interface: IDocumentEditor
    Returns this text editor's document provider.

    Specified by:
    getDocumentProvider in interface IDocumentEditor
    Returns:
    the document provider or null if none, e.g. after closing the editor

    setDocumentProvider

    protected void setDocumentProvider(IDocumentProvider provider)
    Sets this editor's document provider. This method must be called before the editor's control is created.

    Parameters:
    provider - the document provider

    isEditable

    public boolean isEditable()
    Description copied from interface: IDocumentEditor
    Returns whether the text in this text editor can be changed by the user.

    Specified by:
    isEditable in interface IDocumentEditor
    Returns:
    true if it can be edited, and false if it is read-only

    setDocumentProvider

    protected void setDocumentProvider(IEditorInput input)
    Hook method for setting the document provider for the given input. This default implementation does nothing. Clients may reimplement.

    Parameters:
    input - the input of this editor.

    getDocumentProvider

    protected IDocumentProvider getDocumentProvider(IEditorInput input)
    Hook method for setting the document provider for the given input. This default implementation does nothing. Clients may reimplement.

    Parameters:
    input - the input of this editor.

    releaseInput

    protected void releaseInput()
    refreshes the editor with the given file by: 0 - resets resource modification stamp 1- Flushing the command stack 2- Clearing the graphical viewer's contents 3- Setting the new File input 4- Setting the new graphical viewer's contents 5- Clearing the graphical viewer's selection


    setInput

    public void setInput(IEditorInput input)
    Specified by:
    setInput in interface IReusableEditor
    Overrides:
    setInput in class DiagramEditor
    See Also:
    EditorPart.setInput(IEditorInput)

    doSetInput

    public void doSetInput(IEditorInput input,
                           boolean releaseEditorContents)
                    throws CoreException
    Throws:
    CoreException

    close

    public void close(boolean save)
    Description copied from interface: IDocumentEditor
    Closes this text editor after optionally saving changes.

    Specified by:
    close in interface IDocumentEditor
    Parameters:
    save - true if unsaved changed should be saved, and false if unsaved changed should be discarded

    disposeDocumentProvider

    protected void disposeDocumentProvider()
    Disposes of the connection with the document provider. Subclasses may extend.


    getProgressMonitor

    protected IProgressMonitor getProgressMonitor()
    Returns the progress monitor related to this editor. It should not be necessary to extend this method.

    Returns:
    the progress monitor related to this editor

    handleEditorInputChanged

    protected void handleEditorInputChanged()
    Handles an external change of the editor's input element. Subclasses may extend.


    doSaveAs

    public void doSaveAs()
    The AbstractDiagramEditor implementation of this IEditorPart method calls performSaveAs. Subclasses may reimplement.

    Specified by:
    doSaveAs in interface ISaveablePart

    performSaveAs

    protected void performSaveAs(IProgressMonitor progressMonitor)
    Performs a save as and reports the result state back to the given progress monitor. This default implementation does nothing. Subclasses may reimplement.

    Parameters:
    progressMonitor - the progress monitor for communicating result state or null

    doSave

    public void doSave(IProgressMonitor progressMonitor)
    The AbstractDiagramEditor implementation of this IEditorPart method may be extended by subclasses.

    Specified by:
    doSave in interface ISaveablePart
    Parameters:
    progressMonitor - the progress monitor for communicating result state or null

    enableSanityChecking

    protected void enableSanityChecking(boolean enable)
    Enables/disables sanity checking.

    Parameters:
    enable - true if sanity checking should be enabled, false otherwise

    safelySanityCheckState

    protected void safelySanityCheckState(IEditorInput input)
    Checks the state of the given editor input if sanity checking is enabled.

    Parameters:
    input - the editor input whose state is to be checked

    sanityCheckState

    protected void sanityCheckState(IEditorInput input)
    Checks the state of the given editor input.

    Parameters:
    input - the editor input whose state is to be checked

    enableStateValidation

    protected void enableStateValidation(boolean enable)
    Enables/disables state validation.

    Parameters:
    enable - true if state validation should be enabled, false otherwise

    validateState

    protected void validateState(IEditorInput input)
    Validates the state of the given editor input. The predominate intent of this method is to take any action probably necessary to ensure that the input can persistently be changed.

    Parameters:
    input - the input to be validated

    validateEditorInputState

    public boolean validateEditorInputState()
    Description copied from interface: IDocumentEditor
    Validates the state of the given editor input. The predominate intent of this method is to take any action probably necessary to ensure that the input can persistently be changed.

    Specified by:
    validateEditorInputState in interface IDocumentEditor
    Returns:
    true if the input was validated, false otherwise

    updateState

    protected void updateState(IEditorInput input)
    Updates the state of the given editor input such as read-only flag.

    Parameters:
    input - the input to be validated

    performSave

    protected void performSave(boolean overwrite,
                               IProgressMonitor progressMonitor)
    Performs the save and handles errors appropriately.

    Parameters:
    overwrite - indicates whether or not overwriting is allowed
    progressMonitor - the monitor in which to run the operation

    handleExceptionOnSave

    protected void handleExceptionOnSave(CoreException exception,
                                         IProgressMonitor progressMonitor)
    Handles the given exception. If the exception reports an out-of-sync situation, this is reported to the user. Otherwise, the exception is generically reported.

    Parameters:
    exception - the exception to handle
    progressMonitor - the progress monitor

    isSaveAsAllowed

    public boolean isSaveAsAllowed()
    The AbstractDiagramEditor implementation of this IEditorPart method returns false. Subclasses may override.

    Specified by:
    isSaveAsAllowed in interface ISaveablePart
    Returns:
    false

    isDirty

    public boolean isDirty()
    Specified by:
    isDirty in interface ISaveablePart

    handleElementContentReplaced

    protected void handleElementContentReplaced()
    Performs any additional action necessary to perform after the input document's content has been replaced.

    Clients may extended this method.


    handleElementContentAboutToBeReplaced

    protected void handleElementContentAboutToBeReplaced()
    Performs any additional action necessary to perform after the input document's content has been replaced.

    Clients may extended this method.


    editorSaved

    protected void editorSaved()
    Hook which gets called when the editor has been saved. Subclasses may extend.


    firePropertyChange

    protected void firePropertyChange(int property)

    isEditorInputReadOnly

    public boolean isEditorInputReadOnly()
    Description copied from interface: IDocumentEditor
    Returns whether the editor's input is read-only. The semantics of this method is orthogonal to isEditable as it talks about the editor input, i.e. the domain element, and not about the editor document.

    Specified by:
    isEditorInputReadOnly in interface IDocumentEditor
    Returns:
    true if the editor input is read-only

    isEditorInputModifiable

    public boolean isEditorInputModifiable()
    Description copied from interface: IDocumentEditor
    Returns whether the editor's input can be persistently be modified. This is orthogonal to ITextEditorExtension.isEditorInputReadOnly as read-only elements may be modifiable and writable elements may not be modifiable. If the given element is not connected to this document provider, the result is undefined. Document providers are allowed to use a cache to answer this question, i.e. there can be a difference between the "real" state of the element and the return value.

    Specified by:
    isEditorInputModifiable in interface IDocumentEditor
    Returns:
    true if the editor input is modifiable

    getEditorDescriptor

    protected final IEditorDescriptor getEditorDescriptor()
    Retrieves the descriptor for this editor

    Returns:
    the editor descriptor

    createPartControl

    public void createPartControl(Composite parent)
    Description copied from class: DiagramEditorWithFlyOutPalette
    Creates a splitter composite that will contain 2 parts one is for the diagram and the other is for the palette.

    Specified by:
    createPartControl in interface IWorkbenchPart
    Overrides:
    createPartControl in class DiagramEditorWithFlyOutPalette
    See Also:
    IWorkbenchPart.createPartControl(Composite)

    getEditingDomain

    public org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain()
    Description copied from class: DiagramEditor
    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.

    Overrides:
    getEditingDomain in class DiagramEditor
    Returns:
    my editing domain

    createEditingDomain

    protected org.eclipse.emf.transaction.TransactionalEditingDomain createEditingDomain()
    Gets an editing domain from the editing domain registry using the id returned from DiagramDocumentEditor.getEditingDomainID() if an editing domain has been registered already with this id. Use the org.eclipse.emf.transaction.editingDomains extension point to register a shared editing domain.

    If an editing domain is not found for the id, then a new editing domain will be created per editor instance.

    Returns:
    the editing domain

    getEditingDomainID

    protected java.lang.String getEditingDomainID()
    Returns an editing domain id used to retrive an editing domain from the editing domain registry. Clients should override this if they wish to use a shared editing domain for this editor. If null is returned then a new editing domain will be created per editor instance.

    Returns:
    the shared editing domain id if applicable

    reuseDiagramOnMove

    protected boolean reuseDiagramOnMove()

    Runtime

    Guidelines for using Eclipse APIs.

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