public class DiagramEditor extends org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette implements IDiagramContainerUI, ITabbedPropertySheetPageContributor, org.eclipse.emf.edit.domain.IEditingDomainProvider, org.eclipse.gef.commands.CommandStackEventListener
IEditorPart. The
implementation is based upon a GEF editor implementation (
GraphicalEditorWithFlyoutPalette) and enhances it with
Graphiti-specific stuff.IEditorInput object is a
subclass of DiagramEditorInput, but using another type of input is
also ok as long as it can be adapted to an IFile that can be reolved within
the workspace of is a URIEditorInput. These types of input objects
will be converted to a corresponding DiagramEditorInput when the
editor is initialized (see init(IEditorSite, IEditorInput)).DiagramEditor instance. This means they are instantiated when a
new diagram editor is created and exist until the editor is closed again.
There are default implementations for all of these aspects, see the
Default*Behavior classes in this package. The following aspects are
separated:
DefaultMarkerBehavior for the default implementation. Override
#createMarkerBehavior() to change the default behavior.DefaultPaletteBehavior for the default implementation. Override
#createPaletteBehaviour() to change the default behavior.DefaultPersistencyBehavior for the default
implementation. Override #createPersistencyBehavior() to change the
default behavior.DefaultRefreshBehavior for the default implementation. Override
#createRefreshBehavior() to change the default behavior.DefaultMarkerBehavior for the default implementation. Override
#createMarkerBehavior() to change the default behavior.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DIAGRAM_EDITOR_ID
The ID of the
DiagramEditor as it is registered with the
org.eclipse.ui.editors extension point. |
DIAGRAM_CONTEXT_IDPROP_DIRTY, PROP_INPUTPROP_TITLE| Constructor and Description |
|---|
DiagramEditor()
Creates a new diagram editor and cares about the creation of the
different behavior extensions by delegating to the various
create*Behavior() methods.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Notify the container that it should shut down or clear it's state.
|
void |
commandStackChanged(java.util.EventObject event)
Notification that the command stack changed.
|
void |
configureGraphicalViewer()
Called to configure the editor, before it receives its content.
|
void |
createPartControl(Composite parent)
Creates the UI of the editor by delegating to the
super.createPartControl method. |
void |
dispose()
Disposes this
DiagramEditor instance and frees all used resources
and clears all references. |
void |
doSave(IProgressMonitor monitor)
Called to perform the saving of the editor.
|
org.eclipse.gef.ui.actions.ActionRegistry |
getActionRegistry()
Returns the GEF action registry for the container.
|
java.lang.Object |
getAdapter(java.lang.Class type)
Implements the Eclipse
IAdaptable interface. |
java.lang.String |
getContributorId()
Returns the ID for contributions in the tabbed property sheets by
delegating to the method
IToolBehaviorProvider.getContributorId()
. |
DiagramBehavior |
getDiagramBehavior()
Returns the associated
DiagramSupport instance to this editor. |
IDiagramEditorInput |
getDiagramEditorInput()
Returns the
IDiagramEditorInput instance used for this container. |
IDiagramTypeProvider |
getDiagramTypeProvider()
Returns the
IDiagramTypeProvider instance associated with this
DiagramEditor. |
org.eclipse.gef.DefaultEditDomain |
getEditDomain()
Returns the GEF edit domain as needed for some of the feature
functionality in Graphiti; simply a public rewrite of the GEF editor
super method.
|
org.eclipse.emf.transaction.TransactionalEditingDomain |
getEditingDomain()
Returns the EMF
TransactionalEditingDomain used within this
editor by delegating to the update behavior extension, by default
DefaultUpdateBehavior.getEditingDomain(). |
org.eclipse.gef.GraphicalViewer |
getGraphicalViewer()
Returns the GEF
GraphicalViewer as it is needed in some Graphiti
feature implementations. |
PictogramElement[] |
getSelectedPictogramElements()
Returns the
PictogramElements that are currently selected in the
diagram editor. |
java.util.List |
getSelectionActions()
Returns the actions used for selection of the parent GEF editor, for an
editor based upon the GEF editor this simply returns the standard GEF
selection actions by delegating to the super editor class.
|
java.lang.String |
getTitleToolTip()
Returns the tooltip that shall be displayed when hovering over the editor
title tab.
|
IWorkbenchPart |
getWorkbenchPart()
Returns the
IWorkbenchPart for this container. |
void |
hookGraphicalViewer()
Hooks the
GraphicalViewer to be used inside the container. |
void |
init(IEditorSite site,
IEditorInput input)
Does the initialization of the editor.
|
void |
initializeGraphicalViewer()
Called to initialize the editor with its content.
|
boolean |
isDirty()
Returns if the editor is currently dirty and needs to be saved or not.
|
void |
refreshTitle()
Refreshes the editor title to show the name of the diagram
|
void |
refreshTitleToolTip()
Refreshes the tooltip displayed for the editor title tab according to
what is returned in
getTitleToolTip(). |
void |
selectionChanged(IWorkbenchPart part,
ISelection selection)
Handles a selection changed event that is triggered by any selection
source, e.g.
|
void |
selectPictogramElements(PictogramElement[] pictogramElements)
Selects the given
PictogramElements in the diagram. |
void |
setEditDomain(org.eclipse.gef.DefaultEditDomain editDomain)
Sets the GEF edit domain to the container.
|
void |
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 to
DefaultUpdateBehavior.handleActivate(). |
void |
setGraphicalViewer(org.eclipse.gef.GraphicalViewer viewer)
Sets the
GraphicalViewer to be used inside the container. |
void |
setPictogramElementForSelection(PictogramElement pictogramElement)
Sets one
PictogramElement for later selection. |
void |
setPictogramElementsForSelection(PictogramElement[] pictogramElements)
Sets
PictogramElements for later selection. |
void |
stackChanged(org.eclipse.gef.commands.CommandStackEvent event) |
void |
updateDirtyState()
Updates the UI to correctly reflect the dirty state of the editor.
|
getEditorInput, getEditorSite, isSaveOnCloseNeeded, setInitializationDataaddPartPropertyListener, addPropertyListener, getContentDescription, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, removePartPropertyListener, removePropertyListener, setPartProperty, showBusyequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetSitegetTitleaddPropertyListener, getSite, getTitle, getTitleImage, removePropertyListenerpublic static final java.lang.String DIAGRAM_EDITOR_ID
DiagramEditor as it is registered with the
org.eclipse.ui.editors extension point.public DiagramEditor()
public DiagramBehavior getDiagramBehavior()
DiagramSupport instance to this editor.getDiagramBehavior in interface IDiagramContainergetDiagramBehavior in interface IDiagramContainerUIDiagramSupport instancepublic void init(IEditorSite site, IEditorInput input) throws PartInitException
IEditorInput to a
DiagramEditorInput. In case this fails, a
PartInitException is thrown.DefaultUpdateBehavior.createEditingDomain(IDiagramEditorInput)
for detailssuper.init(site, input).init in interface IEditorPartinit in class org.eclipse.gef.ui.parts.GraphicalEditorsite - the Eclipse IEditorSite that will host this editorinput - the editor input that shall be used. Note that this method
will exchange the input instance in case it is no
DiagramEditorInput.PartInitExceptionIEditorPart.init(IEditorSite, IEditorInput)public void createPartControl(Composite parent)
super.createPartControl method. The default implementation
here also registers the command stack listener to correctly reflect the
dirty state of the editor.createPartControl in interface IWorkbenchPartcreatePartControl in class org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalettepublic void initializeGraphicalViewer()
initializeGraphicalViewer in interface IDiagramContainerUIinitializeGraphicalViewer in class org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPaletteGraphicalEditorWithFlyoutPalette.initializeGraphicalViewer()public void configureGraphicalViewer()
configureGraphicalViewer in interface IDiagramContainerUIconfigureGraphicalViewer in class org.eclipse.gef.ui.parts.GraphicalEditorGraphicalEditor.configureGraphicalViewer()public void updateDirtyState()
IEditorPart.PROP_DIRTY property change.updateDirtyState in interface IDiagramContainerpublic void doSave(IProgressMonitor monitor)
DiagramSupport to
DefaultPersistencyBehavior.saveDiagram(IProgressMonitor).doSave in interface IDiagramContainerdoSave in interface ISaveablePartdoSave in class EditorPartmonitor - the Eclipse progress monitor to report progress with.public boolean isDirty()
DiagramSupport#isDirty().isDirty in interface IDiagramContainerisDirty in interface ISaveablePartisDirty in class org.eclipse.gef.ui.parts.GraphicalEditortrue in case the editor is dirty, false
otherwise.public void refreshTitle()
refreshTitle in interface IDiagramContainerpublic void refreshTitleToolTip()
getTitleToolTip().refreshTitleToolTip in interface IDiagramContainerpublic 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).getAdapter in interface IAdaptablegetAdapter in class org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalettetype - the type to which shall be adaptedpublic void dispose()
DiagramEditor 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!dispose in interface IWorkbenchPartdispose in class org.eclipse.gef.ui.parts.GraphicalEditorpublic void setFocus()
DefaultUpdateBehavior.handleActivate().setFocus in interface IWorkbenchPartsetFocus in class org.eclipse.gef.ui.parts.GraphicalEditorpublic PictogramElement[] getSelectedPictogramElements()
PictogramElements that are currently selected in the
diagram editor.getSelectedPictogramElements in interface IDiagramContainerPictogramElements.public void selectionChanged(IWorkbenchPart part, ISelection selection)
MultiPageEditorPart
with an opened diagram editor inside, tries to find any
PictogramElement for the objects in the selection and selects
them in the diagram.CommonNavigator as event source, its
editor linking mechanism must be enabled.selectionChanged in interface ISelectionListenerselectionChanged in class org.eclipse.gef.ui.parts.GraphicalEditorpart - the source IWorkbenchPart that triggered the eventselection - the new selection (mostly a IStructuredSelection
instance.public void selectPictogramElements(PictogramElement[] pictogramElements)
PictogramElements in the diagram.selectPictogramElements in interface IDiagramContainerpictogramElements - an array of PictogramElements to select.public void setPictogramElementForSelection(PictogramElement pictogramElement)
PictogramElement for later selection.
The methods #getPictogramElementsForSelection(),
setPictogramElementForSelection(PictogramElement),
setPictogramElementsForSelection(PictogramElement[]) and
DiagramSupport#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
DiagramSupport#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.
setPictogramElementForSelection in interface IDiagramContainerpictogramElement - the PictogramElement that shall be stored for later
selectionpublic void setPictogramElementsForSelection(PictogramElement[] pictogramElements)
PictogramElements for later selection.
The methods #getPictogramElementsForSelection(),
setPictogramElementForSelection(PictogramElement),
setPictogramElementsForSelection(PictogramElement[]) and
DiagramSupport#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
DiagramSupport#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.
setPictogramElementsForSelection in interface IDiagramContainerpictogramElements - the PictogramElements that shall be stored for later
selectionpublic java.lang.String getContributorId()
IToolBehaviorProvider.getContributorId()
.getContributorId in interface ITabbedPropertySheetPageContributorStringpublic IDiagramTypeProvider getDiagramTypeProvider()
IDiagramTypeProvider instance associated with this
DiagramEditor. There is always a 1:1 relation between the editor
and the provider.
Note that this is a pure delegation method. Overrides should happen in
DiagramBehavior.
getDiagramTypeProvider in interface IDiagramContainerIDiagramTypeProvider instance.public org.eclipse.gef.DefaultEditDomain getEditDomain()
getEditDomain in interface IDiagramContainerUIgetEditDomain in class org.eclipse.gef.ui.parts.GraphicalEditorDefaultEditDomain used in this editorGraphicalEditor.getEditDomain()public org.eclipse.gef.GraphicalViewer getGraphicalViewer()
GraphicalViewer as it is needed in some Graphiti
feature implementations. This is simply a public rewrite of the according
super method.getGraphicalViewer in interface IDiagramContainerUIgetGraphicalViewer in class org.eclipse.gef.ui.parts.GraphicalEditorGraphicalViewer used within this editor instanceGraphicalEditor.getGraphicalViewer()public java.lang.String getTitleToolTip()
getTitleToolTip in interface IDiagramContainergetTitleToolTip in interface IWorkbenchPartgetTitleToolTip in class EditorPartStringpublic org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain()
TransactionalEditingDomain used within this
editor by delegating to the update behavior extension, by default
DefaultUpdateBehavior.getEditingDomain().getEditingDomain in interface org.eclipse.emf.edit.domain.IEditingDomainProviderTransactionalEditingDomain instance used in the
editorpublic IDiagramEditorInput getDiagramEditorInput()
IDiagramContainerUIIDiagramEditorInput instance used for this container.
Basically it is used as an Eclipse IEditorInput 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.getDiagramEditorInput in interface IDiagramContainerUIpublic IWorkbenchPart getWorkbenchPart()
IWorkbenchPart for this container. Since this editor
itself is already a part the default implementation simply returns this.getWorkbenchPart in interface IDiagramContainerUIpublic void close()
IDiagramContainerclose in interface IDiagramContainerpublic void setEditDomain(org.eclipse.gef.DefaultEditDomain editDomain)
IDiagramContainerUIDiagramBehavior instance.setEditDomain in interface IDiagramContainerUIsetEditDomain in class org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPaletteeditDomain - The DefaultEditDomain to setGraphicalEditor#setEditDomain()public org.eclipse.gef.ui.actions.ActionRegistry getActionRegistry()
IDiagramContainerUIgetActionRegistry in interface IDiagramContainerUIgetActionRegistry in class org.eclipse.gef.ui.parts.GraphicalEditorActionRegistrypublic java.util.List getSelectionActions()
IDiagramContainerUIgetSelectionActions in interface IDiagramContainerUIgetSelectionActions in class org.eclipse.gef.ui.parts.GraphicalEditorList containing the selection actionsGraphicalEditor.getSelectionActions()public void commandStackChanged(java.util.EventObject event)
IDiagramContainerUIcommandStackChanged in interface org.eclipse.gef.commands.CommandStackListenercommandStackChanged in interface IDiagramContainerUIcommandStackChanged in class org.eclipse.gef.ui.parts.GraphicalEditorevent - An event instance describing what happenedGraphicalEditor.commandStackChanged(EventObject event)public void stackChanged(org.eclipse.gef.commands.CommandStackEvent event)
stackChanged in interface org.eclipse.gef.commands.CommandStackEventListenerpublic void setGraphicalViewer(org.eclipse.gef.GraphicalViewer viewer)
IDiagramContainerUIGraphicalViewer to be used inside the container. The
viewer is created by the DiagramBehavior instance and needs to be
set in the GEF container.setGraphicalViewer in interface IDiagramContainerUIsetGraphicalViewer in class org.eclipse.gef.ui.parts.GraphicalEditorviewer - The viewer to use.GraphicalEditor.setGraphicalViewer(GraphicalViewer viewer)public void hookGraphicalViewer()
IDiagramContainerUIGraphicalViewer to be used inside the container.hookGraphicalViewer in interface IDiagramContainerUIhookGraphicalViewer in class org.eclipse.gef.ui.parts.GraphicalEditorGraphicalEditor#hookGraphicalViewer(GraphicalViewer viewer)