|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectGraphicalEditorWithFlyoutPalette
org.eclipse.graphiti.ui.editor.DiagramEditor
public class DiagramEditor
This is the main class for the Graphiti diagram editor. It represents the
editor to Eclipse and therefore implements IEditorPart
. The
implementation is based upon a GEF editor implementation (
GraphicalEditorWithFlyoutPalette
) and enhances it with
Graphiti-specific stuff.
This editor is registered as an Eclipse editor using the extension point
org.eclipse.ui.editors. Therefore the Eclipse standard methods can be used to
open a new diagram editor. The associated 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)
).
Any clients extending this class should also contribute their editor to the
Eclipse editor extension point to gain full advantage of the Eclipse editor
integration of Graphiti.
There are a lot of aspects this class needs to deal with; the larger aspects
are separated into other classes which share the lifecycle with the
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.
Field Summary | |
---|---|
private String |
contributorId
|
static String |
DIAGRAM_EDITOR_ID
The ID of the DiagramEditor as it is registered with the
org.eclipse.ui.editors extension point. |
private DiagramBehavior |
diagramBehavior
|
Fields inherited from interface org.eclipse.graphiti.ui.editor.IDiagramContainerUI |
---|
DIAGRAM_CONTEXT_ID |
Constructor Summary | |
---|---|
DiagramEditor()
Creates a new diagram editor and cares about the creation of the different behavior extensions by delegating to the various create*Behavior() methods. |
Method Summary | |
---|---|
void |
close()
Notify the container that it should shut down or clear it's state. |
void |
commandStackChanged(EventObject event)
Notification that the command stack changed. |
protected void |
configureGraphicalViewer()
Called to configure the editor, before it receives its content. |
protected DiagramEditorInput |
convertToDiagramEditorInput(IEditorInput input)
Is called by the init(IEditorSite, IEditorInput) method in case
the IEditorInput instance passed is no DiagramEditorInput
. |
protected DiagramBehavior |
createDiagramBehavior()
Creates the behavior object that cares about the common (behavioral) coding shared between editors, views and other composites. |
protected void |
createGraphicalViewer(Composite parent)
Creates the GraphicalViewer on the specified Composite and
initializes it. |
protected PaletteViewerProvider |
createPaletteViewerProvider()
Delegates to the method (or the method in a subclass of) #createPaletteViewerProvider() to create the
PaletteViewerProvider used inside the GEF editor. |
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. |
ActionRegistry |
getActionRegistry()
Returns the GEF action registry for the container. |
Object |
getAdapter(Class type)
Implements the Eclipse IAdaptable interface. |
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 . |
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. |
TransactionalEditingDomain |
getEditingDomain()
Returns the EMF TransactionalEditingDomain used within this
editor by delegating to the update behavior extension, by default
DefaultUpdateBehavior.getEditingDomain() . |
GraphicalViewer |
getGraphicalViewer()
Returns the GEF GraphicalViewer as it is needed in some Graphiti
feature implementations. |
protected FlyoutPreferences |
getPalettePreferences()
Delegates to the method (or the method in a subclass of) DefaultPaletteBehavior.getPalettePreferences() . |
protected PaletteRoot |
getPaletteRoot()
Returns the PaletteRoot to use in the GEF editor by delegating to
DefaultPaletteBehavior.getPaletteRoot() . |
PictogramElement[] |
getSelectedPictogramElements()
Returns the PictogramElement s that are currently selected in the
diagram editor. |
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. |
String |
getTitleToolTip()
Returns the tooltip that shall be displayed when hovering over the editor title tab. |
private IToolBehaviorProvider |
getToolBehaviorProvider()
|
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(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(GraphicalViewer viewer)
Sets the GraphicalViewer to be used inside the container. |
protected void |
setInput(IEditorInput input)
Sets the given IEditorInput object as the input for this editor. |
void |
setPictogramElementForSelection(PictogramElement pictogramElement)
Sets one PictogramElement for later selection. |
void |
setPictogramElementsForSelection(PictogramElement[] pictogramElements)
Sets PictogramElement s for later selection. |
void |
updateDirtyState()
Updates the UI to correctly reflect the dirty state of the editor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.eclipse.graphiti.ui.editor.IDiagramContainerUI |
---|
getSite |
Methods inherited from interface org.eclipse.graphiti.platform.IDiagramContainer |
---|
getTitle |
Field Detail |
---|
private String contributorId
private DiagramBehavior diagramBehavior
public static final String DIAGRAM_EDITOR_ID
DiagramEditor
as it is registered with the
org.eclipse.ui.editors extension point.
Constructor Detail |
---|
public DiagramEditor()
Method Detail |
---|
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()
for
detailssuper.init(site, input)
.
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
org.eclipse.ui.IEditorPart#init(IEditorSite, IEditorInput)
protected DiagramBehavior createDiagramBehavior()
DiagramBehavior
for details and the default implementation.
Override to change the behavior.
DiagramBehavior
protected DiagramEditorInput convertToDiagramEditorInput(IEditorInput input) throws PartInitException
init(IEditorSite, IEditorInput)
method in case
the IEditorInput
instance passed is no DiagramEditorInput
. This method should try to convert the passed input object to a
DiagramEditorInput
or throw an PartInitException
in case
the conversion can (or should) not be done for any reason. The default
implementation uses the
EditorInputAdapter.adaptToDiagramEditorInput(IEditorInput)
method
to do the conversion. Clients may adapt to do additional conversions or
to prohibit any conversion by simply throwing a PartInitException
.
input
- the original input
DiagramEditorInput
corresponding to the passed input
instance in case a conversion is possible. This method must not
return null
, otherwise the editor initialization
will fail.
PartInitException
- in case the passed input object cannot or should not be
converted to a DiagramEditorInput
instance.protected void setInput(IEditorInput input)
IEditorInput
object as the input for this editor.
It must be of type DiagramEditorInput
otherwise an
IllegalArgumentException
is thrown.Resource
the input points to, sets the ID of the
IDiagramTypeProvider
for the diagram given in the input,
registers listeners (by delegating to
#registerDiagramResourceSetListener()
and
#registerBusinessObjectsListener()
) and does the refreshing of
the editor UI.
input
- the DiagramEditorInput
instance to use within this
editor.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.
protected void createGraphicalViewer(Composite parent)
Composite
and
initializes it. This method needs to be implemented here to fulfill the
interface of the underlying GEF editor but only delegates to
DiagramSupport#createGraphicalViewer(Composite)
.
parent
- The parent compositepublic void initializeGraphicalViewer()
org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette#initializeGraphicalViewer()
protected void configureGraphicalViewer()
org.eclipse.gef.ui.parts.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
monitor
- the Eclipse progress monitor to report progress with.public boolean isDirty()
DiagramSupport#isDirty()
.
isDirty
in interface IDiagramContainer
isDirty
in interface IDiagramEditor
true
in case the editor is dirty, false
otherwise.protected final PaletteViewerProvider createPaletteViewerProvider()
#createPaletteViewerProvider()
to create the
PaletteViewerProvider
used inside the GEF editor.
PaletteViewerProvider
to useprotected final FlyoutPreferences getPalettePreferences()
DefaultPaletteBehavior.getPalettePreferences()
. To change the
palette override the behavior there.
PaletteViewerProvider
preferences to use.protected final PaletteRoot getPaletteRoot()
PaletteRoot
to use in the GEF editor by delegating to
DefaultPaletteBehavior.getPaletteRoot()
.
PaletteRoot
to usepublic void refreshTitle()
refreshTitle
in interface IDiagramContainer
refreshTitle
in interface IDiagramEditor
public void refreshTitleToolTip()
getTitleToolTip()
.
refreshTitleToolTip
in interface IDiagramContainer
refreshTitleToolTip
in interface IDiagramEditor
public Object getAdapter(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 adapted
public 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!
public void setFocus()
DefaultUpdateBehavior.handleActivate()
.
public PictogramElement[] getSelectedPictogramElements()
PictogramElement
s that are currently selected in the
diagram editor.
getSelectedPictogramElements
in interface IDiagramContainer
getSelectedPictogramElements
in interface IDiagramEditor
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.
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
selectPictogramElements
in interface IDiagramEditor
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
setPictogramElementForSelection
in interface IDiagramEditor
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
setPictogramElementsForSelection
in interface IDiagramEditor
pictogramElements
- the PictogramElement
s that shall be stored for later
selectionpublic String getContributorId()
IToolBehaviorProvider.getContributorId()
.
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
getDiagramTypeProvider
in interface IDiagramEditor
IDiagramTypeProvider
instance.public DefaultEditDomain getEditDomain()
getEditDomain
in interface IDiagramContainerUI
DefaultEditDomain
used in this editorGraphicalEditor#getEditDomain()
public 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
GraphicalViewer
used within this editor instanceGraphicalEditor#getGraphicalViewer()
public String getTitleToolTip()
getTitleToolTip
in interface IDiagramContainer
String
private IToolBehaviorProvider getToolBehaviorProvider()
public TransactionalEditingDomain getEditingDomain()
TransactionalEditingDomain
used within this
editor by delegating to the update behavior extension, by default
DefaultUpdateBehavior.getEditingDomain()
.
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(DefaultEditDomain editDomain)
IDiagramContainerUI
DiagramBehavior
instance.
setEditDomain
in interface IDiagramContainerUI
editDomain
- The DefaultEditDomain
to setGraphicalEditor#setEditDomain()
public ActionRegistry getActionRegistry()
IDiagramContainerUI
getActionRegistry
in interface IDiagramContainerUI
ActionRegistry
public List getSelectionActions()
IDiagramContainerUI
getSelectionActions
in interface IDiagramContainerUI
List
containing the selection actionsGraphicalEditor#getSelectionActions()
public void commandStackChanged(EventObject event)
IDiagramContainerUI
commandStackChanged
in interface IDiagramContainerUI
event
- An event instance describing what happenedGraphicalEditor#commandStackChanged(EventObject event)
public void setGraphicalViewer(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
viewer
- The viewer to use.GraphicalEditor#setGraphicalViewer(GraphicalViewer viewer)
public void hookGraphicalViewer()
IDiagramContainerUI
GraphicalViewer
to be used inside the container.
hookGraphicalViewer
in interface IDiagramContainerUI
GraphicalEditor#hookGraphicalViewer(GraphicalViewer viewer)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |