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 java.lang.Object implements org.eclipse.ui.IEditorInput, org.eclipse.ui.IPersistableElement, IDiagramEditorInput
The editor input object forIDiagramContainerUIs. Wraps theURIof aDiagramand an ID of a diagram type provider for displaying it with a Graphiti diagram editor.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringKEY_PROVIDER_IDThe memento key for the ID of the diagram type provider.static java.lang.StringKEY_URIThe memento key for the storedURIstring
-
Constructor Summary
Constructors Constructor Description DiagramEditorInput(org.eclipse.emf.common.util.URI diagramUri, java.lang.String providerId)Creates a newDiagramEditorInputout of aURIstring and a Graphiti diagram type provider ID.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DiagramEditorInputcreateEditorInput(Diagram diagram, java.lang.String providerId)Creates a newDiagramEditorInputfor the givenDiagramand the given diagram type provider ID.booleanequals(java.lang.Object obj)Checks if this instance of the input represent the same object as the given instance.booleanexists()Checks if the diagram this input represents exist.java.lang.ObjectgetAdapter(java.lang.Class adapter)Adapter method as defined inIAdaptable, supports adaptation toIFile.java.lang.StringgetFactoryId()Returns the factory ID for creatingDiagramEditorInputs from mementos.org.eclipse.jface.resource.ImageDescriptorgetImageDescriptor()java.lang.StringgetName()org.eclipse.ui.IPersistableElementgetPersistable()java.lang.StringgetProviderId()Returns the diagram type provider id.java.lang.StringgetToolTipText()org.eclipse.emf.common.util.URIgetUri()java.lang.StringgetUriString()inthashCode()protected booleanhasName()Checks if a name is set for this instancevoidsaveState(org.eclipse.ui.IMemento memento)SavesURIstring, object name and provider ID to the givenIMemento.protected voidsetName(java.lang.String name)Sets the name for this instance.voidsetProviderId(java.lang.String providerId)Sets the diagram type provider id.java.lang.StringtoString()Used for logging only!voidupdateUri(org.eclipse.emf.common.util.URI diagramFileUri)
-
-
-
Field Detail
-
KEY_URI
public static final java.lang.String KEY_URI
The memento key for the storedURIstring- See Also:
- Constant Field Values
-
KEY_PROVIDER_ID
public static java.lang.String KEY_PROVIDER_ID
The memento key for the ID of the diagram type provider.
-
-
Constructor Detail
-
DiagramEditorInput
public DiagramEditorInput(org.eclipse.emf.common.util.URI diagramUri, java.lang.String providerId)Creates a newDiagramEditorInputout of aURIstring and a Graphiti diagram type provider ID. For resolving theURIto anEObjecttheResourceSetthat 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- AURIthat 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- AStringwhich holds the diagram type id. When it is null, it is set later inDiagramBehavior#setInput(IEditorInput)- Throws:
java.lang.IllegalArgumentException- ifuriStringparameter is null- Since:
- 0.9
- See Also:
URI
-
-
Method Detail
-
createEditorInput
public static DiagramEditorInput createEditorInput(Diagram diagram, java.lang.String providerId)
Creates a newDiagramEditorInputfor the givenDiagramand the given diagram type provider ID.- Parameters:
diagram- ADiagramproviderId- AStringwhich holds the diagram type provider id.- Returns:
- A
DiagramEditorInputeditor input - Since:
- 0.9
-
getProviderId
public java.lang.String getProviderId()
Returns the diagram type provider id.- Specified by:
getProviderIdin interfaceIDiagramEditorInput- Returns:
- The providerId.
-
setProviderId
public void setProviderId(java.lang.String providerId)
Sets the diagram type provider id.- Specified by:
setProviderIdin interfaceIDiagramEditorInput- Parameters:
providerId- The providerId to set.
-
getFactoryId
public java.lang.String getFactoryId()
Returns the factory ID for creatingDiagramEditorInputs from mementos.- Specified by:
getFactoryIdin interfaceorg.eclipse.ui.IPersistableElement- Returns:
- The ID of the associated factory
-
getImageDescriptor
public org.eclipse.jface.resource.ImageDescriptor getImageDescriptor()
- Specified by:
getImageDescriptorin interfaceorg.eclipse.ui.IEditorInput- Returns:
- Simply returns
null.
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceorg.eclipse.ui.IEditorInput- Returns:
- The cached name or the input's
URIstring - See Also:
#getLiveName()
-
hasName
protected boolean hasName()
Checks if a name is set for this instance- Returns:
truein case a name is set,falsein name isnull.
-
setName
protected void setName(java.lang.String name)
Sets the name for this instance.- Parameters:
name- The name to set.
-
getToolTipText
public java.lang.String getToolTipText()
- Specified by:
getToolTipTextin interfaceorg.eclipse.ui.IEditorInput- Returns:
- The cached tooltip or the input's
URIstring - See Also:
#getLiveToolTipText()
-
getAdapter
public java.lang.Object getAdapter(java.lang.Class adapter)
Adapter method as defined inIAdaptable, supports adaptation toIFile.- Specified by:
getAdapterin interfaceorg.eclipse.core.runtime.IAdaptable- Parameters:
adapter- The adapter class to look up- Returns:
- A object castable to the given class, or
nullif this object does not have an adapter for the given class
-
saveState
public void saveState(org.eclipse.ui.IMemento memento)
SavesURIstring, object name and provider ID to the givenIMemento.- Specified by:
saveStatein interfaceorg.eclipse.ui.IPersistable- Parameters:
memento- The memento to store the information in
-
getUriString
public final java.lang.String getUriString()
- Specified by:
getUriStringin interfaceIDiagramEditorInput- Returns:
- The
URIstring 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
trueis returned.- Specified by:
existsin interfaceorg.eclipse.ui.IEditorInput- Returns:
trueif the input's state denotes a living EMF object
-
getPersistable
public org.eclipse.ui.IPersistableElement getPersistable()
- Specified by:
getPersistablein interfaceorg.eclipse.ui.IEditorInput- Returns:
- this input if it is persistable, otherwise null
-
getUri
public org.eclipse.emf.common.util.URI getUri()
- Specified by:
getUriin interfaceIDiagramEditorInput- Returns:
- the resolved
URIornullin case of failures - Since:
- 0.9
-
equals
public boolean equals(java.lang.Object obj)
Checks if this instance of the input represent the same object as the given instance.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- The object to compare this instance with.- Returns:
trueif the represented objects are the same
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
Used for logging only!- Overrides:
toStringin classjava.lang.Object
-
updateUri
public void updateUri(org.eclipse.emf.common.util.URI diagramFileUri)
- Specified by:
updateUriin interfaceIDiagramEditorInput- Since:
- 0.9
-
-