|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.graphiti.ui.editor.DiagramEditorInput
public class DiagramEditorInput
The Class DiagramEditorInput.
The editor input for DiagramEditor
diagram editors. Basically a
TransactionalEditingDomain
with an already existing
ResourceSet
is hosted to resolve an EObject
from an
URI
String. Some helper methods are added.
Note that neither the URI
nor the EObject
is held by an
instance of this object. Only the TransactionalEditingDomain
(needs
to be passed to the constructor) is held and the creator of the domain is
also responsible for disposing it, unless the flag
disposeEditingDomain
is set to true
in one of the
appropriate constructors.
IEditorInput}
,
IPersistableElement}
,
DiagramEditorFactory}
,
DiagramEditor}
Field Summary | |
---|---|
private boolean |
disposeEditingDomain
Controls if this instance is responsible for disposing its TransactionalEditingDomain member or not. |
protected TransactionalEditingDomain |
editingDomain
The editor's TransactionalEditingDomain set by
setEditorEditingDomain(TransactionalEditingDomain) . |
static java.lang.String |
KEY_OBJECT_NAME
The memento key for the stored object name |
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 URI |
normalizedUri
The stored URI in normalized form. |
private java.lang.String |
providerId
The ID of the diagram type provider. |
private java.lang.String |
tooltip
The cached input tooltip |
private java.lang.String |
uriName
The stored URI string |
Constructor Summary | |
---|---|
DiagramEditorInput(java.lang.String diagramUriString,
TransactionalEditingDomain domain,
java.lang.String providerId)
Creates a new DiagramEditorInput out of a URI string and
a transactional editing domain. |
|
DiagramEditorInput(java.lang.String diagramUriString,
TransactionalEditingDomain domain,
java.lang.String providerId,
boolean disposeEditingDomain)
Creates a new DiagramEditorInput out of a URI string and
a transactional editing domain. |
|
DiagramEditorInput(URI diagramUri,
TransactionalEditingDomain domain,
java.lang.String providerId)
Creates a new DiagramEditorInput out of a URI string and
a transactional editing domain. |
|
DiagramEditorInput(URI diagramUri,
TransactionalEditingDomain domain,
java.lang.String providerId,
boolean disposeEditingDomain)
Creates a new DiagramEditorInput out of a URI string and
a transactional editing domain. |
Method Summary | |
---|---|
static DiagramEditorInput |
createEditorInput(Diagram diagram,
TransactionalEditingDomain domain,
java.lang.String providerId,
boolean disposeEditingDomain)
Creates a new DiagramEditorInput with a self created
TransactionalEditingDomain editing domain, which must be disposed later
on. |
private URI |
createNormalizedUri()
|
void |
dispose()
|
boolean |
equals(java.lang.Object obj)
Checks if this instance of the input represents 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)
Returns the concrete model element represented by the stored URI, if the requested adapter is either the same class or super class. |
Diagram |
getDiagram()
Returns the diagram instance of this input |
private TransactionalEditingDomain |
getEditingDomain()
|
EObject |
getEObject()
Returns the model object the editor input is working on. |
private EObject |
getEObject(java.lang.Class<EObject> adapter)
This method returns an instance which is either of the same Class object a sub class or sub interface of the class
defined by adapter - null otherwise. |
java.lang.String |
getFactoryId()
Returns the factory ID for creating DiagramEditorInput s from
mementos. |
ImageDescriptor |
getImageDescriptor()
|
protected java.lang.String |
getLiveName()
Returns a name for the input from the Diagram , when possible. |
protected java.lang.String |
getLiveToolTipText()
Returns a tooltip for the input from the Diagram object, when
possible. |
java.lang.String |
getName()
|
IPersistableElement |
getPersistable()
|
java.lang.String |
getProviderId()
Returns the diagram type provider id. |
java.lang.String |
getToolTipText()
|
private URI |
getUri()
|
java.lang.String |
getUriString()
|
int |
hashCode()
|
protected boolean |
hasName()
Checks if a name is set for this instance |
void |
saveState(IMemento memento)
Saves URI string, object name and provider ID to the given
IMemento . |
private void |
setEditorEditingDomain(TransactionalEditingDomain editingDomain)
Called from constructor to populate the editor's TransactionalEditingDomain to its input. |
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! |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String KEY_URI
URI
string
public static final java.lang.String KEY_OBJECT_NAME
public static java.lang.String KEY_PROVIDER_ID
private final java.lang.String uriName
URI
string
private URI normalizedUri
URI
in normalized form.
private java.lang.String providerId
private java.lang.String name
EObject
)
getLiveName()
private java.lang.String tooltip
getLiveToolTipText()
protected TransactionalEditingDomain editingDomain
TransactionalEditingDomain
set by
setEditorEditingDomain(TransactionalEditingDomain)
. Its
ResourcSet is used to resolve uriName
into live objects.
getEditingDomain()
private boolean disposeEditingDomain
TransactionalEditingDomain
member or not.
Constructor Detail |
---|
public DiagramEditorInput(java.lang.String diagramUriString, TransactionalEditingDomain domain, java.lang.String providerId)
DiagramEditorInput
out of a URI
string and
a transactional editing domain. For resolving the URI
to an
EObject
its ResourceSet
is used. IWorkspaceCommandStack
as the used command stack.
diagramUriString
- A URI
string as returned by URI#toString()
that denotes the input's EObject
domain
- A TransactionalEditingDomain
which contains the
ResourceSet
. Note that the caller is responsible for
disposing this instance of the domain when it is no longer
needed!providerId
- A String
which holds the diagram type id. When it is
null, it is set later in DiagramEditorInternal
java.lang.IllegalArgumentException
- if uriString
parameter is null domain
is no
IWorkspaceCommandStack
URI
public DiagramEditorInput(java.lang.String diagramUriString, TransactionalEditingDomain domain, java.lang.String providerId, boolean disposeEditingDomain)
DiagramEditorInput
out of a URI
string and
a transactional editing domain. For resolving the URI
to an
EObject
its ResourceSet
is used. IWorkspaceCommandStack
as the used command stack.
diagramUriString
- A URI
string as returned by URI#toString()
that denotes the input's EObject
domain
- A TransactionalEditingDomain
which contains the
ResourceSet
. Unless disposeEditingDomain
is set, the caller is responsible for disposing this instance
of the domain when it is no longer needed!providerId
- A String
which holds the diagram type id. When it is
null, it is set later in DiagramEditorInternal
disposeEditingDomain
- If set to true
this instance of
DiagramEditorInput
will on dispose care about
disposing the passed TransactionalEditingDomain
as
well. If false
is passed the caller (or rather
the creator of the domain needs to care about that.
java.lang.IllegalArgumentException
- if uriString
parameter is null domain
is no
IWorkspaceCommandStack
URI
public DiagramEditorInput(URI diagramUri, TransactionalEditingDomain domain, java.lang.String providerId)
DiagramEditorInput
out of a URI
string and
a transactional editing domain. For resolving the URI
to an
EObject
its ResourceSet
is used. IWorkspaceCommandStack
as the used command stack. URI
string and a transactional editing domain. For resolving
the URI
to an EObject
its ResourceSet
is used.
The ResourceSet of the editing domain must have been already set from
outside. A diagram type provider ID is hold in this class.
diagramUri
- a URI
that denotes the input's EObject
domain
- A TransactionalEditingDomain
which contains the
ResourceSet
. Note that the caller is responsible for
disposing this instance of the domain when it is no longer
needed!providerId
- A String
which holds the diagram type id. When it is
null, it is set later in DiagramEditorInternal
java.lang.IllegalArgumentException
- if uri
parameter is null domain
is no
IWorkspaceCommandStack
#DiagramEditorInput(String, TransactionalEditingDomain)
,
URI
public DiagramEditorInput(URI diagramUri, TransactionalEditingDomain domain, java.lang.String providerId, boolean disposeEditingDomain)
DiagramEditorInput
out of a URI
string and
a transactional editing domain. For resolving the URI
to an
EObject
its ResourceSet
is used. IWorkspaceCommandStack
as the used command stack. URI
string and a transactional editing domain. For resolving
the URI
to an EObject
its ResourceSet
is used.
The ResourceSet of the editing domain must have been already set from
outside. A diagram type provider ID is hold in this class.
diagramUri
- a URI
that denotes the input's EObject
domain
- A TransactionalEditingDomain
which contains the
ResourceSet
. Unless disposeEditingDomain
is set, the caller is responsible for disposing this instance
of the domain when it is no longer needed!providerId
- A String
which holds the diagram type id. When it is
null, it is set later in DiagramEditorInternal
disposeEditingDomain
- If set to true
this instance of
DiagramEditorInput
will on dispose care about
disposing the passed TransactionalEditingDomain
as
well. If false
is passed the caller (or rather
the creator of the domain needs to care about that.
java.lang.IllegalArgumentException
- if uri
parameter is null domain
is no
IWorkspaceCommandStack
#DiagramEditorInput(String, TransactionalEditingDomain)
,
URI
Method Detail |
---|
public static DiagramEditorInput createEditorInput(Diagram diagram, TransactionalEditingDomain domain, java.lang.String providerId, boolean disposeEditingDomain)
DiagramEditorInput
with a self created
TransactionalEditingDomain editing domain, which must be disposed later
on. IWorkspaceCommandStack
as the used command stack.
diagram
- A Diagram
domain
- A TransactionalEditingDomain
which contains the
ResourceSet
providerId
- A String
which holds the diagram type id.disposeEditingDomain
- If set to true
the created instance of
DiagramEditorInput
will on dispose care about
disposing the passed TransactionalEditingDomain
as
well. If false
is passed the caller (or rather
the creator of the domain needs to care about that.
DiagramEditorInput
editor inputpublic Diagram getDiagram()
public java.lang.String getProviderId()
public void setProviderId(java.lang.String providerId)
providerId
- The providerId to set.public java.lang.String getFactoryId()
DiagramEditorInput
s from
mementos.
public void dispose()
public ImageDescriptor getImageDescriptor()
null
.public java.lang.String getName()
URI
stringgetLiveName()
protected boolean hasName()
true
in case a name is set, false
in
name is null
.protected void setName(java.lang.String name)
name
- The name to set.public java.lang.String getToolTipText()
URI
stringgetLiveToolTipText()
protected java.lang.String getLiveName()
Diagram
, when possible.
Otherwise it tries to get a human readable name from the EObject
(retrieved via its URI) of the editor input.
null
to indicate that a it can currently not be
obtained.IEditorInput#getName()
,
getLiveName()
protected java.lang.String getLiveToolTipText()
Diagram
object, when
possible. Otherwise it tries to return the object's live name and type.
null
to indicate that a it can currently not be
obtained.IEditorInput#getToolTipText()
public java.lang.Object getAdapter(java.lang.Class adapter)
URI
adapter
- The adapter class to look up
null
if
this object does not have an adapter for the given classpublic void saveState(IMemento memento)
URI
string, object name and provider ID to the given
IMemento
.
memento
- The memeto to store the information inprivate void setEditorEditingDomain(TransactionalEditingDomain editingDomain)
TransactionalEditingDomain
to its input. The resourceSet of the
TransactionalEditingDomain is needed on requests to resolve the stored
uriName
.
editingDomain
- the TransactionalEditingDomain
to set
java.lang.IllegalArgumentException
- if editingDomain
parameter is nullgetEditingDomain()
public final EObject getEObject()
null
if no such object can be
obtained, e.g. if the input's editor is not yet initialised.public final java.lang.String getUriString()
URI
string this input and its editors operate onpublic boolean exists()
Note: The editor gets only restored, when true
is returned.
true
if the input's state denotes a living EMF
object public IPersistableElement getPersistable()
private EObject getEObject(java.lang.Class<EObject> adapter)
Class
object a sub class or sub interface of the class
defined by adapter
- null
otherwise. The
implementation also checks composite children.
adapter
-
private URI getUri()
URI
or null
in case of failuresprivate TransactionalEditingDomain getEditingDomain()
TransactionalEditingDomain
or
null
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- The object to compare this instance with.
true
if the represented objects are the samepublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
private URI createNormalizedUri()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |