|
||||||||||
| 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 String |
KEY_OBJECT_NAME
The memento key for the stored object name |
static String |
KEY_PROVIDER_ID
The memento key for the ID of the diagram type provider. |
static String |
KEY_URI
The memento key for the stored URI string |
private String |
name
The cached input name (e.g. |
private URI |
normalizedUri
The stored URI in normalized form. |
private String |
providerId
The ID of the diagram type provider. |
private String |
tooltip
The cached input tooltip |
private String |
uriName
The stored URI string |
| Constructor Summary | |
|---|---|
DiagramEditorInput(String diagramUriString,
TransactionalEditingDomain domain,
String providerId)
Creates a new DiagramEditorInput out of a URI string and
a transactional editing domain. |
|
DiagramEditorInput(String diagramUriString,
TransactionalEditingDomain domain,
String providerId,
boolean disposeEditingDomain)
Creates a new DiagramEditorInput out of a URI string and
a transactional editing domain. |
|
DiagramEditorInput(URI diagramUri,
TransactionalEditingDomain domain,
String providerId)
Creates a new DiagramEditorInput out of a URI string and
a transactional editing domain. |
|
DiagramEditorInput(URI diagramUri,
TransactionalEditingDomain domain,
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,
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(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. |
Object |
getAdapter(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(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. |
String |
getFactoryId()
Returns the factory ID for creating DiagramEditorInputs from
mementos. |
ImageDescriptor |
getImageDescriptor()
|
protected String |
getLiveName()
Returns a name for the input from the Diagram, when possible. |
protected String |
getLiveToolTipText()
Returns a tooltip for the input from the Diagram object, when
possible. |
String |
getName()
|
IPersistableElement |
getPersistable()
|
String |
getProviderId()
Returns the diagram type provider id. |
String |
getToolTipText()
|
private URI |
getUri()
|
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(String name)
Sets the name for this instance. |
void |
setProviderId(String providerId)
Sets the diagram type provider id. |
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 String KEY_URI
URI string
public static final String KEY_OBJECT_NAME
public static String KEY_PROVIDER_ID
private final String uriName
URI string
private URI normalizedUri
URI in normalized form.
private String providerId
private String name
EObject)
getLiveName()private 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(String diagramUriString,
TransactionalEditingDomain domain,
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 EObjectdomain - 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
IllegalArgumentException - if uriString parameter is null domain is no
IWorkspaceCommandStackURI
public DiagramEditorInput(String diagramUriString,
TransactionalEditingDomain domain,
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 EObjectdomain - 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 DiagramEditorInternaldisposeEditingDomain - 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.
IllegalArgumentException - if uriString parameter is null domain is no
IWorkspaceCommandStackURI
public DiagramEditorInput(URI diagramUri,
TransactionalEditingDomain domain,
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 EObjectdomain - 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
IllegalArgumentException - if uri parameter is null domain is no
IWorkspaceCommandStack#DiagramEditorInput(String, TransactionalEditingDomain),
URI
public DiagramEditorInput(URI diagramUri,
TransactionalEditingDomain domain,
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 EObjectdomain - 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 DiagramEditorInternaldisposeEditingDomain - 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.
IllegalArgumentException - if uri parameter is null domain is no
IWorkspaceCommandStack#DiagramEditorInput(String, TransactionalEditingDomain),
URI| Method Detail |
|---|
public static DiagramEditorInput createEditorInput(Diagram diagram,
TransactionalEditingDomain domain,
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 Diagramdomain - A TransactionalEditingDomain which contains the
ResourceSetproviderId - 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 String getProviderId()
public void setProviderId(String providerId)
providerId - The providerId to set.public String getFactoryId()
DiagramEditorInputs from
mementos.
public void dispose()
public ImageDescriptor getImageDescriptor()
null.public String getName()
URI stringgetLiveName()protected boolean hasName()
true in case a name is set, false in
name is null.protected void setName(String name)
name - The name to set.public String getToolTipText()
URI stringgetLiveToolTipText()protected 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 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 Object getAdapter(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
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 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(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
nullpublic boolean equals(Object obj)
equals in class Objectobj - The object to compare this instance with.
true if the represented objects are the samepublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Objectprivate URI createNormalizedUri()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||