org.eclipse.graphiti.ui.editor
Class DiagramBehavior

java.lang.Object
  extended by org.eclipse.graphiti.ui.editor.DiagramBehavior
All Implemented Interfaces:
IDiagramBehavior, IDiagramBehaviorUI

public class DiagramBehavior
extends Object
implements IDiagramBehaviorUI

Provides the common functionality needed to display and manage diagrams. Diagrams can be displayed either in a simple SWT Composite, in a ViewPart or in an IEditorPart, so it's not possible to provide common functionality through sub-classing.

Since:
0.10

Field Summary
private  IConfigurationProviderInternal configurationProvider
           
private  ContextMenuProvider contextMenuProvider
           
private  DiagramChangeListener diagramChangeListener
           
private  IDiagramContainerUI diagramContainer
           
private  IDiagramEditorInput diagramEditorInput
           
private  DiagramScrollingBehavior diagramScrollingBehavior
           
private  boolean directEditingActive
           
private  DomainModelChangeListener domainModelListener
           
private  String editorInitializationError
           
private  CommandStackEventListener gefCommandStackListener
           
private  KeyHandler keyHandler
           
private  DefaultMarkerBehavior markerBehavior
           
private  Point mouseLocation
           
private  DefaultPaletteBehavior paletteBehaviour
           
private  IWorkbenchPart parentPart
           
private  DefaultPersistencyBehavior persistencyBehavior
           
private  PictogramElement[] pictogramElementsForSelection
           
private  DefaultRefreshBehavior refreshBehavior
           
private  DefaultUpdateBehavior updateBehavior
           
 
Constructor Summary
DiagramBehavior(IDiagramContainerUI diagramContainer)
           
 
Method Summary
protected  void addGefListeners()
          Adds the needed GEF listeners after the edit domain is initialized
 Point calculateRealMouseLocation(Point nativeLocation)
          Calculates the mouse location depending on scrollbars and zoom factor.
protected  void configureGraphicalViewer()
          Called to configure the behavior viewer, before it receives its content.
protected  List<TransferDropTargetListener> createBusinessObjectDropTargetListeners()
          Creates a list of drop target listeners that enable dropping domain objects into the diagram, e.g.
protected  ContextMenuProvider createContextMenuProvider()
          Returns a new ContextMenuProvider.
protected  void createErrorPartControl(Composite parent)
          Creates the default error page in case an error occurred while initializing this behavior.
protected  void createGraphicalViewer(Composite parent)
          Creates the GraphicalViewer on the specified Composite and initializes it.
protected  DefaultMarkerBehavior createMarkerBehavior()
          Creates the behavior extension that deals with markers.
protected  DefaultPaletteBehavior createPaletteBehaviour()
          Creates the behavior extension that deals with the palette handling.
protected  TransferDropTargetListener createPaletteDropTargetListener()
          Creates the drop target listener that is used for adding new objects from the palette via drag and drop.
protected  PaletteViewerProvider createPaletteViewerProvider()
          Delegates to the method (or the method in a subclass of) #createPaletteViewerProvider() to create the PaletteViewerProvider used inside the GEF editor.
protected  DefaultPersistencyBehavior createPersistencyBehavior()
          Creates the behavior extension that deals with the persistence handling.
protected  DefaultRefreshBehavior createRefreshBehavior()
          Creates the behavior extension that deals with the refresh handling.
protected  DefaultUpdateBehavior createUpdateBehavior()
          Creates the behavior extension that deals with the update handling.
protected  void disableAdapters()
          Should be called (e.g.
protected  void disposeAfterGefDispose()
          The part of the dispose that should happen after the GEF dispose.
protected  void disposeBeforeGefDispose()
          The part of the dispose that should happen before the GEF dispose.
protected  void editingDomainInitialized()
          Hook that is called by the holder of the TransactionalEditingDomain (DefaultUpdateBehavior or a subclass of it) after the editing domain has been initialized.
protected  void enableAdapters()
          Should be called by the various behavior instances after mass EMF resource operations have been triggered (e.g.
 Object executeFeature(IFeature feature, IContext context)
          Executes the given IFeature with the given IContext in the scope of this DiagramBehavior, meaning within its TransactionalEditingDomain and on its CommandStack.
 Object getAdapter(Class type)
          Implements the Eclipse IAdaptable interface.
protected  KeyHandler getCommonKeyHandler()
          Returns the KeyHandler with common bindings to be used for both the Outline and the Graphical Viewer.
protected  IConfigurationProvider getConfigurationProvider()
          Returns the ConfigurationProvider for this behavior.
 EditPart getContentEditPart()
          Returns the contents EditPart of this behavior.
 IDiagramContainerUI getDiagramContainer()
          Returns the associated container displaying the diagram of this behavior object.
private  DiagramScrollingBehavior getDiagramScrollingBehavior()
          Deprecated. Scroll bar based infinite canvas is a workaround for GEF limitations.
 IDiagramTypeProvider getDiagramTypeProvider()
          Returns the IDiagramTypeProvider instance associated with this DiagramBehavior.
 DefaultEditDomain getEditDomain()
          Delegation method to retrieve the GEF edit domain also here.
 TransactionalEditingDomain getEditingDomain()
          Returns the EMF TransactionalEditingDomain used within this behavior object by delegating to the update behavior extension, by default DefaultUpdateBehavior.getEditingDomain().
protected  String getEditorInitializationError()
          Returns if an error has occured while initializing this behavior and its components.
 GraphicalEditPart getEditPartForPictogramElement(PictogramElement pe)
          Method to retrieve the GEF EditPart for a given PictogramElement.
private  FigureCanvas getFigureCanvas()
           
 IFigure getFigureForPictogramElement(PictogramElement pe)
          Method to retrieve the Draw2D IFigure for a given PictogramElement.
private  GFFigureCanvas getGFFigureCanvas()
           
protected  IDiagramEditorInput getInput()
          Returns the DiagramEditorInput instance used in this behavior.
protected  DefaultMarkerBehavior getMarkerBehavior()
          Returns the instance of the marker behavior that is used with this behavior.
 Point getMouseLocation()
          Gets the current mouse location as a Point.
protected  DefaultPaletteBehavior getPaletteBehavior()
          Returns the instance of the palette behavior that is used with this behavior.
protected  FlyoutPreferences getPalettePreferences()
          Delegates to the method (or the method in a subclass of) DefaultPaletteBehavior.getPalettePreferences().
protected  PaletteRoot getPaletteRoot()
          Returns the PaletteRoot to use in the GEF editor by delegating to DefaultPaletteBehavior.getPaletteRoot().
protected  IWorkbenchPart getParentPart()
          Returns the parent IWorkbenchPart this behavior is embedded into.
protected  DefaultPersistencyBehavior getPersistencyBehavior()
          Returns the instance of the persistency behavior that is used with this behavior.
protected  PictogramElement[] getPictogramElementsForSelection()
          Returns the PictogramElements that are set for later selection.
 DefaultRefreshBehavior getRefreshBehavior()
          Returns the instance of the refresh behavior that is used with this behavior.
 ResourceSet getResourceSet()
          The EMF ResourceSet used within this DiagramBehavior.
 PictogramElement[] getSelectedPictogramElements()
          Returns the PictogramElements that are currently selected in the diagram.
 DefaultUpdateBehavior getUpdateBehavior()
          Returns the instance of the update behavior that is used with this behavior.
 double getZoomLevel()
          Returns the zoom level currently used in the diagram.
protected  void initActionRegistry(ZoomManager zoomManager)
          Initializes the action registry with the predefined actions (update, remove, delete, copy, paste, zooming, direct editing, alignment and toggling actions for the diagram grip and hiding of the context button pad.
protected  void initDefaultBehaviors()
          Hook to initialize the default sub behavior instances used by this editor behavior.
protected  void initializeGraphicalViewer()
          Called to initialize the behavior viewer with its content.
 boolean isAlive()
          Checks if this behavior is alive.
 boolean isDirectEditingActive()
          Returns if direct editing is currently active for this behavior.
protected  boolean isDirty()
          Returns the dirty state of this behavior object
protected  void migrateDiagramModelIfNecessary()
          We provide migration from 0.8.0 to 0.9.0.
 void refresh()
          Triggers a complete refresh of the behavior visualization (content, title, tooltip, palette and decorators) by delegating to DefaultRefreshBehavior.refresh().
 void refreshContent()
          Refreshes the content of the editor (what's shown inside the diagram itself).
 void refreshPalette()
          Refreshes the palette to correctly reflect all available creation tools for the available create features and the currently enabled selection tools.
 void refreshRenderingDecorators(PictogramElement pe)
          Refreshes the rendering decorators (image decorators and the like) by delegating to DefaultRefreshBehavior.refreshRenderingDecorators(PictogramElement) for the given PictogramElement.
protected  void registerAction(IAction action)
          Registers the given action with the Eclipse ActionRegistry.
protected  void registerBusinessObjectsListener()
          Hook that is called to register listeners for changes of the business objects (domain objects) in the resource set of the editor.
protected  void registerDiagramResourceSetListener()
          Hook to register listeners for diagram changes.
 void selectBufferedPictogramElements()
          Triggers the selection for the PictogramElements that are stored for later selection.
protected  void selectPictogramElements(PictogramElement[] pictogramElements)
          Selects the given PictogramElements in the diagram.
private  void setConfigurationProvider(IConfigurationProviderInternal configurationProvider)
           
 void setDirectEditingActive(boolean directEditingActive)
          Sets that direct editing is now active in the behavior or not.
protected  void setInput(IDiagramEditorInput input)
          Sets the given IDiagramEditorInput object as the input for this behavior instance.
private  void setMouseLocation(int x, int y)
           
protected  void setParentPart(IWorkbenchPart parentPart)
          Sets the parent IWorkbenchPart for this behavior.
 void setPictogramElementForSelection(PictogramElement pictogramElement)
          Sets one PictogramElement for later selection.
protected  void setPictogramElementsForSelection(PictogramElement[] pictogramElements)
          Sets PictogramElements for later selection.
protected  boolean shouldRegisterContextMenu()
          Allows subclasses to prevent that the diagram context menu should be registered for extensions at Eclipse.
protected  void unregisterBusinessObjectsListener()
          Hook that is called to unregister the listeners for changes of the business objects (domain objects).
protected  void unregisterDiagramResourceSetListener()
          Hook to unregister the listeners for diagram changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

diagramContainer

private IDiagramContainerUI diagramContainer

updateBehavior

private DefaultUpdateBehavior updateBehavior

paletteBehaviour

private DefaultPaletteBehavior paletteBehaviour

persistencyBehavior

private DefaultPersistencyBehavior persistencyBehavior

markerBehavior

private DefaultMarkerBehavior markerBehavior

refreshBehavior

private DefaultRefreshBehavior refreshBehavior

pictogramElementsForSelection

private PictogramElement[] pictogramElementsForSelection

configurationProvider

private IConfigurationProviderInternal configurationProvider

mouseLocation

private Point mouseLocation

keyHandler

private KeyHandler keyHandler

diagramScrollingBehavior

private DiagramScrollingBehavior diagramScrollingBehavior

directEditingActive

private boolean directEditingActive

gefCommandStackListener

private CommandStackEventListener gefCommandStackListener

diagramChangeListener

private DiagramChangeListener diagramChangeListener

domainModelListener

private DomainModelChangeListener domainModelListener

diagramEditorInput

private IDiagramEditorInput diagramEditorInput

editorInitializationError

private String editorInitializationError

parentPart

private IWorkbenchPart parentPart

contextMenuProvider

private ContextMenuProvider contextMenuProvider
Constructor Detail

DiagramBehavior

public DiagramBehavior(IDiagramContainerUI diagramContainer)
Method Detail

getDiagramContainer

public IDiagramContainerUI getDiagramContainer()
Returns the associated container displaying the diagram of this behavior object.

Specified by:
getDiagramContainer in interface IDiagramBehavior
Returns:
The associated IDiagramContainerUI instance.

createMarkerBehavior

protected DefaultMarkerBehavior createMarkerBehavior()
Creates the behavior extension that deals with markers. See DefaultMarkerBehavior for details and the default implementation. Override to change the marker behavior.

Returns:
a new instance of DefaultMarkerBehavior

getMarkerBehavior

protected DefaultMarkerBehavior getMarkerBehavior()
Returns the instance of the marker behavior that is used with this behavior. To change the behavior override createMarkerBehavior() .

Returns:
the used instance of the marker behavior, by default a DefaultMarkerBehavior.

createUpdateBehavior

protected DefaultUpdateBehavior createUpdateBehavior()
Creates the behavior extension that deals with the update handling. See DefaultUpdateBehavior for details and the default implementation. Override to change the update behavior.

Returns:
a new instance of DefaultUpdateBehavior

getUpdateBehavior

public DefaultUpdateBehavior getUpdateBehavior()
Returns the instance of the update behavior that is used with this behavior. To change the behavior override createUpdateBehavior() .

Returns:
the used instance of the marker behavior, by default a DefaultUpdateBehavior.

createPaletteBehaviour

protected DefaultPaletteBehavior createPaletteBehaviour()
Creates the behavior extension that deals with the palette handling. See DefaultPaletteBehavior for details and the default implementation. Override to change the palette behavior.

Returns:
a new instance of DefaultPaletteBehavior

getPaletteBehavior

protected DefaultPaletteBehavior getPaletteBehavior()
Returns the instance of the palette behavior that is used with this behavior. To change the behavior override createPaletteBehaviour() .

Returns:
the used instance of the palette behavior, by default a DefaultPaletteBehavior.

createPersistencyBehavior

protected DefaultPersistencyBehavior createPersistencyBehavior()
Creates the behavior extension that deals with the persistence handling. See DefaultPersistencyBehavior for details and the default implementation. Override to change the persistence behavior.

Returns:
a new instance of DefaultPersistencyBehavior

getPersistencyBehavior

protected DefaultPersistencyBehavior getPersistencyBehavior()
Returns the instance of the persistency behavior that is used with this behavior. To change the behavior override createPersistencyBehavior() .

Returns:
the used instance of the persistency behavior, by default a DefaultPersistencyBehavior.

createRefreshBehavior

protected DefaultRefreshBehavior createRefreshBehavior()
Creates the behavior extension that deals with the refresh handling. See DefaultRefreshBehavior for details and the default implementation. Override to change the refresh behavior.

Returns:
a new instance of DefaultRefreshBehavior

getRefreshBehavior

public DefaultRefreshBehavior getRefreshBehavior()
Returns the instance of the refresh behavior that is used with this behavior. To change the behavior override createRefreshBehavior() .

Returns:
the used instance of the refresh behavior, by default a DefaultRefreshBehavior.

initDefaultBehaviors

protected void initDefaultBehaviors()
Hook to initialize the default sub behavior instances used by this editor behavior. The default implementation simply delegates to the create methods for the various objects. In case other default behavior implementation should be used, clients should override these create methods instead of this method.

See Also:
createMarkerBehavior(), createUpdateBehavior(), createPaletteBehaviour(), createPersistencyBehavior(), createRefreshBehavior()

setInput

protected void setInput(IDiagramEditorInput input)
Sets the given IDiagramEditorInput object as the input for this behavior instance. The default implementation here cares about loading the diagram from the EMF Resource the input points to, sets the ID of the IDiagramTypeProvider for the diagram given in the input, registers listeners (by delegating to registerDiagramResourceSetListener() and registerBusinessObjectsListener()) and does the refreshing of the UI.

Parameters:
input - the DiagramEditorInput instance to use within this behavior.

addGefListeners

protected void addGefListeners()
Adds the needed GEF listeners after the edit domain is initialized


createGraphicalViewer

protected void createGraphicalViewer(Composite parent)
Creates the GraphicalViewer on the specified Composite and initializes it.

Parameters:
parent - the parent composite

configureGraphicalViewer

protected void configureGraphicalViewer()
Called to configure the behavior viewer, before it receives its content. The default-implementation is for example doing the following: configure the ZoomManager, registering Actions... Here everything is done, which is independent of the IConfigurationProvider.

See Also:
org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer()

initializeGraphicalViewer

protected void initializeGraphicalViewer()
Called to initialize the behavior viewer with its content. Here everything is done, which is dependent of the IConfigurationProvider.

See Also:
org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette#initializeGraphicalViewer()

createPaletteDropTargetListener

protected TransferDropTargetListener createPaletteDropTargetListener()
Creates the drop target listener that is used for adding new objects from the palette via drag and drop. Clients may change the default behavior by providing their own drop target listener or disable drag and drop from the palette by returning null.

Returns:
An instance of the TransferDropTargetListener that handles dropping new objects from the palette or null to disable dropping from the palette.
Since:
0.10

createBusinessObjectDropTargetListeners

protected List<TransferDropTargetListener> createBusinessObjectDropTargetListeners()
Creates a list of drop target listeners that enable dropping domain objects into the diagram, e.g. from the project explorer. By adding additional listeners other sources may be enabled, simply returning an empty list will disable drag and drop into the editor.

Returns:
a List containing all the TransferDropTargetListener that shall be registered in the editor.
Since:
0.10

getEditorInitializationError

protected String getEditorInitializationError()
Returns if an error has occured while initializing this behavior and its components. In case this method reports true and error UI may be shown instead of the normal diagram viewer.

Returns:
true in case an error has occured, false otherwise

createErrorPartControl

protected void createErrorPartControl(Composite parent)
Creates the default error page in case an error occurred while initializing this behavior.

Parameters:
parent - The parent Composite to add the UI to

isDirty

protected boolean isDirty()
Returns the dirty state of this behavior object

Returns:
true in case the stored saved command is different from the next undo command.

createPaletteViewerProvider

protected final PaletteViewerProvider createPaletteViewerProvider()
Delegates to the method (or the method in a subclass of) #createPaletteViewerProvider() to create the PaletteViewerProvider used inside the GEF editor.

Returns:
the PaletteViewerProvider to use

getPalettePreferences

protected final FlyoutPreferences getPalettePreferences()
Delegates to the method (or the method in a subclass of) DefaultPaletteBehavior.getPalettePreferences(). To change the palette override the behavior there.

Returns:
the PaletteViewerProvider preferences to use.

getPaletteRoot

protected final PaletteRoot getPaletteRoot()
Returns the PaletteRoot to use in the GEF editor by delegating to DefaultPaletteBehavior.getPaletteRoot().

Returns:
the PaletteRoot to use

refresh

public void refresh()
Triggers a complete refresh of the behavior visualization (content, title, tooltip, palette and decorators) by delegating to DefaultRefreshBehavior.refresh().

Specified by:
refresh in interface IDiagramBehavior

refreshRenderingDecorators

public void refreshRenderingDecorators(PictogramElement pe)
Refreshes the rendering decorators (image decorators and the like) by delegating to DefaultRefreshBehavior.refreshRenderingDecorators(PictogramElement) for the given PictogramElement.

Specified by:
refreshRenderingDecorators in interface IDiagramBehavior
Parameters:
pe - the PictogramElement for which the decorators shall be refreshed.

refreshPalette

public void refreshPalette()
Refreshes the palette to correctly reflect all available creation tools for the available create features and the currently enabled selection tools.

Specified by:
refreshPalette in interface IDiagramBehavior

refreshContent

public void refreshContent()
Refreshes the content of the editor (what's shown inside the diagram itself).

Specified by:
refreshContent in interface IDiagramBehavior

selectPictogramElements

protected void selectPictogramElements(PictogramElement[] pictogramElements)
Selects the given PictogramElements in the diagram.

Parameters:
pictogramElements - an array of PictogramElements to select.

getSelectedPictogramElements

public PictogramElement[] getSelectedPictogramElements()
Returns the PictogramElements that are currently selected in the diagram.

Returns:
an array of PictogramElements.

setPictogramElementForSelection

public void setPictogramElementForSelection(PictogramElement pictogramElement)
Sets one PictogramElement for later selection.

The methods getPictogramElementsForSelection(), setPictogramElementForSelection(PictogramElement), setPictogramElementsForSelection(PictogramElement[]) and selectBufferedPictogramElements() offer the possibility to use a deferred selection mechanism: via the setters, PictogramElements can be stored for a selection operation that is triggered lateron during a general refresh via the method selectBufferedPictogramElements(). This mechanism is used e.g. in the Graphiti framework in direct editing to restore the previous selection, but can also be used by clients.

Parameters:
pictogramElement - the PictogramElement that shall be stored for later selection

setPictogramElementsForSelection

protected void setPictogramElementsForSelection(PictogramElement[] pictogramElements)
Sets PictogramElements for later selection.

The methods getPictogramElementsForSelection(), setPictogramElementForSelection(PictogramElement), setPictogramElementsForSelection(PictogramElement[]) and selectBufferedPictogramElements() offer the possibility to use a deferred selection mechanism: via the setters, PictogramElements can be stored for a selection operation that is triggered later on during a general refresh via the method selectBufferedPictogramElements(). This mechanism is used e.g. in the Graphiti framework in direct editing to restore the previous selection, but can also be used by clients.

Parameters:
pictogramElements - the PictogramElements that shall be stored for later selection

selectBufferedPictogramElements

public void selectBufferedPictogramElements()
Triggers the selection for the PictogramElements that are stored for later selection. Can be called e.g during a general refresh of the editor or after another operation needing another selection is finished (an example in the framework is direct editing).

The methods getPictogramElementsForSelection(), setPictogramElementForSelection(PictogramElement), setPictogramElementsForSelection(PictogramElement[]) and selectBufferedPictogramElements() offer the possibility to use a deferred selection mechanism: via the setters, PictogramElements can be stored for a selection operation that is triggered later on during a general refresh via the method selectBufferedPictogramElements(). This mechanism is used e.g. in the Graphiti framework in direct editing to restore the previous selection, but can also be used by clients.


getPictogramElementsForSelection

protected PictogramElement[] getPictogramElementsForSelection()
Returns the PictogramElements that are set for later selection.

The methods getPictogramElementsForSelection(), setPictogramElementForSelection(PictogramElement), setPictogramElementsForSelection(PictogramElement[]) and selectBufferedPictogramElements() offer the possibility to use a deferred selection mechanism: via the setters, PictogramElements can be stored for a selection operation that is triggered lateron during a general refresh via the method selectBufferedPictogramElements(). This mechanism is used e.g. in the Graphiti framework in direct editing to restore the previous selection, but can also be used by clients.

Returns:
the PictogramElements stored for later selection

getEditingDomain

public TransactionalEditingDomain getEditingDomain()
Returns the EMF TransactionalEditingDomain used within this behavior object by delegating to the update behavior extension, by default DefaultUpdateBehavior.getEditingDomain().

Specified by:
getEditingDomain in interface IDiagramBehavior
Returns:
the TransactionalEditingDomain instance used in the behavior

getResourceSet

public ResourceSet getResourceSet()
The EMF ResourceSet used within this DiagramBehavior. The resource set is always associated in a 1:1 relation to the TransactionalEditingDomain.

Returns:
the resource set used within this behavior object

getDiagramTypeProvider

public IDiagramTypeProvider getDiagramTypeProvider()
Returns the IDiagramTypeProvider instance associated with this DiagramBehavior. There is always a 1:1 relation between the behavior and the provider.

Returns:
the associated IDiagramTypeProvider instance.

executeFeature

public Object executeFeature(IFeature feature,
                             IContext context)
Executes the given IFeature with the given IContext in the scope of this DiagramBehavior, meaning within its TransactionalEditingDomain and on its CommandStack.

Specified by:
executeFeature in interface IDiagramBehavior
Parameters:
feature - the feature to execute
context - the context to use. In case the passed feature is a IAddFeature this context needs to be an instance of IAddContext, otherwise an AssertionFailedException will be thrown.
Returns:
in case of an IAddFeature being passed as feature the newly added PictogramElement will be returned (in case the add method returning it), in all other cases null
Since:
0.9

disableAdapters

protected void disableAdapters()
Should be called (e.g. by the various behavior instances) before mass EMF resource operations are triggered (e.g. saving all resources). Can be used to disable eventing for performance reasons. See enableAdapters() as well.
Important note: make sure that you re-enable eventing using enableAdapters() after the operation has finished (best in a finally clause to do that also in case of exceptions), otherwise strange errors may happen.


enableAdapters

protected void enableAdapters()
Should be called by the various behavior instances after mass EMF resource operations have been triggered (e.g. saving all resources). Can be used to re-enable eventing after it was disabled for performance reasons. See disableAdapters() as well.
Must be called after disableAdapters() has been called and the operation has finshed (best in a finally clause to also enable the exception case), otherwise strange errors may occur within the editor.


isAlive

public boolean isAlive()
Checks if this behavior is alive.

Returns:
true, if editor contains a model connector and a valid Diagram, false otherwise.

editingDomainInitialized

protected void editingDomainInitialized()
Hook that is called by the holder of the TransactionalEditingDomain (DefaultUpdateBehavior or a subclass of it) after the editing domain has been initialized. Can be used to e.g. register additional listeners on the domain.
The default implementation notifies the marker behavior extension to register its listeners.


getAdapter

public Object getAdapter(Class type)
Implements the Eclipse IAdaptable interface. This implementation first delegates to the IToolBehaviorProvider.getAdapter(Class) method and checks if something is returned. In case the return value is null it returns adapters for ZoomManager, IPropertySheetPage, Diagram, KeyHandler, SelectionSynchronizer and IContextButtonManager. It also delegates to the super implementation in GraphicalEditorWithFlyoutPalette#getAdapter(Class).

Parameters:
type - the type to which shall be adapted
Returns:
the adapter instance

getConfigurationProvider

protected IConfigurationProvider getConfigurationProvider()
Returns the ConfigurationProvider for this behavior. It is mainly a wrapper around varius objects that are connected to the diagram behavior.

Returns:
an IConfigurationProvider instance.

getContentEditPart

public EditPart getContentEditPart()
Returns the contents EditPart of this behavior. This is the topmost EditPart in the GraphicalViewer.

Returns:
The contents EditPart of this behavior.

getEditPartForPictogramElement

public GraphicalEditPart getEditPartForPictogramElement(PictogramElement pe)
Method to retrieve the GEF EditPart for a given PictogramElement.

Specified by:
getEditPartForPictogramElement in interface IDiagramBehaviorUI
Parameters:
pe - the PictogramElement to retrieve the GEF representation for
Returns:
the GEF GraphicalEditPart that represents the given PictogramElement.

getMouseLocation

public Point getMouseLocation()
Gets the current mouse location as a Point.

Returns:
the mouse location

calculateRealMouseLocation

public Point calculateRealMouseLocation(Point nativeLocation)
Calculates the mouse location depending on scrollbars and zoom factor.

Specified by:
calculateRealMouseLocation in interface IDiagramBehaviorUI
Parameters:
nativeLocation - the native location given as Point
Returns:
the Point of the real mouse location

isDirectEditingActive

public boolean isDirectEditingActive()
Returns if direct editing is currently active for this behavior.

Returns:
true in case direct editing is currently active within this editor, false otherwise.

setDirectEditingActive

public void setDirectEditingActive(boolean directEditingActive)
Sets that direct editing is now active in the behavior or not. Note that this flag set to true does not actually start direct editing it is simply an indication that prevents certain operations from running (e.g. refresh)

Parameters:
directEditingActive - true to set the flag to direct editing currently active, false otherwise.

getZoomLevel

public double getZoomLevel()
Returns the zoom level currently used in the diagram.

Returns:
the zoom level

getFigureForPictogramElement

public IFigure getFigureForPictogramElement(PictogramElement pe)
Method to retrieve the Draw2D IFigure for a given PictogramElement.

Specified by:
getFigureForPictogramElement in interface IDiagramBehaviorUI
Parameters:
pe - the PictogramElement to retrieve the Draw2D representation for
Returns:
the Draw2D IFigure that represents the given PictogramElement.

setConfigurationProvider

private void setConfigurationProvider(IConfigurationProviderInternal configurationProvider)

setMouseLocation

private void setMouseLocation(int x,
                              int y)

createContextMenuProvider

protected ContextMenuProvider createContextMenuProvider()
Returns a new ContextMenuProvider. Clients can return null, if no context-menu shall be displayed.

Returns:
A new instance of ContextMenuProvider.

shouldRegisterContextMenu

protected boolean shouldRegisterContextMenu()
Allows subclasses to prevent that the diagram context menu should be registered for extensions at Eclipse. By default others can provide extensions to the menu (default return value of this method is true). By returning false any extension of the context menu can be prevented.

For details see Bugzilla 345347 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=345347).

Returns:
true in case extensions shall be allowed (default), false otherwise.
Since:
0.9

registerAction

protected void registerAction(IAction action)
Registers the given action with the Eclipse ActionRegistry.

Parameters:
action - the action to register
Since:
0.9

initActionRegistry

protected void initActionRegistry(ZoomManager zoomManager)
Initializes the action registry with the predefined actions (update, remove, delete, copy, paste, zooming, direct editing, alignment and toggling actions for the diagram grip and hiding of the context button pad.

Parameters:
zoomManager - the GEF zoom manager to use

getCommonKeyHandler

protected KeyHandler getCommonKeyHandler()
Returns the KeyHandler with common bindings to be used for both the Outline and the Graphical Viewer.

Returns:
The KeyHandler with common bindings for both the Outline and the Graphical Viewer.
Since:
0.9

getDiagramScrollingBehavior

@Deprecated
private DiagramScrollingBehavior getDiagramScrollingBehavior()
Deprecated. Scroll bar based infinite canvas is a workaround for GEF limitations.

Gets the diagram scrolling behavior.

Returns:
the diagram scrolling behavior
See Also:
DefaultToolBehaviorProvider.getDiagramScrollingBehavior()

getFigureCanvas

private FigureCanvas getFigureCanvas()

getGFFigureCanvas

private GFFigureCanvas getGFFigureCanvas()

unregisterDiagramResourceSetListener

protected void unregisterDiagramResourceSetListener()
Hook to unregister the listeners for diagram changes.

See Also:
registerDiagramResourceSetListener()

unregisterBusinessObjectsListener

protected void unregisterBusinessObjectsListener()
Hook that is called to unregister the listeners for changes of the business objects (domain objects).

See Also:
registerBusinessObjectsListener()

registerDiagramResourceSetListener

protected void registerDiagramResourceSetListener()
Hook to register listeners for diagram changes. The listener will be notified with all events and has to filter for the ones regarding the diagram.
Note that additional listeners registered here should also be unregistered in unregisterDiagramResourceSetListener().


registerBusinessObjectsListener

protected void registerBusinessObjectsListener()
Hook that is called to register listeners for changes of the business objects (domain objects) in the resource set of the editor. The default implementation registers the DomainModelChangeListener.
Note that additional listeners registered here should also be unregistered in unregisterBusinessObjectsListener().


getInput

protected IDiagramEditorInput getInput()
Returns the DiagramEditorInput instance used in this behavior.

Returns:
An IDiagramEditorInput instance.

disposeBeforeGefDispose

protected void disposeBeforeGefDispose()
The part of the dispose that should happen before the GEF dispose. Disposes this DiagramBehavior instance and frees all used resources and clears all references. Also delegates to all the behavior extensions to also free their resources (e.g. and most important is the TransactionalEditingDomain held by the DefaultPersistencyBehavior. Always delegate to super.dispose() in case you override this method!


disposeAfterGefDispose

protected void disposeAfterGefDispose()
The part of the dispose that should happen after the GEF dispose. Empties the command stack of the edit domain. Always delegate to super.dispose() in case you override this method!


migrateDiagramModelIfNecessary

protected void migrateDiagramModelIfNecessary()
We provide migration from 0.8.0 to 0.9.0. You can override if you want to migrate manually. WARNING: If your diagram is under version control, this method can cause a check out dialog to be opened etc.

Since:
0.9

getEditDomain

public DefaultEditDomain getEditDomain()
Delegation method to retrieve the GEF edit domain also here. Simply delegates to the container.

Specified by:
getEditDomain in interface IDiagramBehaviorUI
Returns:
The GEF edit domain used used in the container
See Also:
GraphicalEditor#getEditDomain()

setParentPart

protected void setParentPart(IWorkbenchPart parentPart)
Sets the parent IWorkbenchPart for this behavior. Can be used to embed this behavior in various UIs.

Parameters:
parentPart -

getParentPart

protected IWorkbenchPart getParentPart()
Returns the parent IWorkbenchPart this behavior is embedded into. May be null in case the behavior is embedded in a non part UI, like a popup.

Returns:
The parent IWorkbenchPart or null in case it does not exist


Copyright (c) SAP AG 2005, 2012.