org.eclipse.graphiti.ui.editor
Class DiagramEditorInput

java.lang.Object
  extended by org.eclipse.graphiti.ui.editor.DiagramEditorInput
All Implemented Interfaces:
IDiagramEditorInput

public class DiagramEditorInput
extends java.lang.Object
implements IDiagramEditorInput

The editor input object for DiagramEditors. Wraps the URI of a Diagram and an ID of a diagram type provider for displaying it with a Graphiti diagram editor.

See Also:
IEditorInput}, IPersistableElement}, DiagramEditorInputFactory}, DiagramEditor}

Field Summary
static java.lang.String KEY_PROVIDER_ID
          The memento key for the ID of the diagram type provider.
static java.lang.String KEY_URI
          The memento key for the stored URI string
private  java.lang.String name
          The cached input name (e.g.
private  java.lang.String providerId
          The ID of the diagram type provider.
private  java.lang.String tooltip
          The cached input tooltip
private  URI uri
          The stored URI string
 
Constructor Summary
DiagramEditorInput(URI diagramUri, java.lang.String providerId)
          Creates a new DiagramEditorInput out of a URI string and a Graphiti diagram type provider ID.
 
Method Summary
static DiagramEditorInput createEditorInput(Diagram diagram, java.lang.String providerId)
          Creates a new DiagramEditorInput for the given Diagram and the given diagram type provider ID.
 boolean equals(java.lang.Object obj)
          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.
 java.lang.Object getAdapter(java.lang.Class adapter)
          Adapter method as defined in IAdaptable, supports adaptation to IFile.
 java.lang.String getFactoryId()
          Returns the factory ID for creating DiagramEditorInputs from mementos.
 ImageDescriptor getImageDescriptor()
           
 java.lang.String getName()
           
 IPersistableElement getPersistable()
           
 java.lang.String getProviderId()
          Returns the diagram type provider id.
 java.lang.String getToolTipText()
           
 URI getUri()
           
 java.lang.String getUriString()
           
 int hashCode()
           
protected  boolean hasName()
          Checks if a name is set for this instance
private  URI normalizeUriString(URI diagramUri)
           
 void saveState(IMemento memento)
          Saves URI string, object name and provider ID to the given IMemento.
protected  void setName(java.lang.String name)
          Sets the name for this instance.
 void setProviderId(java.lang.String providerId)
          Sets the diagram type provider id.
 java.lang.String toString()
          Used for logging only!
 void updateUri(URI diagramFileUri)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_URI

public static final java.lang.String KEY_URI
The memento key for the stored URI string

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.


uri

private URI uri
The stored URI string


providerId

private java.lang.String providerId
The ID of the diagram type provider.


name

private java.lang.String name
The cached input name (e.g. for displaying the name in the navigation history without having to instantiate the EObject)

See Also:
#getLiveName()

tooltip

private java.lang.String tooltip
The cached input tooltip

See Also:
#getLiveToolTipText()
Constructor Detail

DiagramEditorInput

public DiagramEditorInput(URI diagramUri,
                          java.lang.String providerId)
Creates a new DiagramEditorInput out of a URI string and a Graphiti diagram type provider ID. For resolving the URI to an EObject the ResourceSet 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 - A URI that denotes the input's EObject. 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 lemenet 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 - A String which holds the diagram type id. When it is null, it is set later in DiagramEditor.setInput(IEditorInput)
Throws:
java.lang.IllegalArgumentException - if uriString parameter is null
Since:
0.9
See Also:
URI
Method Detail

normalizeUriString

private URI normalizeUriString(URI diagramUri)

createEditorInput

public static DiagramEditorInput createEditorInput(Diagram diagram,
                                                   java.lang.String providerId)
Creates a new DiagramEditorInput for the given Diagram and the given diagram type provider ID.

Parameters:
diagram - A Diagram
providerId - A String which holds the diagram type provider id.
Returns:
A DiagramEditorInput editor input
Since:
0.9

getProviderId

public java.lang.String getProviderId()
Returns the diagram type provider id.

Specified by:
getProviderId in interface IDiagramEditorInput
Returns:
The providerId.

setProviderId

public void setProviderId(java.lang.String providerId)
Sets the diagram type provider id.

Specified by:
setProviderId in interface IDiagramEditorInput
Parameters:
providerId - The providerId to set.

getFactoryId

public java.lang.String getFactoryId()
Returns the factory ID for creating DiagramEditorInputs from mementos.

Returns:
The ID of the associated factory

getImageDescriptor

public ImageDescriptor getImageDescriptor()
Returns:
Simply returns null.

getName

public java.lang.String getName()
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 is null.

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()
Returns:
The cached tooltip or the input's URI string
See Also:
#getLiveToolTipText()

getAdapter

public java.lang.Object getAdapter(java.lang.Class adapter)
Adapter method as defined in IAdaptable, supports adaptation to IFile.

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(IMemento memento)
Saves URI string, object name and provider ID to the given IMemento.

Parameters:
memento - The memento to store the information in

getUriString

public final java.lang.String getUriString()
Specified by:
getUriString in interface IDiagramEditorInput
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.

Returns:
true if the input's state denotes a living EMF object

getPersistable

public IPersistableElement getPersistable()
Returns:
this input if it is persistable, otherwise null

getUri

public URI getUri()
Specified by:
getUri in interface IDiagramEditorInput
Returns:
the resolved URI or null in 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:
equals in class java.lang.Object
Parameters:
obj - The object to compare this instance with.
Returns:
true if the represented objects are the same

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Used for logging only!

Overrides:
toString in class java.lang.Object

updateUri

public void updateUri(URI diagramFileUri)
Specified by:
updateUri in interface IDiagramEditorInput
Since:
0.9


Copyright (c) SAP AG 2005, 2012.