Class DiagramBehavior
- All Implemented Interfaces:
IDiagramBehavior
,IDiagramBehaviorUI
Composite
, in a
ViewPart
or in an IEditorPart
, so it's not possible to
provide common functionality through sub-classing.- Since:
- 0.10
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Adds the needed GEF listeners after the edit domain is initializedorg.eclipse.draw2d.geometry.Point
calculateRealMouseLocation
(org.eclipse.draw2d.geometry.Point nativeLocation) Calculates the mouse location depending on scrollbars and zoom factor.protected void
Called to configure the behavior viewer, before it receives its content.protected List<org.eclipse.jface.util.TransferDropTargetListener>
Creates a list of drop target listeners that enable dropping domain objects into the diagram, e.g.protected IConfigurationProvider
createConfigurationProvider
(IDiagramTypeProvider diagramTypeProvider) protected org.eclipse.gef.ContextMenuProvider
Returns a newContextMenuProvider
.protected void
createErrorPartControl
(org.eclipse.swt.widgets.Composite parent) Creates the default error page in case an error occurred while initializing this behavior.protected void
createGraphicalViewer
(org.eclipse.swt.widgets.Composite parent) Creates the GraphicalViewer on the specifiedComposite
and initializes it.protected DefaultMarkerBehavior
Creates the behavior extension that deals with markers.protected DefaultPaletteBehavior
Creates the behavior extension that deals with the palette handling.protected org.eclipse.jface.util.TransferDropTargetListener
Creates the drop target listener that is used for adding new objects from the palette via drag and drop.protected final org.eclipse.gef.ui.palette.PaletteViewerProvider
Delegates to the method (or the method in a subclass of)#createPaletteViewerProvider()
to create thePaletteViewerProvider
used inside the GEF editor.protected DefaultPersistencyBehavior
Creates the behavior extension that deals with the persistence handling.protected DefaultRefreshBehavior
Creates the behavior extension that deals with the refresh handling.protected org.eclipse.jface.resource.ResourceManager
Creates a new instance of aResourceManager
implementation.protected DefaultUpdateBehavior
Creates the behavior extension that deals with the update handling.void
Should be called (e.g.protected void
The part of the dispose that should happen after the GEF dispose.protected void
The part of the dispose that should happen before the GEF dispose.protected void
Hook that is called by the holder of theTransactionalEditingDomain
(DefaultUpdateBehavior
or a subclass of it) after the editing domain has been initialized.void
Should be called by the various behavior instances after mass EMF resource operations have been triggered (e.g.executeFeature
(IFeature feature, IContext context) Executes the givenIFeature
with the givenIContext
in the scope of thisDiagramBehavior
, meaning within itsTransactionalEditingDomain
and on itsCommandStack
.getAdapter
(Class type) Implements the EclipseIAdaptable
interface.protected org.eclipse.gef.KeyHandler
Returns the KeyHandler with common bindings to be used for both the Outline and the Graphical Viewer.Returns theConfigurationProvider
for this behavior.org.eclipse.gef.EditPart
Returns the contentsEditPart
of this behavior.Returns the associated container displaying the diagram of this behavior object.Returns theIDiagramTypeProvider
instance associated with thisDiagramBehavior
.protected String
getDiagramTypeProviderId
(Diagram diagram) Gets the diagram type provider ID for the diagram.org.eclipse.gef.DefaultEditDomain
Delegation method to retrieve the GEF edit domain also here.org.eclipse.emf.transaction.TransactionalEditingDomain
Returns the EMFTransactionalEditingDomain
used within this behavior object by delegating to the update behavior extension, by defaultDefaultUpdateBehavior.getEditingDomain()
.protected String
Returns the error text of the error that occurred while initializing this behavior and its components.org.eclipse.gef.GraphicalEditPart
Method to retrieve the GEFEditPart
for a givenPictogramElement
.org.eclipse.draw2d.IFigure
Method to retrieve the Draw2DIFigure
for a givenPictogramElement
.protected IDiagramEditorInput
getInput()
Returns theDiagramEditorInput
instance used in this behavior.protected DefaultMarkerBehavior
Returns the instance of the marker behavior that is used with this behavior.org.eclipse.draw2d.geometry.Point
Gets the current mouse location as aPoint
.protected DefaultPaletteBehavior
Returns the instance of the palette behavior that is used with this behavior.protected final org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences
Delegates to the method (or the method in a subclass of)DefaultPaletteBehavior.getPalettePreferences()
.protected final org.eclipse.gef.palette.PaletteRoot
Returns thePaletteRoot
to use in the GEF editor by delegating toDefaultPaletteBehavior.getPaletteRoot()
.protected org.eclipse.ui.IWorkbenchPart
Returns the parentIWorkbenchPart
this behavior is embedded into.protected DefaultPersistencyBehavior
Returns the instance of the persistency behavior that is used with this behavior.protected PictogramElement[]
Returns thePictogramElement
s that are set for later selection.Returns the instance of the refresh behavior that is used with this behavior.org.eclipse.jface.resource.ResourceManager
org.eclipse.emf.ecore.resource.ResourceSet
The EMFResourceSet
used within thisDiagramBehavior
.Returns thePictogramElement
s that are currently selected in the diagram.Returns the instance of the update behavior that is used with this behavior.double
Returns the zoom level currently used in the diagram.protected void
initActionRegistry
(org.eclipse.gef.editparts.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
initConfigurationProvider
(IDiagramTypeProvider diagramTypeProvider) Initializes the givenIConfigurationProvider
for thisDiagramBehavior
instance and sets it.protected void
Hook to initialize the default sub behavior instances used by this editor behavior.protected IDiagramTypeProvider
initDiagramTypeProvider
(Diagram diagram) Creates and initializes a newIDiagramTypeProvider
for the givenDiagram
and diagram type provider ID.protected void
Called to initialize the behavior viewer with its content.boolean
isAlive()
Checks if this behavior is alive.boolean
Returns if direct editing is currently active for this behavior.protected boolean
isDirty()
Returns the dirty state of this behavior objectprotected void
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 toDefaultRefreshBehavior.refresh()
.void
Refreshes the content of the editor (what's shown inside the diagram itself).void
Refreshes the palette to correctly reflect all available creation tools for the available create features and the currently enabled selection tools.void
Refreshes the rendering decorators (image decorators and the like) by delegating toDefaultRefreshBehavior.refreshRenderingDecorators(PictogramElement)
for the givenPictogramElement
.protected void
registerAction
(org.eclipse.jface.action.IAction action) Registers the given action with the EclipseActionRegistry
.protected void
Hook that is called to register listeners for changes of the business objects (domain objects) in the resource set of the editor.protected void
Hook to register listeners for diagram changes.void
Triggers the selection for thePictogramElement
s that are stored for later selection.protected void
selectPictogramElements
(PictogramElement[] pictogramElements) Selects the givenPictogramElement
s in the diagram.protected void
setDiagramContainer
(IDiagramContainerUI diagramContainer) Setter for the associatedcontainer
displaying the diagram of this behavior.protected void
setDiagramEditorInput
(IDiagramEditorInput diagramEditorInput) Setter for the field storing the editor input.void
setDirectEditingActive
(boolean directEditingActive) Sets that direct editing is now active in the behavior or not.protected void
setEditorInitializationError
(String editorInitializationError) Sets the error text for an error that occured during the initialization of thisDiagramEditor
.protected void
setInput
(IDiagramEditorInput input) Sets the givenIDiagramEditorInput
object as the input for this behavior instance.protected void
setParentPart
(org.eclipse.ui.IWorkbenchPart parentPart) Sets the parentIWorkbenchPart
for this behavior.void
setPictogramElementForSelection
(PictogramElement pictogramElement) Sets onePictogramElement
for later selection.protected void
setPictogramElementsForSelection
(PictogramElement[] pictogramElements) SetsPictogramElement
s for later selection.protected boolean
Allows subclasses to prevent that the diagram context menu should be registered for extensions at Eclipse.protected void
Hook that is called to unregister the listeners for changes of the business objects (domain objects).protected void
Hook to unregister the listeners for diagram changes.
-
Constructor Details
-
DiagramBehavior
-
-
Method Details
-
setDiagramContainer
Setter for the associatedcontainer
displaying the diagram of this behavior. Note that once the container has been set it must not be changed any more.- Parameters:
diagramContainer
- the diagramContainer to set- Since:
- 0.12
-
getDiagramContainer
Returns the associated container displaying the diagram of this behavior object.- Specified by:
getDiagramContainer
in interfaceIDiagramBehavior
- Returns:
- The associated
IDiagramContainerUI
instance.
-
createMarkerBehavior
Creates the behavior extension that deals with markers. SeeDefaultMarkerBehavior
for details and the default implementation. Override to change the marker behavior.- Returns:
- a new instance of
DefaultMarkerBehavior
-
getMarkerBehavior
Returns the instance of the marker behavior that is used with this behavior. To change the behavior overridecreateMarkerBehavior()
.- Returns:
- the used instance of the marker behavior, by default a
DefaultMarkerBehavior
.
-
createUpdateBehavior
Creates the behavior extension that deals with the update handling. SeeDefaultUpdateBehavior
for details and the default implementation. Override to change the update behavior.- Returns:
- a new instance of
DefaultUpdateBehavior
-
getUpdateBehavior
Returns the instance of the update behavior that is used with this behavior. To change the behavior overridecreateUpdateBehavior()
.- Returns:
- the used instance of the marker behavior, by default a
DefaultUpdateBehavior
.
-
createPaletteBehaviour
Creates the behavior extension that deals with the palette handling. SeeDefaultPaletteBehavior
for details and the default implementation. Override to change the palette behavior.- Returns:
- a new instance of
DefaultPaletteBehavior
-
getPaletteBehavior
Returns the instance of the palette behavior that is used with this behavior. To change the behavior overridecreatePaletteBehaviour()
.- Returns:
- the used instance of the palette behavior, by default a
DefaultPaletteBehavior
.
-
createPersistencyBehavior
Creates the behavior extension that deals with the persistence handling. SeeDefaultPersistencyBehavior
for details and the default implementation. Override to change the persistence behavior.- Returns:
- a new instance of
DefaultPersistencyBehavior
-
getPersistencyBehavior
Returns the instance of the persistency behavior that is used with this behavior. To change the behavior overridecreatePersistencyBehavior()
.- Returns:
- the used instance of the persistency behavior, by default a
DefaultPersistencyBehavior
.
-
createRefreshBehavior
Creates the behavior extension that deals with the refresh handling. SeeDefaultRefreshBehavior
for details and the default implementation. Override to change the refresh behavior.- Returns:
- a new instance of
DefaultRefreshBehavior
-
getRefreshBehavior
Returns the instance of the refresh behavior that is used with this behavior. To change the behavior overridecreateRefreshBehavior()
.- 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. -
setInput
Sets the givenIDiagramEditorInput
object as the input for this behavior instance. The default implementation here cares about loading the diagram from the EMFResource
the input points to, sets the ID of theIDiagramTypeProvider
for the diagram given in the input, registers listeners (by delegating toregisterDiagramResourceSetListener()
andregisterBusinessObjectsListener()
) and does the refreshing of the UI.- Parameters:
input
- theDiagramEditorInput
instance to use within this behavior.
-
initDiagramTypeProvider
Creates and initializes a newIDiagramTypeProvider
for the givenDiagram
and diagram type provider ID.- Parameters:
diagram
- The diagramproviderId
- The diagram type provider ID- Since:
- 0.12
-
getDiagramTypeProviderId
Gets the diagram type provider ID for the diagram. The default implementation checks if the input defines one and will use that that, otherwise it will retrieve the ID of the first diagram type provider that is registered for the type of the passed diagram. In case no ID is found this method will set the editor initialization error and throw anAssertionFailedException
.- Parameters:
diagram
- The diagram to find the ID for.- Since:
- 0.12
-
addGefListeners
protected void addGefListeners()Adds the needed GEF listeners after the edit domain is initialized -
createGraphicalViewer
protected void createGraphicalViewer(org.eclipse.swt.widgets.Composite parent) Creates the GraphicalViewer on the specifiedComposite
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 theIConfigurationProvider
.- See Also:
-
GraphicalEditor.configureGraphicalViewer()
-
initializeGraphicalViewer
protected void initializeGraphicalViewer()Called to initialize the behavior viewer with its content. Here everything is done, which is dependent of theIConfigurationProvider
.- See Also:
-
GraphicalEditorWithFlyoutPalette.initializeGraphicalViewer()
-
createPaletteDropTargetListener
protected org.eclipse.jface.util.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 ornull
to disable dropping from the palette. - Since:
- 0.10
-
createBusinessObjectDropTargetListeners
protected List<org.eclipse.jface.util.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 theTransferDropTargetListener
that shall be registered in the editor. - Since:
- 0.10
-
getEditorInitializationError
Returns the error text of the error that occurred while initializing this behavior and its components. In case this method reports the error text and error UI may be shown instead of the normal diagram viewer.- Returns:
- The error text in case an error has occurred,
null
otherwise
-
setEditorInitializationError
Sets the error text for an error that occured during the initialization of thisDiagramEditor
. Setting anon-null
value indicates an error has occurred, settingnull
indicates everything went fine.- Parameters:
editorInitializationError
- The error message- Since:
- 0.12
-
createErrorPartControl
protected void createErrorPartControl(org.eclipse.swt.widgets.Composite parent) Creates the default error page in case an error occurred while initializing this behavior.- Parameters:
parent
- The parentComposite
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 org.eclipse.gef.ui.palette.PaletteViewerProvider createPaletteViewerProvider()Delegates to the method (or the method in a subclass of)#createPaletteViewerProvider()
to create thePaletteViewerProvider
used inside the GEF editor.- Returns:
- the
PaletteViewerProvider
to use
-
getPalettePreferences
protected final org.eclipse.gef.ui.palette.FlyoutPaletteComposite.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 org.eclipse.gef.palette.PaletteRoot getPaletteRoot()Returns thePaletteRoot
to use in the GEF editor by delegating toDefaultPaletteBehavior.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 toDefaultRefreshBehavior.refresh()
.- Specified by:
refresh
in interfaceIDiagramBehavior
-
refreshRenderingDecorators
Refreshes the rendering decorators (image decorators and the like) by delegating toDefaultRefreshBehavior.refreshRenderingDecorators(PictogramElement)
for the givenPictogramElement
.- Specified by:
refreshRenderingDecorators
in interfaceIDiagramBehavior
- Parameters:
pe
- thePictogramElement
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 interfaceIDiagramBehavior
-
refreshContent
public void refreshContent()Refreshes the content of the editor (what's shown inside the diagram itself).- Specified by:
refreshContent
in interfaceIDiagramBehavior
-
selectPictogramElements
Selects the givenPictogramElement
s in the diagram.- Parameters:
pictogramElements
- an array ofPictogramElement
s to select.
-
getSelectedPictogramElements
Returns thePictogramElement
s that are currently selected in the diagram.- Returns:
- an array of
PictogramElement
s.
-
setPictogramElementForSelection
Sets onePictogramElement
for later selection.The methods
getPictogramElementsForSelection()
,setPictogramElementForSelection(PictogramElement)
,setPictogramElementsForSelection(PictogramElement[])
andselectBufferedPictogramElements()
offer the possibility to use a deferred selection mechanism: via the setters,PictogramElement
s can be stored for a selection operation that is triggered lateron during a general refresh via the methodselectBufferedPictogramElements()
. 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
- thePictogramElement
that shall be stored for later selection
-
setPictogramElementsForSelection
SetsPictogramElement
s for later selection.The methods
getPictogramElementsForSelection()
,setPictogramElementForSelection(PictogramElement)
,setPictogramElementsForSelection(PictogramElement[])
andselectBufferedPictogramElements()
offer the possibility to use a deferred selection mechanism: via the setters,PictogramElement
s can be stored for a selection operation that is triggered later on during a general refresh via the methodselectBufferedPictogramElements()
. 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
- thePictogramElement
s that shall be stored for later selection
-
selectBufferedPictogramElements
public void selectBufferedPictogramElements()Triggers the selection for thePictogramElement
s 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[])
andselectBufferedPictogramElements()
offer the possibility to use a deferred selection mechanism: via the setters,PictogramElement
s can be stored for a selection operation that is triggered later on during a general refresh via the methodselectBufferedPictogramElements()
. 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
Returns thePictogramElement
s that are set for later selection.The methods
getPictogramElementsForSelection()
,setPictogramElementForSelection(PictogramElement)
,setPictogramElementsForSelection(PictogramElement[])
andselectBufferedPictogramElements()
offer the possibility to use a deferred selection mechanism: via the setters,PictogramElement
s can be stored for a selection operation that is triggered lateron during a general refresh via the methodselectBufferedPictogramElements()
. 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
PictogramElement
s stored for later selection
-
getEditingDomain
public org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain()Returns the EMFTransactionalEditingDomain
used within this behavior object by delegating to the update behavior extension, by defaultDefaultUpdateBehavior.getEditingDomain()
.- Specified by:
getEditingDomain
in interfaceIDiagramBehavior
- Returns:
- the
TransactionalEditingDomain
instance used in the behavior
-
getResourceSet
public org.eclipse.emf.ecore.resource.ResourceSet getResourceSet()The EMFResourceSet
used within thisDiagramBehavior
. The resource set is always associated in a 1:1 relation to theTransactionalEditingDomain
.- Returns:
- the resource set used within this behavior object
-
getDiagramTypeProvider
Returns theIDiagramTypeProvider
instance associated with thisDiagramBehavior
. There is always a 1:1 relation between the behavior and the provider.- Returns:
- the associated
IDiagramTypeProvider
instance.
-
executeFeature
Executes the givenIFeature
with the givenIContext
in the scope of thisDiagramBehavior
, meaning within itsTransactionalEditingDomain
and on itsCommandStack
.- Specified by:
executeFeature
in interfaceIDiagramBehavior
- Parameters:
feature
- the feature to executecontext
- the context to use. In case the passed feature is aIAddFeature
this context needs to be an instance ofIAddContext
, otherwise anAssertionFailedException
will be thrown.- Returns:
- in case of an
IAddFeature
being passed as feature the newly addedPictogramElement
will be returned (in case the add method returning it), in all other casesnull
- Since:
- 0.9
-
disableAdapters
public 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. SeeenableAdapters()
as well.
Important note: make sure that you re-enable eventing usingenableAdapters()
after the operation has finished (best in a finally clause to do that also in case of exceptions), otherwise strange errors may happen.- Since:
- 0.12
-
enableAdapters
public 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. SeedisableAdapters()
as well.
Must be called afterdisableAdapters()
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.- Since:
- 0.12
-
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 theTransactionalEditingDomain
(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
Implements the EclipseIAdaptable
interface. This implementation first delegates to theIToolBehaviorProvider.getAdapter(Class)
method and checks if something is returned. In case the return value isnull
it returns adapters for ZoomManager, IPropertySheetPage, Diagram, KeyHandler, SelectionSynchronizer and IContextButtonManager. It also delegates to the super implementation inGraphicalEditorWithFlyoutPalette.getAdapter(Class)
.- Parameters:
type
- the type to which shall be adapted- Returns:
- the adapter instance
-
getConfigurationProvider
Returns theConfigurationProvider
for this behavior. It is mainly a wrapper around various objects that are connected to the diagram behavior.- Returns:
- an
IConfigurationProvider
instance. - Since:
- 0.12
-
getContentEditPart
public org.eclipse.gef.EditPart getContentEditPart()Returns the contentsEditPart
of this behavior. This is the topmost EditPart in theGraphicalViewer
.- Returns:
- The contents
EditPart
of this behavior.
-
getEditPartForPictogramElement
Method to retrieve the GEFEditPart
for a givenPictogramElement
.- Specified by:
getEditPartForPictogramElement
in interfaceIDiagramBehaviorUI
- Parameters:
pe
- thePictogramElement
to retrieve the GEF representation for- Returns:
- the GEF
GraphicalEditPart
that represents the givenPictogramElement
.
-
getMouseLocation
public org.eclipse.draw2d.geometry.Point getMouseLocation()Gets the current mouse location as aPoint
.- Returns:
- the mouse location
-
calculateRealMouseLocation
public org.eclipse.draw2d.geometry.Point calculateRealMouseLocation(org.eclipse.draw2d.geometry.Point nativeLocation) Calculates the mouse location depending on scrollbars and zoom factor.- Specified by:
calculateRealMouseLocation
in interfaceIDiagramBehaviorUI
- Parameters:
nativeLocation
- the native location given asPoint
- 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 totrue
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
Method to retrieve the Draw2DIFigure
for a givenPictogramElement
.- Specified by:
getFigureForPictogramElement
in interfaceIDiagramBehaviorUI
- Parameters:
pe
- thePictogramElement
to retrieve the Draw2D representation for- Returns:
- the Draw2D
IFigure
that represents the givenPictogramElement
.
-
initConfigurationProvider
Initializes the givenIConfigurationProvider
for thisDiagramBehavior
instance and sets it.- Parameters:
configurationProvider
- The configuration provider- Since:
- 0.12
-
createConfigurationProvider
protected IConfigurationProvider createConfigurationProvider(IDiagramTypeProvider diagramTypeProvider) Creates a newConfigurationProvider
for thisDiagramBehavior
and the givenIDiagramTypeProvider
. The default implementation will create a defaultConfigurationProvider
which should suite for all Graphiti clients.- Since:
- 0.12
-
createContextMenuProvider
protected org.eclipse.gef.ContextMenuProvider createContextMenuProvider()Returns a newContextMenuProvider
. 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 istrue
). By returningfalse
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(org.eclipse.jface.action.IAction action) Registers the given action with the EclipseActionRegistry
.- Parameters:
action
- the action to register- Since:
- 0.9
-
initActionRegistry
protected void initActionRegistry(org.eclipse.gef.editparts.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 org.eclipse.gef.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
-
unregisterDiagramResourceSetListener
protected void unregisterDiagramResourceSetListener()Hook to unregister the listeners for diagram changes.- See Also:
-
unregisterBusinessObjectsListener
protected void unregisterBusinessObjectsListener()Hook that is called to unregister the listeners for changes of the business objects (domain objects).- See Also:
-
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 inunregisterDiagramResourceSetListener()
. -
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 theDomainModelChangeListener
.
Note that additional listeners registered here should also be unregistered inunregisterBusinessObjectsListener()
. -
getInput
Returns theDiagramEditorInput
instance used in this behavior.- Returns:
- An
IDiagramEditorInput
instance.
-
setDiagramEditorInput
Setter for the field storing the editor input.- Parameters:
diagramEditorInput
- The new input- Since:
- 0.12
-
disposeBeforeGefDispose
protected void disposeBeforeGefDispose()The part of the dispose that should happen before the GEF dispose. Disposes thisDiagramBehavior
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 theTransactionalEditingDomain
held by theDefaultPersistencyBehavior
. Always delegate tosuper.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 tosuper.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 org.eclipse.gef.DefaultEditDomain getEditDomain()Delegation method to retrieve the GEF edit domain also here. Simply delegates to the container.- Specified by:
getEditDomain
in interfaceIDiagramBehaviorUI
- Returns:
- The GEF edit domain used used in the container
- See Also:
-
GraphicalEditor.getEditDomain()
-
setParentPart
protected void setParentPart(org.eclipse.ui.IWorkbenchPart parentPart) Sets the parentIWorkbenchPart
for this behavior. Can be used to embed this behavior in various UIs.- Parameters:
parentPart
-
-
getParentPart
protected org.eclipse.ui.IWorkbenchPart getParentPart()Returns the parentIWorkbenchPart
this behavior is embedded into. May benull
in case the behavior is embedded in a non part UI, like a popup.- Returns:
- The parent
IWorkbenchPart
ornull
in case it does not exist
-
createResourceManager
protected org.eclipse.jface.resource.ResourceManager createResourceManager()Creates a new instance of aResourceManager
implementation.By default this creates a
LocalResourceManager
instance. Subclasses may override this method to enforce the usage of another implementation.- Returns:
- A new instance of a
ResourceManager
. - Since:
- 0.14
-
getResourceManager
public org.eclipse.jface.resource.ResourceManager getResourceManager()- Returns:
- the JFace
ResourceManager
to be used to create images, fonts etc for an open diagram. - Since:
- 0.14
-