Package org.eclipse.graphiti.ui.editor
Class DiagramEditorInput
java.lang.Object
org.eclipse.graphiti.ui.editor.DiagramEditorInput
- All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable
,IDiagramEditorInput
,org.eclipse.ui.IEditorInput
,org.eclipse.ui.IPersistable
,org.eclipse.ui.IPersistableElement
public class DiagramEditorInput
extends Object
implements org.eclipse.ui.IEditorInput, org.eclipse.ui.IPersistableElement, IDiagramEditorInput
The editor input object for
IDiagramContainerUI
s. Wraps the URI
of
a Diagram
and an ID of a diagram type provider for displaying it with
a Graphiti diagram editor.-
Field Summary
-
Constructor Summary
ConstructorDescriptionDiagramEditorInput
(org.eclipse.emf.common.util.URI diagramUri, String providerId) Creates a newDiagramEditorInput
out of aURI
string and a Graphiti diagram type provider ID. -
Method Summary
Modifier and TypeMethodDescriptionstatic DiagramEditorInput
createEditorInput
(Diagram diagram, String providerId) Creates a newDiagramEditorInput
for the givenDiagram
and the given diagram type provider ID.boolean
Checks if this instance of the input represent the same object as the given instance.boolean
exists()
Checks if the diagram this input represents exist.getAdapter
(Class adapter) Adapter method as defined inIAdaptable
, supports adaptation toIFile
.Returns the factory ID for creatingDiagramEditorInput
s from mementos.org.eclipse.jface.resource.ImageDescriptor
getName()
org.eclipse.ui.IPersistableElement
Returns the diagram type provider id.org.eclipse.emf.common.util.URI
getUri()
final String
int
hashCode()
protected boolean
hasName()
Checks if a name is set for this instancevoid
saveState
(org.eclipse.ui.IMemento memento) SavesURI
string, object name and provider ID to the givenIMemento
.protected void
Sets the name for this instance.void
setProviderId
(String providerId) Sets the diagram type provider id.toString()
Used for logging only!void
updateUri
(org.eclipse.emf.common.util.URI diagramFileUri)
-
Field Details
-
KEY_URI
The memento key for the storedURI
string- See Also:
-
KEY_PROVIDER_ID
The memento key for the ID of the diagram type provider.
-
-
Constructor Details
-
DiagramEditorInput
Creates a newDiagramEditorInput
out of aURI
string and a Graphiti diagram type provider ID. For resolving theURI
to anEObject
theResourceSet
that will be created when a diagram editor starts is taken. This input object will not resolve the diagram.
A diagram type provider ID is held in this class.- Parameters:
diagramUri
- AURI
that denotes the input'sEObject
. This can either be a URI of a Graphiti diagram or the URI of an EMF resource storing a Graphiti diagram. In the latter case the given URI will b e trimmed to point to the first element in the resource; make sure that this element is a Graphiti diagram, otherwise an exception will be thrown when the diagram editor opens. No check on this is done inside the input object itself!providerId
- AString
which holds the diagram type id. When it is null, it is set later inDiagramBehavior#setInput(IEditorInput)
- Throws:
IllegalArgumentException
- ifuriString
parameter is null- Since:
- 0.9
- See Also:
-
URI
-
-
Method Details
-
createEditorInput
Creates a newDiagramEditorInput
for the givenDiagram
and the given diagram type provider ID.- Parameters:
diagram
- ADiagram
providerId
- AString
which holds the diagram type provider id.- Returns:
- A
DiagramEditorInput
editor input - Since:
- 0.9
-
getProviderId
Returns the diagram type provider id.- Specified by:
getProviderId
in interfaceIDiagramEditorInput
- Returns:
- The providerId.
-
setProviderId
Sets the diagram type provider id.- Specified by:
setProviderId
in interfaceIDiagramEditorInput
- Parameters:
providerId
- The providerId to set.
-
getFactoryId
Returns the factory ID for creatingDiagramEditorInput
s from mementos.- Specified by:
getFactoryId
in interfaceorg.eclipse.ui.IPersistableElement
- Returns:
- The ID of the associated factory
-
getImageDescriptor
public org.eclipse.jface.resource.ImageDescriptor getImageDescriptor()- Specified by:
getImageDescriptor
in interfaceorg.eclipse.ui.IEditorInput
- Returns:
- Simply returns
null
.
-
getName
- Specified by:
getName
in interfaceorg.eclipse.ui.IEditorInput
- Returns:
- The cached name or the input's
URI
string - See Also:
-
#getLiveName()
-
hasName
protected boolean hasName()Checks if a name is set for this instance- Returns:
true
in case a name is set,false
in name isnull
.
-
setName
Sets the name for this instance.- Parameters:
name
- The name to set.
-
getToolTipText
- Specified by:
getToolTipText
in interfaceorg.eclipse.ui.IEditorInput
- Returns:
- The cached tooltip or the input's
URI
string - See Also:
-
#getLiveToolTipText()
-
getAdapter
Adapter method as defined inIAdaptable
, supports adaptation toIFile
.- Specified by:
getAdapter
in interfaceorg.eclipse.core.runtime.IAdaptable
- Parameters:
adapter
- The adapter class to look up- Returns:
- A object castable to the given class, or
null
if this object does not have an adapter for the given class
-
saveState
public void saveState(org.eclipse.ui.IMemento memento) SavesURI
string, object name and provider ID to the givenIMemento
.- Specified by:
saveState
in interfaceorg.eclipse.ui.IPersistable
- Parameters:
memento
- The memento to store the information in
-
getUriString
- Specified by:
getUriString
in interfaceIDiagramEditorInput
- Returns:
- The
URI
string this input and its editors operate on
-
exists
public boolean exists()Checks if the diagram this input represents exist.Note: The editor gets only restored, when
true
is returned.- Specified by:
exists
in interfaceorg.eclipse.ui.IEditorInput
- Returns:
true
if the input's state denotes a living EMF object
-
getPersistable
public org.eclipse.ui.IPersistableElement getPersistable()- Specified by:
getPersistable
in interfaceorg.eclipse.ui.IEditorInput
- Returns:
- this input if it is persistable, otherwise null
-
getUri
public org.eclipse.emf.common.util.URI getUri()- Specified by:
getUri
in interfaceIDiagramEditorInput
- Returns:
- the resolved
URI
ornull
in case of failures - Since:
- 0.9
-
equals
Checks if this instance of the input represent the same object as the given instance. -
hashCode
public int hashCode() -
toString
Used for logging only! -
updateUri
public void updateUri(org.eclipse.emf.common.util.URI diagramFileUri) - Specified by:
updateUri
in interfaceIDiagramEditorInput
- Since:
- 0.9
-