public class DiagramBehavior extends java.lang.Object implements IDiagramBehaviorUI
Composite, in a
ViewPart or in an IEditorPart, so it's not possible to
provide common functionality through sub-classing.| Constructor and Description |
|---|
DiagramBehavior(IDiagramContainerUI diagramContainer) |
| Modifier and Type | Method and Description |
|---|---|
org.eclipse.draw2d.geometry.Point |
calculateRealMouseLocation(org.eclipse.draw2d.geometry.Point nativeLocation)
Calculates the mouse location depending on scrollbars and zoom factor.
|
void |
disableAdapters()
Should be called (e.g.
|
void |
enableAdapters()
Should be called by the various behavior instances after mass EMF
resource operations have been triggered (e.g.
|
java.lang.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. |
java.lang.Object |
getAdapter(java.lang.Class type)
Implements the Eclipse
IAdaptable interface. |
IConfigurationProvider |
getConfigurationProvider()
Returns the
ConfigurationProvider for this behavior. |
org.eclipse.gef.EditPart |
getContentEditPart()
Returns the contents
EditPart of this behavior. |
IDiagramContainerUI |
getDiagramContainer()
Returns the associated container displaying the diagram of this behavior
object.
|
IDiagramTypeProvider |
getDiagramTypeProvider()
Returns the
IDiagramTypeProvider instance associated with this
DiagramBehavior. |
org.eclipse.gef.DefaultEditDomain |
getEditDomain()
Delegation method to retrieve the GEF edit domain also here.
|
org.eclipse.emf.transaction.TransactionalEditingDomain |
getEditingDomain()
Returns the EMF
TransactionalEditingDomain used within this
behavior object by delegating to the update behavior extension, by
default DefaultUpdateBehavior.getEditingDomain(). |
org.eclipse.gef.GraphicalEditPart |
getEditPartForPictogramElement(PictogramElement pe)
Method to retrieve the GEF
EditPart for a given
PictogramElement. |
org.eclipse.draw2d.IFigure |
getFigureForPictogramElement(PictogramElement pe)
Method to retrieve the Draw2D
IFigure for a given
PictogramElement. |
org.eclipse.draw2d.geometry.Point |
getMouseLocation()
Gets the current mouse location as a
Point. |
DefaultRefreshBehavior |
getRefreshBehavior()
Returns the instance of the refresh behavior that is used with this
behavior.
|
ResourceManager |
getResourceManager() |
org.eclipse.emf.ecore.resource.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.
|
boolean |
isAlive()
Checks if this behavior is alive.
|
boolean |
isDirectEditingActive()
Returns if direct editing is currently active for this behavior.
|
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. |
void |
selectBufferedPictogramElements()
Triggers the selection for the
PictogramElements that are stored
for later selection. |
void |
setDirectEditingActive(boolean directEditingActive)
Sets that direct editing is now active in the behavior or not.
|
void |
setPictogramElementForSelection(PictogramElement pictogramElement)
Sets one
PictogramElement for later selection. |
public DiagramBehavior(IDiagramContainerUI diagramContainer)
public IDiagramContainerUI getDiagramContainer()
getDiagramContainer in interface IDiagramBehaviorIDiagramContainerUI instance.public DefaultUpdateBehavior getUpdateBehavior()
createUpdateBehavior()
.DefaultUpdateBehavior.public DefaultRefreshBehavior getRefreshBehavior()
createRefreshBehavior() .DefaultRefreshBehavior.public void refresh()
DefaultRefreshBehavior.refresh().refresh in interface IDiagramBehaviorpublic void refreshRenderingDecorators(PictogramElement pe)
DefaultRefreshBehavior.refreshRenderingDecorators(PictogramElement)
for the given PictogramElement.refreshRenderingDecorators in interface IDiagramBehaviorpe - the PictogramElement for which the decorators shall be
refreshed.public void refreshPalette()
refreshPalette in interface IDiagramBehaviorpublic void refreshContent()
refreshContent in interface IDiagramBehaviorpublic PictogramElement[] getSelectedPictogramElements()
PictogramElements that are currently selected in the
diagram.PictogramElements.public void setPictogramElementForSelection(PictogramElement pictogramElement)
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.
pictogramElement - the PictogramElement that shall be stored for later
selectionpublic void selectBufferedPictogramElements()
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.
public org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain()
TransactionalEditingDomain used within this
behavior object by delegating to the update behavior extension, by
default DefaultUpdateBehavior.getEditingDomain().getEditingDomain in interface IDiagramBehaviorTransactionalEditingDomain instance used in the
behaviorpublic org.eclipse.emf.ecore.resource.ResourceSet getResourceSet()
ResourceSet used within this DiagramBehavior. The
resource set is always associated in a 1:1 relation to the
TransactionalEditingDomain.public IDiagramTypeProvider getDiagramTypeProvider()
IDiagramTypeProvider instance associated with this
DiagramBehavior. There is always a 1:1 relation between the
behavior and the provider.IDiagramTypeProvider instance.public java.lang.Object executeFeature(IFeature feature, IContext context)
IFeature with the given IContext in
the scope of this DiagramBehavior, meaning within its
TransactionalEditingDomain and on its
CommandStack.executeFeature in interface IDiagramBehaviorfeature - the feature to executecontext - 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.IAddFeature being passed as feature the
newly added PictogramElement will be returned (in case
the add method returning it), in all other cases
nullpublic void disableAdapters()
enableAdapters() as well.enableAdapters() after the operation has finished (best in a
finally clause to do that also in case of exceptions), otherwise strange
errors may happen.public void enableAdapters()
disableAdapters() as well.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.public boolean isAlive()
true, if editor contains a model connector and a
valid Diagram, false otherwise.public java.lang.Object getAdapter(java.lang.Class type)
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).type - the type to which shall be adaptedpublic IConfigurationProvider getConfigurationProvider()
ConfigurationProvider for this behavior. It is mainly
a wrapper around various objects that are connected to the diagram
behavior.IConfigurationProvider instance.public org.eclipse.gef.EditPart getContentEditPart()
EditPart of this behavior. This is the
topmost EditPart in the GraphicalViewer.EditPart of this behavior.public org.eclipse.gef.GraphicalEditPart getEditPartForPictogramElement(PictogramElement pe)
EditPart for a given
PictogramElement.getEditPartForPictogramElement in interface IDiagramBehaviorUIpe - the PictogramElement to retrieve the GEF
representation forGraphicalEditPart that represents the given
PictogramElement.public org.eclipse.draw2d.geometry.Point getMouseLocation()
Point.public org.eclipse.draw2d.geometry.Point calculateRealMouseLocation(org.eclipse.draw2d.geometry.Point nativeLocation)
calculateRealMouseLocation in interface IDiagramBehaviorUInativeLocation - the native location given as PointPoint of the real mouse locationpublic boolean isDirectEditingActive()
true in case direct editing is currently active
within this editor, false otherwise.public void setDirectEditingActive(boolean directEditingActive)
true does not actually start direct editing
it is simply an indication that prevents certain operations from running
(e.g. refresh)directEditingActive - true to set the flag to direct editing currently
active, false otherwise.public double getZoomLevel()
public org.eclipse.draw2d.IFigure getFigureForPictogramElement(PictogramElement pe)
IFigure for a given
PictogramElement.getFigureForPictogramElement in interface IDiagramBehaviorUIpe - the PictogramElement to retrieve the Draw2D
representation forIFigure that represents the given
PictogramElement.public org.eclipse.gef.DefaultEditDomain getEditDomain()
getEditDomain in interface IDiagramBehaviorUIGraphicalEditor.getEditDomain()public ResourceManager getResourceManager()
ResourceManager to be used to create images,
fonts etc for an open diagram.