Package org.eclipse.graphiti.ui.editor
Class DiagramComposite
- java.lang.Object
-
- org.eclipse.swt.widgets.Widget
-
- org.eclipse.swt.widgets.Control
-
- org.eclipse.swt.widgets.Scrollable
-
- org.eclipse.swt.widgets.Composite
-
- org.eclipse.graphiti.ui.editor.GraphicalComposite
-
- org.eclipse.graphiti.ui.editor.DiagramComposite
-
- All Implemented Interfaces:
java.util.EventListener
,org.eclipse.core.runtime.IAdaptable
,org.eclipse.gef.commands.CommandStackEventListener
,org.eclipse.gef.commands.CommandStackListener
,IDiagramContainer
,IDiagramContainerUI
,org.eclipse.swt.graphics.Drawable
,org.eclipse.ui.ISelectionListener
public class DiagramComposite extends GraphicalComposite implements IDiagramContainerUI
An SWT composite that can display a Graphiti diagram. This implementation is based on a customGraphicalComposite
class that works much like the GEF GraphicalEditorWithFlyoutPalette class. A DiagramComposite can be used anywhere a regular SWT Composite can. A DiagramComposite can participate in a parent transaction or create one of it's own. If the DiagramComposites is managing it's own transaction, it is up to the enclosing workbench part to call the appropriate methods on the composite.- Since:
- 0.10
-
-
Field Summary
-
Fields inherited from interface org.eclipse.graphiti.ui.editor.IDiagramContainerUI
DIAGRAM_CONTEXT_ID
-
-
Constructor Summary
Constructors Constructor Description DiagramComposite(org.eclipse.swt.widgets.Composite parent, int style)
DiagramComposite(org.eclipse.ui.IWorkbenchPart ownedPart, org.eclipse.swt.widgets.Composite parent, int style)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Notify the container that it should shut down or clear it's state.void
configureGraphicalViewer()
Called to configure the graphical viewer before it receives its contents.protected DiagramBehavior
createDiagramBehavior()
protected void
createGraphicalViewer()
Creates the GraphicalViewer on the specifiedComposite
.protected org.eclipse.gef.ui.palette.PaletteViewerProvider
createPaletteViewerProvider()
void
disableAdapters()
void
dispose()
void
doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
Triggers that the diagram model is persisted.void
editingDomainInitialized()
void
enableAdapters()
java.lang.Object
getAdapter(java.lang.Class type)
Returns the adapter for the specified key.DiagramBehavior
getDiagramBehavior()
Returns theDiagramBehavior
instance associated with this container.IDiagramEditorInput
getDiagramEditorInput()
Returns theIDiagramEditorInput
instance used for this container.IDiagramTypeProvider
getDiagramTypeProvider()
Gets the diagram type provider.org.eclipse.gef.GraphicalEditPart
getEditPartForPictogramElement(PictogramElement pe)
protected org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences
getPalettePreferences()
protected org.eclipse.gef.palette.PaletteRoot
getPaletteRoot()
DefaultRefreshBehavior
getRefreshBehavior()
PictogramElement[]
getSelectedPictogramElements()
Gets all pictogram elements that are currently selected.org.eclipse.ui.IWorkbenchPartSite
getSite()
Returns theIWorkbenchPartSite
of the EclipseIWorkbenchPart
that displays this container.java.lang.String
getTitle()
Gets the title for the container that is displaying the diagram.java.lang.String
getTitleToolTip()
Returns the tooltip for the container.DefaultUpdateBehavior
getUpdateBehavior()
org.eclipse.ui.IWorkbenchPart
getWorkbenchPart()
Returns the instance of the EclipseIWorkbenchPart
that displays this container.double
getZoomLevel()
void
initializeGraphicalViewer()
Override to set the contents of the GraphicalViewer after it has been created.boolean
isAlive()
boolean
isDirectEditingActive()
boolean
isDirty()
Returnstrue
if the command stack is dirtyvoid
refreshTitle()
Refreshes the title text of this container.void
refreshTitleToolTip()
Refreshes the title tool tip text of this part.void
selectPictogramElements(PictogramElement[] pictogramElements)
Selects all the given pictogram elements in the container.void
setDirectEditingActive(boolean directEditingActive)
boolean
setFocus()
Sets the focus by delegating to the super class implementation in the GEF editor and additionally triggers a update of the diagram by delegating toDefaultUpdateBehavior.handleActivate()
.void
setInput(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, IDiagramEditorInput input)
void
setInput(IDiagramEditorInput input)
void
setPictogramElementForSelection(PictogramElement pictogramElement)
Sets the pictogram element which should be selected after the container refresh.void
setPictogramElementsForSelection(PictogramElement[] pictogramElements)
Sets the pictogram elements which should be selected after the container refresh.void
updateDirtyState()
Updates the UI of the container to correctly reflect the dirty state.-
Methods inherited from class org.eclipse.graphiti.ui.editor.GraphicalComposite
commandStackChanged, createActions, createControl, firePropertyChange, getActionRegistry, getCommandStack, getEditDomain, getGraphicalViewer, getPropertyActions, getSelectionActions, getSelectionSynchronizer, getStackActions, hookGraphicalViewer, init, initializeActionRegistry, selectionChanged, setActionRegistry, setEditDomain, setGraphicalViewer, stackChanged, updateActions
-
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayout, setLayoutDeferred, setTabList
-
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
-
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isAutoScalable, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
-
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.graphiti.ui.editor.IDiagramContainerUI
commandStackChanged, getActionRegistry, getEditDomain, getGraphicalViewer, getSelectionActions, hookGraphicalViewer, setEditDomain, setGraphicalViewer
-
-
-
-
Method Detail
-
createDiagramBehavior
protected DiagramBehavior createDiagramBehavior()
-
setInput
public void setInput(IDiagramEditorInput input)
-
setInput
public void setInput(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, IDiagramEditorInput input)
-
initializeGraphicalViewer
public void initializeGraphicalViewer()
Description copied from class:GraphicalComposite
Override to set the contents of the GraphicalViewer after it has been created.- Specified by:
initializeGraphicalViewer
in interfaceIDiagramContainerUI
- Overrides:
initializeGraphicalViewer
in classGraphicalComposite
- See Also:
#createGraphicalViewer(Composite)
-
createGraphicalViewer
protected void createGraphicalViewer()
Description copied from class:GraphicalComposite
Creates the GraphicalViewer on the specifiedComposite
.- Overrides:
createGraphicalViewer
in classGraphicalComposite
-
configureGraphicalViewer
public void configureGraphicalViewer()
Description copied from class:GraphicalComposite
Called to configure the graphical viewer before it receives its contents. This is where the root editpart should be configured. Subclasses should extend or override this method as needed.- Specified by:
configureGraphicalViewer
in interfaceIDiagramContainerUI
- Overrides:
configureGraphicalViewer
in classGraphicalComposite
- Since:
- 0.12
-
refreshTitle
public void refreshTitle()
Description copied from interface:IDiagramContainer
Refreshes the title text of this container. It depends on the container type what and if anything is refreshed, for an editor e.g. the part tab will be refreshed.- Specified by:
refreshTitle
in interfaceIDiagramContainer
-
refreshTitleToolTip
public void refreshTitleToolTip()
Description copied from interface:IDiagramContainer
Refreshes the title tool tip text of this part. It depends on the container type what and if anything is refreshed, for an editor e.g. the part tab tooltip will be refreshed.- Specified by:
refreshTitleToolTip
in interfaceIDiagramContainer
-
updateDirtyState
public void updateDirtyState()
Description copied from interface:IDiagramContainer
Updates the UI of the container to correctly reflect the dirty state. What (and if anything) happens depends on the container type. The default implementation in the editor e.g. does this by firing aIEditorPart#PROP_DIRTY
property change.- Specified by:
updateDirtyState
in interfaceIDiagramContainer
-
getWorkbenchPart
public org.eclipse.ui.IWorkbenchPart getWorkbenchPart()
Description copied from interface:IDiagramContainerUI
Returns the instance of the EclipseIWorkbenchPart
that displays this container. E.g. for an editor this will be the editor itself.- Specified by:
getWorkbenchPart
in interfaceIDiagramContainerUI
- Specified by:
getWorkbenchPart
in classGraphicalComposite
- Returns:
- The
IWorkbenchPart
that is displaying the diagram.
-
close
public void close()
Description copied from interface:IDiagramContainer
Notify the container that it should shut down or clear it's state.- Specified by:
close
in interfaceIDiagramContainer
-
getAdapter
public java.lang.Object getAdapter(java.lang.Class type)
Description copied from class:GraphicalComposite
Returns the adapter for the specified key.IMPORTANT certain requests, such as the property sheet, may be made before or after
#createPartControl(Composite)
is called. The order is unspecified by the Workbench.- Specified by:
getAdapter
in interfaceorg.eclipse.core.runtime.IAdaptable
- Overrides:
getAdapter
in classGraphicalComposite
- See Also:
IAdaptable.getAdapter(java.lang.Class)
-
dispose
public void dispose()
- Overrides:
dispose
in classGraphicalComposite
- See Also:
IWorkbenchPart.dispose()
-
setFocus
public boolean setFocus()
Sets the focus by delegating to the super class implementation in the GEF editor and additionally triggers a update of the diagram by delegating toDefaultUpdateBehavior.handleActivate()
.- Overrides:
setFocus
in classGraphicalComposite
-
getUpdateBehavior
public final DefaultUpdateBehavior getUpdateBehavior()
-
getRefreshBehavior
public final DefaultRefreshBehavior getRefreshBehavior()
-
editingDomainInitialized
public void editingDomainInitialized()
-
disableAdapters
public void disableAdapters()
-
enableAdapters
public void enableAdapters()
-
isDirty
public boolean isDirty()
Description copied from class:GraphicalComposite
Returnstrue
if the command stack is dirty- Specified by:
isDirty
in interfaceIDiagramContainer
- Overrides:
isDirty
in classGraphicalComposite
- Returns:
true
, if container is dirty,false
otherwise- See Also:
ISaveablePart.isDirty()
-
createPaletteViewerProvider
protected final org.eclipse.gef.ui.palette.PaletteViewerProvider createPaletteViewerProvider()
-
getPalettePreferences
protected final org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences getPalettePreferences()
-
getPaletteRoot
protected final org.eclipse.gef.palette.PaletteRoot getPaletteRoot()
-
getSelectedPictogramElements
public PictogramElement[] getSelectedPictogramElements()
Description copied from interface:IDiagramContainer
Gets all pictogram elements that are currently selected.- Specified by:
getSelectedPictogramElements
in interfaceIDiagramContainer
- Returns:
- all selected pictogram elements
-
selectPictogramElements
public void selectPictogramElements(PictogramElement[] pictogramElements)
Description copied from interface:IDiagramContainer
Selects all the given pictogram elements in the container.- Specified by:
selectPictogramElements
in interfaceIDiagramContainer
- Parameters:
pictogramElements
- The pictogram elements to select
-
setPictogramElementForSelection
public void setPictogramElementForSelection(PictogramElement pictogramElement)
Description copied from interface:IDiagramContainer
Sets the pictogram element which should be selected after the container refresh.- Specified by:
setPictogramElementForSelection
in interfaceIDiagramContainer
- Parameters:
pictogramElement
- The pictogram element to select
-
setPictogramElementsForSelection
public void setPictogramElementsForSelection(PictogramElement[] pictogramElements)
Description copied from interface:IDiagramContainer
Sets the pictogram elements which should be selected after the container refresh.- Specified by:
setPictogramElementsForSelection
in interfaceIDiagramContainer
- Parameters:
pictogramElements
- The pictogram elements to select
-
getDiagramTypeProvider
public IDiagramTypeProvider getDiagramTypeProvider()
Description copied from interface:IDiagramContainer
Gets the diagram type provider.- Specified by:
getDiagramTypeProvider
in interfaceIDiagramContainer
- Returns:
- The diagram type provider
-
getEditPartForPictogramElement
public org.eclipse.gef.GraphicalEditPart getEditPartForPictogramElement(PictogramElement pe)
-
getZoomLevel
public double getZoomLevel()
-
isAlive
public boolean isAlive()
-
isDirectEditingActive
public boolean isDirectEditingActive()
-
setDirectEditingActive
public void setDirectEditingActive(boolean directEditingActive)
-
getDiagramEditorInput
public IDiagramEditorInput getDiagramEditorInput()
Description copied from interface:IDiagramContainerUI
Returns theIDiagramEditorInput
instance used for this container. Basically it is used as an EclipseIEditorInput
object only in case the container is an editor; for other types of containers the input is simply used as a holder for a URI pointing to a diagram.- Specified by:
getDiagramEditorInput
in interfaceIDiagramContainerUI
- Returns:
- The input containing the URI for the diagram
-
getSite
public org.eclipse.ui.IWorkbenchPartSite getSite()
Description copied from interface:IDiagramContainerUI
Returns theIWorkbenchPartSite
of the EclipseIWorkbenchPart
that displays this container. E.g. for an editor this will be the editor site.- Specified by:
getSite
in interfaceIDiagramContainerUI
- Returns:
- The site for the
IWorkbenchPart
that is displaying the diagram.
-
getTitle
public java.lang.String getTitle()
Description copied from interface:IDiagramContainer
Gets the title for the container that is displaying the diagram.- Specified by:
getTitle
in interfaceIDiagramContainer
- Returns:
- The title as a
String
-
getTitleToolTip
public java.lang.String getTitleToolTip()
Description copied from interface:IDiagramContainer
Returns the tooltip for the container. For an editor that would e.g. be the string that is displayed when hovering over the editor title tab.- Specified by:
getTitleToolTip
in interfaceIDiagramContainer
- Returns:
- The tooltip as a
String
-
doSave
public void doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
Description copied from interface:IDiagramContainer
Triggers that the diagram model is persisted.- Specified by:
doSave
in interfaceIDiagramContainer
-
getDiagramBehavior
public DiagramBehavior getDiagramBehavior()
Description copied from interface:IDiagramContainerUI
Returns theDiagramBehavior
instance associated with this container.- Specified by:
getDiagramBehavior
in interfaceIDiagramContainer
- Specified by:
getDiagramBehavior
in interfaceIDiagramContainerUI
- Returns:
- The associated
DiagramBehavior
instance
-
-