Package org.eclipse.graphiti.ui.internal.services.impl

## Class EmfService

- java.lang.Object
- - org.eclipse.graphiti.ui.internal.services.impl.EmfService

All Implemented Interfaces:
  `IEmfService`, `IEmfService`

    public class EmfService
    extends java.lang.Object
    implements IEmfService

### Constructor Summary

Constructors
`EmfService()`

### Method Summary

All Methods Instance Methods Concrete Methods
`org.eclipse.emf.transaction.TransactionalEditingDomain` `createResourceSetAndEditingDomain()` Creates a `TransactionalEditingDomain` with a `ResourceSet` resource set and a `IWorkspaceCommandStack` command stack.
`Diagram` `getDiagramFromFile​(org.eclipse.core.resources.IFile file, org.eclipse.emf.ecore.resource.ResourceSet resourceSet)` If given file is a valid emf resource and it contains a diagram as first root element, this methods return the diagram.
`org.eclipse.emf.ecore.EObject` `getEObject​(java.lang.Object object)` Tries to convert the given object to a `EObject` using `#adaptObject(Object, Class)`, unwrapping an `IStructuredSelection`.
`org.eclipse.core.resources.IFile` `getFile​(org.eclipse.emf.common.util.URI uri)` Returns the Eclipse file for the given `URI`.
`org.eclipse.core.resources.IFile` `getFile​(org.eclipse.emf.ecore.EObject object)` Returns the Eclipse file for the given `EObject`'s `Resource` .
`protected org.eclipse.core.resources.IFile` `getFileForUriString​(java.lang.String uriString)`
`org.eclipse.emf.common.util.URI` `getFileURI​(org.eclipse.core.resources.IFile file)` Retrieves the workspace-local string location of the given `IFile`, constructs a potentially normalized platform resource `URI` from it and returns it.
`java.lang.String` `getObjectName​(java.lang.Object obj)` Returns the human readable name of a given object or the EMF id if no name can be found.
`org.eclipse.emf.common.util.URI` `mapDiagramFileUriToDiagramUri​(org.eclipse.emf.common.util.URI diagramFileUri)` Maps the fileURI to an URI which points directly to the Diagram Object.
`java.lang.StringBuilder` `toString​(org.eclipse.emf.ecore.EObject o, java.lang.StringBuilder result)` Creates an extended string presentation of the given `EObject`, including its type and attributes

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### EmfService

    public EmfService()

### Method Detail

#### getObjectName

    public java.lang.String getObjectName​(java.lang.Object obj)

Description copied from interface: `IEmfService`
Returns the human readable name of a given object or the EMF id if no name can be found. The method tries to access a modeled attribute "name" or "id" in this order. If no attribute with this name is modeled, the first attribute whose value is a String or `TranslatableTextFragment` is returned, otherwise `null` .

Specified by:
  `getObjectName` in interface `IEmfService`
Parameters:
  `obj` - the object to get a name for
Returns:
  the value of attribute "name" or the EMF id if no attribute "name" exists

#### getEObject

    public org.eclipse.emf.ecore.EObject getEObject​(java.lang.Object object)

Description copied from interface: `IEmfService`
Tries to convert the given object to a `EObject`

- using `#adaptObject(Object, Class)`,
- unwrapping an `IStructuredSelection`.

Specified by:
  `getEObject` in interface `IEmfService`
Parameters:
  `object` - the object to convert
Returns:
  the target object or `null`
See Also:
  `IEmfService.getEObject(Object)`

#### getFile

    public org.eclipse.core.resources.IFile getFile​(org.eclipse.emf.ecore.EObject object)

Description copied from interface: `IEmfService`
Returns the Eclipse file for the given `EObject`'s `Resource` . Note that the file is `null` for objects in

- archives,
- closed projects,
- not yet persisted resources or not yet persisted EObjects in already persisted resources. In this respect this methods behaves asymmetric to the handle-only resource APIs like `IProject.getFile(String)`.

Specified by:
  `getFile` in interface `IEmfService`
Parameters:
  `object` - the model object to get the file for
Returns:
  the partition file or `null` under the mentioned circumstances
See Also:
  `IEmfService.getFile(URI)`

#### getFile

    public org.eclipse.core.resources.IFile getFile​(org.eclipse.emf.common.util.URI uri)

Description copied from interface: `IEmfService`
Returns the Eclipse file for the given `URI`. Note that the file is `null` for objects in

- archives,
- closed projects,
- not yet persisted resources or not yet persisted EObjects in already persisted resources. In this respect this methods behaves asymmetric to the handle-only resource APIs like `IProject.getFile(String)`.

Specified by:
  `getFile` in interface `IEmfService`
Parameters:
  `uri` - the URI to get the file for
Returns:
  the file or `null` under the mentioned circumstances
See Also:
  `IEmfService.getFile(EObject)`

#### getFileForUriString

    protected org.eclipse.core.resources.IFile getFileForUriString​(java.lang.String uriString)

#### toString

    public java.lang.StringBuilder toString​(org.eclipse.emf.ecore.EObject o,
                                            java.lang.StringBuilder result)

Description copied from interface: `IEmfService`
Creates an extended string presentation of the given `EObject`, including its type and attributes

Specified by:
  `toString` in interface `IEmfService`
Parameters:
  `o` - the object to create a string presentation for
  `result` - the string buffer to store the result into
Returns:
  the same string buffer as `result` per convenience
See Also:
  `#toString(EObject)`

#### getDiagramFromFile

    public Diagram getDiagramFromFile​(org.eclipse.core.resources.IFile file,
                                      org.eclipse.emf.ecore.resource.ResourceSet resourceSet)

Description copied from interface: `IEmfService`
If given file is a valid emf resource and it contains a diagram as first root element, this methods return the diagram. Otherwise this method returns null.

Specified by:
  `getDiagramFromFile` in interface `IEmfService`
Parameters:
  `file` - a valid emf (diagram) resource
Returns:
  diagram or null

#### getFileURI

    public org.eclipse.emf.common.util.URI getFileURI​(org.eclipse.core.resources.IFile file)

Description copied from interface: `IEmfService`
Retrieves the workspace-local string location of the given `IFile`, constructs a potentially normalized platform resource `URI` from it and returns it.

Specified by:
  `getFileURI` in interface `IEmfService`
Parameters:
  `file` - The file to construct the URI for
Returns:
  The platform resource URI for the given file.

#### mapDiagramFileUriToDiagramUri

    public org.eclipse.emf.common.util.URI mapDiagramFileUriToDiagramUri​(org.eclipse.emf.common.util.URI diagramFileUri)

Description copied from interface: `IEmfService`
Maps the fileURI to an URI which points directly to the Diagram Object. This methods assumes the Diagram object is the first root object in the given file.

Specified by:
  `mapDiagramFileUriToDiagramUri` in interface `IEmfService`
Parameters:
  `diagramFileUri` - URI of the diagramFile
Returns:
  URI of the diagram

#### createResourceSetAndEditingDomain

    public org.eclipse.emf.transaction.TransactionalEditingDomain createResourceSetAndEditingDomain()

Description copied from interface: `IEmfService`
Creates a `TransactionalEditingDomain` with a `ResourceSet` resource set and a `IWorkspaceCommandStack` command stack.

Specified by:
  `createResourceSetAndEditingDomain` in interface `IEmfService`
Returns:
  a `TransactionalEditingDomain` editing domain