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_ID
PROP_DIRTY, PROP_INPUT
PROP_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
PictogramElement s 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
PictogramElement s 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
PictogramElement s 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, setInitializationData
addPartPropertyListener, addPropertyListener, getContentDescription, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, removePartPropertyListener, removePropertyListener, setPartProperty, showBusy
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSite
getTitle
addPropertyListener, getSite, getTitle, getTitleImage, removePropertyListener
public 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 IDiagramContainer
getDiagramBehavior
in interface IDiagramContainerUI
DiagramSupport
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 IEditorPart
init
in class org.eclipse.gef.ui.parts.GraphicalEditor
site
- 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
.PartInitException
IEditorPart.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 IWorkbenchPart
createPartControl
in class org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette
public void initializeGraphicalViewer()
initializeGraphicalViewer
in interface IDiagramContainerUI
initializeGraphicalViewer
in class org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette
GraphicalEditorWithFlyoutPalette.initializeGraphicalViewer()
public void configureGraphicalViewer()
configureGraphicalViewer
in interface IDiagramContainerUI
configureGraphicalViewer
in class org.eclipse.gef.ui.parts.GraphicalEditor
GraphicalEditor.configureGraphicalViewer()
public void updateDirtyState()
IEditorPart.PROP_DIRTY
property change.updateDirtyState
in interface IDiagramContainer
public void doSave(IProgressMonitor monitor)
DiagramSupport
to
DefaultPersistencyBehavior.saveDiagram(IProgressMonitor)
.doSave
in interface IDiagramContainer
doSave
in interface ISaveablePart
doSave
in class EditorPart
monitor
- the Eclipse progress monitor to report progress with.public boolean isDirty()
DiagramSupport#isDirty()
.isDirty
in interface IDiagramContainer
isDirty
in interface ISaveablePart
isDirty
in class org.eclipse.gef.ui.parts.GraphicalEditor
true
in case the editor is dirty, false
otherwise.public void refreshTitle()
refreshTitle
in interface IDiagramContainer
public void refreshTitleToolTip()
getTitleToolTip()
.refreshTitleToolTip
in interface IDiagramContainer
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)
.getAdapter
in interface IAdaptable
getAdapter
in class org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette
type
- 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 IWorkbenchPart
dispose
in class org.eclipse.gef.ui.parts.GraphicalEditor
public void setFocus()
DefaultUpdateBehavior.handleActivate()
.setFocus
in interface IWorkbenchPart
setFocus
in class org.eclipse.gef.ui.parts.GraphicalEditor
public PictogramElement[] getSelectedPictogramElements()
PictogramElement
s that are currently selected in the
diagram editor.getSelectedPictogramElements
in interface IDiagramContainer
PictogramElement
s.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 ISelectionListener
selectionChanged
in class org.eclipse.gef.ui.parts.GraphicalEditor
part
- the source IWorkbenchPart
that triggered the eventselection
- the new selection (mostly a IStructuredSelection
instance.public void selectPictogramElements(PictogramElement[] pictogramElements)
PictogramElement
s in the diagram.selectPictogramElements
in interface IDiagramContainer
pictogramElements
- an array of PictogramElement
s 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,
PictogramElement
s 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 IDiagramContainer
pictogramElement
- the PictogramElement
that shall be stored for later
selectionpublic void setPictogramElementsForSelection(PictogramElement[] pictogramElements)
PictogramElement
s 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,
PictogramElement
s 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 IDiagramContainer
pictogramElements
- the PictogramElement
s that shall be stored for later
selectionpublic java.lang.String getContributorId()
IToolBehaviorProvider.getContributorId()
.getContributorId
in interface ITabbedPropertySheetPageContributor
String
public 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 IDiagramContainer
IDiagramTypeProvider
instance.public org.eclipse.gef.DefaultEditDomain getEditDomain()
getEditDomain
in interface IDiagramContainerUI
getEditDomain
in class org.eclipse.gef.ui.parts.GraphicalEditor
DefaultEditDomain
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 IDiagramContainerUI
getGraphicalViewer
in class org.eclipse.gef.ui.parts.GraphicalEditor
GraphicalViewer
used within this editor instanceGraphicalEditor.getGraphicalViewer()
public java.lang.String getTitleToolTip()
getTitleToolTip
in interface IDiagramContainer
getTitleToolTip
in interface IWorkbenchPart
getTitleToolTip
in class EditorPart
String
public 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.IEditingDomainProvider
TransactionalEditingDomain
instance used in the
editorpublic IDiagramEditorInput getDiagramEditorInput()
IDiagramContainerUI
IDiagramEditorInput
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 IDiagramContainerUI
public IWorkbenchPart getWorkbenchPart()
IWorkbenchPart
for this container. Since this editor
itself is already a part the default implementation simply returns this.getWorkbenchPart
in interface IDiagramContainerUI
public void close()
IDiagramContainer
close
in interface IDiagramContainer
public void setEditDomain(org.eclipse.gef.DefaultEditDomain editDomain)
IDiagramContainerUI
DiagramBehavior
instance.setEditDomain
in interface IDiagramContainerUI
setEditDomain
in class org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette
editDomain
- The DefaultEditDomain
to setGraphicalEditor#setEditDomain()
public org.eclipse.gef.ui.actions.ActionRegistry getActionRegistry()
IDiagramContainerUI
getActionRegistry
in interface IDiagramContainerUI
getActionRegistry
in class org.eclipse.gef.ui.parts.GraphicalEditor
ActionRegistry
public java.util.List getSelectionActions()
IDiagramContainerUI
getSelectionActions
in interface IDiagramContainerUI
getSelectionActions
in class org.eclipse.gef.ui.parts.GraphicalEditor
List
containing the selection actionsGraphicalEditor.getSelectionActions()
public void commandStackChanged(java.util.EventObject event)
IDiagramContainerUI
commandStackChanged
in interface org.eclipse.gef.commands.CommandStackListener
commandStackChanged
in interface IDiagramContainerUI
commandStackChanged
in class org.eclipse.gef.ui.parts.GraphicalEditor
event
- 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.CommandStackEventListener
public void setGraphicalViewer(org.eclipse.gef.GraphicalViewer viewer)
IDiagramContainerUI
GraphicalViewer
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 IDiagramContainerUI
setGraphicalViewer
in class org.eclipse.gef.ui.parts.GraphicalEditor
viewer
- The viewer to use.GraphicalEditor.setGraphicalViewer(GraphicalViewer viewer)
public void hookGraphicalViewer()
IDiagramContainerUI
GraphicalViewer
to be used inside the container.hookGraphicalViewer
in interface IDiagramContainerUI
hookGraphicalViewer
in class org.eclipse.gef.ui.parts.GraphicalEditor
GraphicalEditor#hookGraphicalViewer(GraphicalViewer viewer)