public final class EcorePlatformUtil
extends java.lang.Object
Provides a set of methods allowing to handle resources, to load or save models, to retrieve a file from a resource (and vice-versa), etc.
Modifier and Type | Method and Description |
---|---|
static void |
addNewModelResource(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.core.runtime.IPath path,
java.lang.String contentTypeId,
org.eclipse.emf.ecore.EObject content,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor)
Add a new model
Resource to the provided TransactionalEditingDomain , created by using
content as basis for the containing model. |
static void |
addNewModelResources(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
java.util.Collection<ModelResourceDescriptor> modelResourceDescriptors,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor)
* Add a new
resource s described by modelResourceDescriptors to the provided
editingDomain . |
static boolean |
areModelsLoaded(java.util.Collection<IModelDescriptor> modelDescriptors)
Tests if the persisted files of the given collection of
model Descriptor s are loaded
completely. |
static org.eclipse.core.runtime.IPath |
convertToAbsoluteFileLocation(org.eclipse.core.runtime.IPath path)
Converts the given
path into an absolute file location. |
static org.eclipse.core.runtime.IPath |
createAbsoluteFileLocation(org.eclipse.emf.common.util.URI uri)
Converts the given
uri into an absolute file location, i.e. into a path. |
static org.eclipse.emf.common.util.URI |
createAbsoluteFileURI(org.eclipse.core.runtime.IPath path)
Converts the given
path into an absolute file URI. |
static org.eclipse.core.runtime.IPath |
createPath(org.eclipse.emf.common.util.URI uri) |
static org.eclipse.core.runtime.jobs.ISchedulingRule |
createSaveNewSchedulingRule(java.util.Collection<ModelResourceDescriptor> modelResourceDescriptors) |
static org.eclipse.core.runtime.jobs.ISchedulingRule |
createSaveSchedulingRule(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources)
Creates the scheduling rule that are required for saving the specified
resource s. |
static org.eclipse.core.runtime.jobs.ISchedulingRule |
createSaveSchedulingRule(org.eclipse.emf.ecore.resource.Resource resource)
Creates the scheduling rule that is required for saving the specified
resource . |
static org.eclipse.emf.common.util.URI |
createURI(org.eclipse.core.runtime.IPath path)
Converts given
path into a workspace-relative platform resource URI if possible or an
absolute file URI otherwise. |
static org.eclipse.emf.ecore.EObject |
getEObject(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.emf.common.util.URI uri)
Retrieves the model
object referenced by provided URI from the resource set of given editing domain . |
static org.eclipse.emf.ecore.EObject |
getEObject(org.eclipse.emf.common.util.URI uri)
Retrieves the model
object referenced by provided URI from the resource set of the editing domain the URI is mapped to. |
static org.eclipse.core.resources.IFile |
getFile(org.eclipse.emf.ecore.EObject eObject)
Retrieves the file owning to the given EObject.
|
static org.eclipse.core.resources.IFile |
getFile(org.eclipse.emf.ecore.util.FeatureMap.Entry entry)
Retrieves the file matching the given
entry . |
static org.eclipse.core.resources.IFile |
getFile(org.eclipse.emf.edit.provider.IWrapperItemProvider provider)
Retrieves the file owning the given
IWrapperItemProvider.
|
static org.eclipse.core.resources.IFile |
getFile(java.lang.Object object)
Returns the file corresponding to the specified object.
|
static org.eclipse.core.resources.IFile |
getFile(org.eclipse.emf.ecore.resource.Resource resource)
Retrieves the
file corresponding to the given resource . |
static org.eclipse.core.resources.IFile |
getFile(TransientItemProvider provider)
Retrieves the file owning the given TransientItemProvider.
|
static org.eclipse.core.resources.IFile |
getFile(org.eclipse.emf.common.util.URI uri)
Retrieves the file corresponding to the given URI.
|
static org.eclipse.emf.ecore.EObject |
getModelRoot(org.eclipse.core.resources.IFile file)
Deprecated.
Use
getResource(IFile) or getEObject(URI) instead. |
static org.eclipse.emf.ecore.EObject |
getModelRoot(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.core.resources.IFile file)
Deprecated.
Use
getResource(IFile) or getEObject(TransactionalEditingDomain, URI) instead. |
static org.eclipse.emf.ecore.resource.Resource |
getResource(org.eclipse.emf.ecore.EObject eObject)
Retrieves the resource corresponding to the given
object . |
static org.eclipse.emf.ecore.resource.Resource |
getResource(org.eclipse.emf.ecore.util.FeatureMap.Entry entry)
Retrieves the resource matching the given
entry . |
static org.eclipse.emf.ecore.resource.Resource |
getResource(org.eclipse.core.resources.IFile file)
Retrieves the resource corresponding to the given
file . |
static org.eclipse.emf.ecore.resource.Resource |
getResource(org.eclipse.emf.edit.provider.IWrapperItemProvider provider)
Retrieves the resource owning the given
provider . |
static org.eclipse.emf.ecore.resource.Resource |
getResource(java.lang.Object object)
Returns the resource corresponding to the specified object.
|
static org.eclipse.emf.ecore.resource.Resource |
getResource(TransientItemProvider provider)
Retrieves the resource owning the given
provider . |
static org.eclipse.emf.ecore.resource.Resource |
getResource(org.eclipse.emf.common.util.URI uri)
Returns the resource corresponding to the specified
uri . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInModel(org.eclipse.emf.ecore.EObject contextEObject,
boolean includeReferencedModels)
Returns all resources owned by the
model descriptor of the context eobject . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInModel(org.eclipse.emf.ecore.util.FeatureMap.Entry contextEntry,
boolean includeReferencedModels)
Returns all resources owned by the
model descriptor of the context
feature map entry . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInModel(org.eclipse.core.resources.IFile contextFile,
boolean includeReferencedModels)
Returns all resources owned by the
model descriptor of the context file . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInModel(IModelDescriptor modelDescriptor,
boolean includeReferencedModels)
Returns all resources owned by the
model descriptor provided in argument . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInModel(org.eclipse.emf.edit.provider.IWrapperItemProvider contextProvider,
boolean includeReferencedModels)
Returns all resources owned by the
model descriptor of the context
provider . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInModel(java.lang.Object contextObject,
boolean includeReferencedModels)
Returns all resources owned by the
model descriptor of the contextObject. |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInModel(org.eclipse.emf.ecore.resource.Resource contextResource,
boolean includeReferencedModels)
Returns all resources owned by the
model descriptor of the context resource .If the given contextResource doesn't belong to any model
descriptor , resources in contextResourceSet will be returned |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInModel(TransientItemProvider contextProvider,
boolean includeReferencedModels)
Returns all resources owned by the
model descriptor of the context
provider . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInModel(org.eclipse.emf.common.util.URI contextURI,
boolean includeReferencedModels)
Returns all resources owned by the
model descriptor of the context uri . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInModels(org.eclipse.core.resources.IContainer contextContainer,
IMetaModelDescriptor mmDescriptor,
boolean includeReferencedModels)
|
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInOtherModels(org.eclipse.emf.ecore.resource.Resource contextResource,
IMetaModelDescriptor otherMMDescriptor,
boolean includeReferencedModels)
Returns all resources owned by the
model descriptor s which are filtered by the
other meta model descriptor . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInScope(org.eclipse.emf.ecore.EObject contextEObject,
boolean includeReferencedScopes)
Returns all resources owned by the
model resource scope of the model descriptor of the context eObject . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInScope(org.eclipse.emf.ecore.util.FeatureMap.Entry contextEntry,
boolean includeReferencedScopes)
Returns all resources owned by the
model resource scope of the model descriptor of the context feature map entry . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInScope(org.eclipse.core.resources.IFile contextFile,
boolean includeReferencedScopes)
Returns all resources owned by the
model resource scope of the model descriptor of the context file . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInScope(IModelDescriptor modelDescriptor,
boolean includeReferencedScopes)
Returns all resources owned by the
model resource scope of the model descriptor provided in argument . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInScope(org.eclipse.emf.edit.provider.IWrapperItemProvider contextProvider,
boolean includeReferencedScopes)
Returns all resources owned by the
model resource scope of the model descriptor of the context provider . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInScope(java.lang.Object contextObject,
boolean includeReferencedScopes)
Returns all resources owned by the
model resource scope of the contextObject. |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInScope(org.eclipse.emf.ecore.resource.Resource contextResource,
boolean includeReferencedScopes)
Returns all resources owned by the
model resource scope of the model descriptor of the context resource .If the given contextResource does not
belong to any model descriptor , resources in context ResourceSet will be
returned. |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInScope(TransientItemProvider contextProvider,
boolean includeReferencedScopes)
Returns all resources owned by the
model resource scope of the model descriptor of the context provider . |
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInScope(org.eclipse.emf.common.util.URI contextURI,
boolean includeReferencedScopes)
|
static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> |
getResourcesInScopes(org.eclipse.core.resources.IContainer contextContainer,
boolean includeReferencedScopes)
Returns all resources owned by the
model resource scope s of the model descriptor s of the context container . |
static boolean |
isFileLoaded(org.eclipse.core.resources.IFile file)
Tests if the given
file is loaded in the resource set of some
editingDomain . |
static boolean |
isFileLoaded(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.core.resources.IFile file)
Tests if the given
file is loaded in the resource set of the given
editingDomain . |
static boolean |
isModelLoaded(IModelDescriptor modelDescriptor)
Tests if the persisted files of the given
model Descriptor are loaded completely. |
static boolean |
isResourceLoaded(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.emf.ecore.resource.Resource resource)
Tests if the given
resource is loaded in the resource set of given
editingDomain . |
static org.eclipse.emf.ecore.EObject |
loadEObject(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.emf.common.util.URI uri)
Retrieves the model
object referenced by provided URI from the resource set of given editing domain . |
static org.eclipse.emf.ecore.EObject |
loadEObject(org.eclipse.emf.common.util.URI uri)
Retrieves the model
object referenced by provided URI from the resource set of the editing domain the URI is mapped to. |
static void |
loadModel(IModelDescriptor modelDescriptor,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor)
Loads all persisted resources that belong to the model specified by given
modelDescriptor . |
static org.eclipse.emf.ecore.EObject |
loadModelRoot(org.eclipse.core.resources.IFile file)
Deprecated.
Use
loadModelRoot(IFile, Map) instead. |
static org.eclipse.emf.ecore.EObject |
loadModelRoot(org.eclipse.core.resources.IFile file,
java.util.Map<?,?> options)
Deprecated.
Use
loadResource(IFile, Map) or loadEObject(URI) instead. |
static org.eclipse.emf.ecore.EObject |
loadModelRoot(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.core.resources.IFile file)
Deprecated.
|
static org.eclipse.emf.ecore.EObject |
loadModelRoot(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.core.resources.IFile file,
java.util.Map<?,?> options)
Deprecated.
|
static void |
loadModels(java.util.Collection<IModelDescriptor> modelDescriptors,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor)
Loads all persisted resources that belong to the models specified by given
modelDescriptors . |
static org.eclipse.emf.ecore.resource.Resource |
loadResource(org.eclipse.core.resources.IFile file,
java.util.Map<?,?> options)
Loads the
resource referred to by given file . |
static org.eclipse.emf.ecore.resource.Resource |
loadResource(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.core.resources.IFile file,
java.util.Map<?,?> options)
Loads the
resource referred to by given file into the resource
set of given editing domain . |
static java.lang.String |
readModelNamespace(org.eclipse.core.resources.IFile file)
Reads the model namespace (i.e.
|
static java.util.Collection<java.lang.String> |
readRootElementComments(org.eclipse.core.resources.IFile file)
Retrieves the XML comments located above the root element in given
file . |
static java.lang.String |
readTargetNamespace(org.eclipse.core.resources.IFile file)
Reads the target namespace of given
file . |
static java.lang.String |
readTargetNamespace(org.eclipse.core.resources.IFile file,
java.lang.String... targetNamespaceExcludePatterns) |
static void |
saveModel(java.lang.Object contextObject,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor)
Saves all modified resources of the model behind the specified object (i.e. all resources in the context
of the given object).
|
static void |
saveModel(java.lang.Object contextObject,
java.util.Map<?,?> options,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor)
Saves all modified, writable models from a given context object.
|
static void |
saveNewModelResource(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.core.runtime.IPath path,
java.lang.String contentTypeId,
org.eclipse.emf.ecore.EObject content,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor) |
static void |
saveNewModelResource(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.core.runtime.IPath path,
java.lang.String contentTypeId,
org.eclipse.emf.ecore.EObject content,
java.util.Map<?,?> options,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor) |
static void |
saveNewModelResources(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
java.util.Collection<ModelResourceDescriptor> modelResourceDescriptors,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor) |
static void |
saveNewModelResources(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
java.util.Collection<ModelResourceDescriptor> modelResourceDescriptors,
java.util.Map<?,?> options,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor) |
static void |
saveProject(org.eclipse.core.resources.IProject project,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor)
Saves all modified
resource s of all models behind the specified project
including all referenced projects ( i.e. all resources in the context of the given project). |
static void |
saveProject(org.eclipse.core.resources.IProject project,
java.util.Map<?,?> options,
boolean async,
org.eclipse.core.runtime.IProgressMonitor monitor)
Saves all modified
Resource s of all models behind the specified project including all referenced
IProject s ( i.e. all resources in the context of the given project). |
static void |
unloadAllResources(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.core.runtime.IProgressMonitor monitor)
Unloads all resources from given editing domain
inside a read-only transaction.
|
static void |
unloadFile(org.eclipse.core.resources.IFile file)
Unloads the model contained in given
file . |
static void |
unloadFile(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
org.eclipse.core.resources.IFile file)
Unloads the model contained in given file from given editing domain.
|
static void |
unloadFiles(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
java.util.Collection<org.eclipse.core.resources.IFile> files,
boolean memoryOptimized,
org.eclipse.core.runtime.IProgressMonitor monitor)
Unloads the models contained in given files from given editing domain inside a read-only transaction.
|
static void |
unloadResources(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources,
boolean memoryOptimized,
org.eclipse.core.runtime.IProgressMonitor monitor)
Unloads the specified resources from given editing
domain inside a read-only transaction.
|
static void |
validate(org.eclipse.core.resources.IFile file,
java.net.URL schemaURL)
Parses given
file and validates it against XSD schema with specified url . |
public static org.eclipse.emf.common.util.URI createURI(org.eclipse.core.runtime.IPath path)
path
into a workspace-relative platform resource URI
if possible or an
absolute file URI
otherwise. Returns given IPath
as indeterminate (scheme-less) URI
if
none of both is possible.path
- The path
for which to create the URI
; must not be null
.URI
or absolute file URI
for given path
or given IPath
as indeterminate (scheme-less) URI
otherwise.public static org.eclipse.core.runtime.IPath createPath(org.eclipse.emf.common.util.URI uri)
public static org.eclipse.emf.common.util.URI createAbsoluteFileURI(org.eclipse.core.runtime.IPath path)
path
into an absolute file URI.path
- The path
for which an URI is to be created.path
or an URI
corresponding to
given path
as is if no conversion is possible.public static org.eclipse.core.runtime.IPath createAbsoluteFileLocation(org.eclipse.emf.common.util.URI uri)
uri
into an absolute file location, i.e. into a path.uri
- The file URI for which an absolute file location must be created.uri
.public static org.eclipse.core.runtime.IPath convertToAbsoluteFileLocation(org.eclipse.core.runtime.IPath path)
path
into an absolute file location.path
- The file path for which an absolute file location must be created.path
.public static java.lang.String readModelNamespace(org.eclipse.core.resources.IFile file)
file
. Returns a meaningful result only if
the file
is an XML document.file
- The file
to investigate.file
or null
if the file is
either a non-XML file or an XML file which is not well-formed or has no model namespace.public static java.lang.String readTargetNamespace(org.eclipse.core.resources.IFile file)
file
. Returns a meaningful result only if given file
is an XML document.file
- The file
to investigate.file
or null
if the file
is either a not an XML file or an XML file which is not well-formed or has no target namespace.public static java.lang.String readTargetNamespace(org.eclipse.core.resources.IFile file, java.lang.String... targetNamespaceExcludePatterns)
file
- targetNamespaceExcludePatterns
- public static java.util.Collection<java.lang.String> readRootElementComments(org.eclipse.core.resources.IFile file)
file
. Returns a meaningful
result only if given file
is an XML document.file
- The file
to investigate.@Deprecated public static org.eclipse.emf.ecore.EObject getModelRoot(org.eclipse.core.resources.IFile file)
root object
of the model contained in given file
. Returns
null
if the file
has not been loaded yet or contains no or multiple root objects.file
- The file
containing the model.root object
of the model in given file
or null
if the
file
has not been loaded yet or contains no or multiple root objects.getModelRoot(TransactionalEditingDomain, IFile)
@Deprecated public static org.eclipse.emf.ecore.EObject getModelRoot(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.core.resources.IFile file)
root object
of the model contained in given file
using given
editing domain
. Returns null
if the file
has not
been loaded yet or contains no or multiple root objects.editingDomain
- The editing domain the specified file
belongs
to; must not be null
.file
- The file containing the model; must not be null
.file
or null
if the
file has not been loaded yet or contains no or multiple root objects.@Deprecated public static org.eclipse.emf.ecore.EObject loadModelRoot(org.eclipse.core.resources.IFile file)
loadModelRoot(IFile, Map)
instead.file
using default load options
and returns its root object
. Returns null
if the file
is empty.
Note: Calling this method involves retrieving the editing domain
behind the
given file. In case that the file
has not been loaded yet this is done by analyzing the its content
type. However, if it happens that the file
's content type is retrieved for the very first time this
operation is somewhat costly in terms of runtime performance. Therefore, when the
editing domain
is already available prior to calling this method it is
recommended to use loadModelRoot(TransactionalEditingDomain, IFile)
instead.
file
- The file
containing the model.root object
of the model in given file
or null
if the
file
is empty.EcoreResourceUtil.getDefaultLoadOptions()
,
loadModelRoot(TransactionalEditingDomain, IFile)
@Deprecated public static org.eclipse.emf.ecore.EObject loadModelRoot(org.eclipse.core.resources.IFile file, java.util.Map<?,?> options)
file
using given load options and returns its root object
. Returns null
if the file
contains no or multiple root objects..
Note: Calling this method involves retrieving the editing domain
behind the
given file. In case that the file
has not been loaded yet this is done by analyzing the its content
type. However, if it happens that the file
's content type is retrieved for the very first time this
operation is somewhat costly in terms of runtime performance. Therefore, when the
editing domain
is already available prior to calling this method it is
recommended to use loadModelRoot(TransactionalEditingDomain, IFile, Map)
instead.
file
- The file
containing the model.options
- The options to be used for loading the model.root object
of the model in given file
or null
if the
file
contains no or multiple root objects.loadModelRoot(TransactionalEditingDomain, IFile, Map)
@Deprecated public static org.eclipse.emf.ecore.EObject loadModelRoot(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.core.resources.IFile file)
loadModelRoot(TransactionalEditingDomain, IFile, Map)
instead.file
into given editing
domain
using default load options
and returns its
root object
. Returns null
if the file
contains no or multiple root
objects.file
- The file
containing the model.editingDomain
- The editing domain
the file
belongs to.options
- The options to be used for loading the model.root object
of the model in given file
or null
if the
file
contains no or multiple root objects.EcoreResourceUtil.getDefaultLoadOptions()
@Deprecated public static org.eclipse.emf.ecore.EObject loadModelRoot(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.core.resources.IFile file, java.util.Map<?,?> options)
loadResource(TransactionalEditingDomain, IFile, Map)
or
loadEObject(TransactionalEditingDomain, URI)
instead.file
into given editing
domain
using given load options and returns its root object
. Returns null
if the
file
contains no or multiple root objects.file
- The file
containing the model; must not be null
.editingDomain
- The editing domain
the file
belongs to; must not be
null
.options
- The options to be used for loading the model.root object
of the model in given file
or null
if the
file
contains no or multiple root objects.public static org.eclipse.emf.ecore.EObject getEObject(org.eclipse.emf.common.util.URI uri)
object
referenced by provided URI
from the resource set
of the editing domain
the URI is mapped to. Returns
null
if the resource
containing the model object referenced by the URI has not yet
been loaded into the editing domain's resource set.uri
- The URI that identifies the model object to be retrieved.null
if referenced model object does not
exist in underlying resource or the latter has not yet been loaded into the editing domain's resource
set.public static org.eclipse.emf.ecore.EObject getEObject(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.emf.common.util.URI uri)
object
referenced by provided URI
from the resource set
of given editing domain
. Returns null
if the
resource
containing the model object referenced by the URI has not yet been loaded into the
editing domain's resource set.editingDomain
- The editing domain from the resource set of which the model object is to be retrieved.uri
- The URI that identifies the model object to be retrieved.null
if the referenced model object does not exist in underlying resource or the latter has not yet been
loaded into the editing domain's resource set.public static org.eclipse.emf.ecore.EObject loadEObject(org.eclipse.emf.common.util.URI uri)
object
referenced by provided URI
from the resource set
of the editing domain
the URI is mapped to. Loads the
resource
containing the model object referenced by the URI into the editing domain's resource
set if this has not yet been done.uri
- The URI that identifies the model object to be retrieved.null
if referenced model object does not
exist in underlying resource.public static org.eclipse.emf.ecore.EObject loadEObject(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.emf.common.util.URI uri)
object
referenced by provided URI
from the resource set
of given editing domain
. Loads the resource
containing the model object referenced by the URI into the editing domain's resource set if this has not yet been
done.editingDomain
- The editing domain from the resource set of which the model object is to be retrieved.uri
- The URI that identifies the model object to be retrieved.null
if referenced model object does not exist in underlying resource.public static org.eclipse.emf.ecore.resource.Resource getResource(java.lang.Object object)
The supported object types are:
If the type of the specified object does not belongs to that list of supported types, null
is
returned.
object
- The object from which a resource must be returned.public static org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.core.resources.IFile file)
file
.file
- The file whose resource
is to be returned.file
.public static org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.emf.common.util.URI uri)
uri
.uri
- The URI of the resource to return.uri
.public static org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.emf.ecore.EObject eObject)
object
.eObject
- The object whose resource
is to be returned.object
.public static org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.emf.edit.provider.IWrapperItemProvider provider)
provider
.
First retrieves the owner of the provider
; then, if owner is an EObject
returns its resource, else delegates to getResource(Object).
provider
- The IWrapperItemProvider whose resource must be returned.provider
; null
if that
provider is null
.public static org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.emf.ecore.util.FeatureMap.Entry entry)
entry
.
First unwraps the entry
; then, delegates to getResource(Object).
entry
- The FeatureMap.Entry whose underlying resource must be returned.entry
.public static org.eclipse.emf.ecore.resource.Resource getResource(TransientItemProvider provider)
provider
.
First retrieves the owner of the provider
; then, if owner is an
EObject returns its resource.
provider
- The TransientItemProvider whose resource must be returned.provider
; null
if that
provider is null
.public static org.eclipse.emf.ecore.resource.Resource loadResource(org.eclipse.core.resources.IFile file, java.util.Map<?,?> options)
resource
referred to by given file
.file
- The file from which the resource is to be loaded.options
- Optional custom load options to be used for loading the resource. May be set to null
if
not such are needed.loadResource(TransactionalEditingDomain, IFile, Map)
public static org.eclipse.emf.ecore.resource.Resource loadResource(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.core.resources.IFile file, java.util.Map<?,?> options)
resource
referred to by given file
into the resource
set
of given editing domain
.file
- The file from which the resource is to be loaded.editingDomain
- The editing domain into the resource set of which the file is to be loaded.options
- Optional custom load options to be used for loading the resource. May be set to null
if
not such are needed.loadResource(IFile, Map)
public static boolean isResourceLoaded(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.emf.ecore.resource.Resource resource)
resource
is loaded in the resource set
of given
editingDomain
.editingDomain
- The editing domain
with the resource set
to be
investigated.resource
- The resource
that may or not be loaded.true
if specified resource
is loaded in resource set
of
given editingDomain
; false
otherwise.public static void loadModel(IModelDescriptor modelDescriptor, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
modelDescriptor
.modelDescriptors
- The model
whose resources are to be loaded.async
- true
if this operation is required to be run asynchronously, or false
if
synchronous execution is desired.monitor
- A progress monitor
, or null
if progress reporting is not
desired.public static void loadModels(java.util.Collection<IModelDescriptor> modelDescriptors, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
modelDescriptors
.modelDescriptors
- The collection of model
s whose resources are to be loaded.async
- true
if this operation is required to be run asynchronously, or false
if
synchronous execution is desired.monitor
- A progress monitor
, or null
if progress reporting is not
desired.public static boolean isModelLoaded(IModelDescriptor modelDescriptor)
model Descriptor
are loaded completely.modelDescriptor
- The model Descriptor
that may or not be loaded.true
if the persisted files of the specified model Descriptor
are
all loaded; false
otherwise.public static boolean areModelsLoaded(java.util.Collection<IModelDescriptor> modelDescriptors)
model Descriptor
s are loaded
completely.modelDescriptors
- The collection of model Descriptor
s that may or not be loaded.true
if the persisted files of the specified collection of model
Descriptor
s are all loaded; false
otherwise.public static org.eclipse.core.resources.IFile getFile(java.lang.Object object)
The supported object types are:
object
- The object from which a file must be returned.public static org.eclipse.core.resources.IFile getFile(org.eclipse.emf.common.util.URI uri)
uri
- The URI of the file to return.uri
.public static org.eclipse.core.resources.IFile getFile(org.eclipse.emf.ecore.resource.Resource resource)
file
corresponding to the given resource
.resource
- The resource
for which the file is to be returned.resource
.public static org.eclipse.core.resources.IFile getFile(org.eclipse.emf.ecore.EObject eObject)
eObject
- The EObject whose file must be returned.eObject
.public static org.eclipse.core.resources.IFile getFile(org.eclipse.emf.edit.provider.IWrapperItemProvider provider)
First retrieves the owner of the provider
; then, if owner is an EObject
delegates to getFile(EObject) else delegates to getFile(Object).
provider
- The IWrapperItemProvider whose file must be returned.provider
; null
if that
provider is null
.public static org.eclipse.core.resources.IFile getFile(org.eclipse.emf.ecore.util.FeatureMap.Entry entry)
entry
.
First unwraps the entry
; then, delegates to getFile(Object).
entry
- The FeatureMap.Entry whose underlying file must be returned.entry
.public static org.eclipse.core.resources.IFile getFile(TransientItemProvider provider)
First retrieves the owner of the provider
; then, if owner is an
EObject delegates to getFile(EObject) else delegates to getFile(Object).
provider
- The TransientItemProvider whose file must be returned.provider
; null
if that
provider is null
.public static boolean isFileLoaded(org.eclipse.core.resources.IFile file)
file
is loaded in the resource set
of some
editingDomain
.file
- The file
that may or not be loaded.true
if specified file
is loaded in resource set
of some
editingDomain
; false
otherwise.public static boolean isFileLoaded(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.core.resources.IFile file)
file
is loaded in the resource set
of the given
editingDomain
.editingDomain
- The editing domain
with the resource set
to be
investigated.file
- The file
that may or not be loaded.true
if specified file
is loaded in resource set
of given
editingDomain
; false
otherwise.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInModel(java.lang.Object contextObject, boolean includeReferencedModels)
model descriptor
of the contextObject.contextObject
- The Object used to research resources in the model.includeReferencedModels
- Determines if the model descriptors
referenced by the context object's
model descriptor
must be considered for the research.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInModel(IModelDescriptor modelDescriptor, boolean includeReferencedModels)
model descriptor
provided in argument .modelDescriptor
- The model descriptor
used as context object for investigation.includeReferencedModels
- Determines if the model descriptors
referenced by the context
model descriptor
must be considered for the research.resource
s owned by the model descriptor
.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInModel(org.eclipse.core.resources.IFile contextFile, boolean includeReferencedModels)
model descriptor
of the context file
.
If the given file
doesn't belong to any model descriptor
, resources in
contextResourceSet
will be returnedcontextFile
- The file
used as context object for investigation.includeReferencedModels
- Determines if the model descriptors
referenced by the context file
's model descriptor
must be considered for the research.file
's model.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInModel(org.eclipse.emf.common.util.URI contextURI, boolean includeReferencedModels)
model descriptor
of the context uri
.contextURI
- The uri
used as context object for investigation.includeReferencedModels
- Determines if the model descriptors
referenced by the context uri
's model descriptor
must be considered for the research.uri
's model.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInModel(org.eclipse.emf.ecore.resource.Resource contextResource, boolean includeReferencedModels)
model descriptor
of the context resource
.If the given contextResource
doesn't belong to any model
descriptor
, resources in contextResourceSet
will be returnedcontextResource
- The resource
used as context object for investigation.includeReferencedModels
- Determines if the model descriptors
referenced by the context
resource
's model descriptor
must be considered for the
research.resource
's model.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInModel(org.eclipse.emf.ecore.EObject contextEObject, boolean includeReferencedModels)
model descriptor
of the context eobject
.contextEObject
- The eobject
used as context object for investigation.includeReferencedModels
- Determines if the model descriptors
referenced by the context eobject
's model descriptor
must be considered for the research.eobject
's model.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInModel(org.eclipse.emf.edit.provider.IWrapperItemProvider contextProvider, boolean includeReferencedModels)
model descriptor
of the context
provider
.contextProvider
- The provider
used as context object for investigation.includeReferencedModels
- Determines if the model descriptors
referenced by the context
provider
's model descriptor
must be considered
for the research.provider
's model.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInModel(org.eclipse.emf.ecore.util.FeatureMap.Entry contextEntry, boolean includeReferencedModels)
model descriptor
of the context
feature map entry
.contextEntry
- The feature map entry
used as context object for investigation.includeReferencedModels
- Determines if the model descriptors
referenced by the context
feature map entry
's model descriptor
must be
considered for the research.feature map entry
's model.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInModel(TransientItemProvider contextProvider, boolean includeReferencedModels)
model descriptor
of the context
provider
.contextProvider
- The provider
used as context object for investigation.includeReferencedModels
- Determines if the model descriptors
referenced by the context
provider
's model descriptor
must be considered
for the research.provider
's model.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInModels(org.eclipse.core.resources.IContainer contextContainer, IMetaModelDescriptor mmDescriptor, boolean includeReferencedModels)
contextContainer
- The container
used as context object for investigation.includeReferencedModels
- Determines if the model descriptors
referenced by the context
container
's model descriptor
must be considered for the
research.container
's models.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInOtherModels(org.eclipse.emf.ecore.resource.Resource contextResource, IMetaModelDescriptor otherMMDescriptor, boolean includeReferencedModels)
model descriptor
s which are filtered by the
other meta model descriptor
. These resources reside in the models other than the
model of the context resource resides.contextResource
- The resource
used as context object for investigation.otherMMDescriptor
- The target meta model descriptor
includeReferencedModels
- Determines if the model resource scopes
referenced by the context
resource
's model resource scope
must be considered for the
research.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInScope(java.lang.Object contextObject, boolean includeReferencedScopes)
model resource scope
of the contextObject.contextObject
- The Object used to research resources in the model.includeReferencedScopes
- Determines if the model resource scope
referenced by the context object's
model resource scope
must be considered for the research.model resource scope
.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInScope(IModelDescriptor modelDescriptor, boolean includeReferencedScopes)
model resource scope
of the model descriptor
provided in argument .modelDescriptor
- The model descriptor
used as context object for investigation.includeReferencedModels
- Determines if the model resource scopes
referenced by the context
model resource scope
must be considered for the research.resource
s owned by the model resource scope
.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInScope(org.eclipse.core.resources.IFile contextFile, boolean includeReferencedScopes)
model resource scope
of the model descriptor
of the context file
. If the given file
does not belong to any
model descriptor
, resources in context ResourceSet
will be returned.contextFile
- The file
used as context object for investigation.includeReferencedModels
- Determines if the model resource scopes
referenced by the context file
's model resource scope
must be considered for the research.file
's model resource scope
.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInScope(org.eclipse.emf.common.util.URI contextURI, boolean includeReferencedScopes)
contextURI
- The uri
used as context object for investigation.includeReferencedModels
- Determines if the model resource scopes
referenced by the context uri
's model resource scope
must be considered for the research.uri
's model resource scope
.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInScope(org.eclipse.emf.ecore.resource.Resource contextResource, boolean includeReferencedScopes)
model resource scope
of the model descriptor
of the context resource
.If the given contextResource
does not
belong to any model descriptor
, resources in context ResourceSet
will be
returned.contextResource
- The resource
used as context object for investigation.includeReferencedModels
- Determines if the model resource scopes
referenced by the context
resource
's model resource scope
must be considered for the
research.resource
's model resource scope
.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInScope(org.eclipse.emf.ecore.EObject contextEObject, boolean includeReferencedScopes)
model resource scope
of the model descriptor
of the context eObject
.contextEObject
- The eObject
used as context object for investigation.includeReferencedModels
- Determines if the model resource scopes
referenced by the context
eObject
's model resource scope
must be considered for the
research.eObject
's model resource scope
.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInScope(org.eclipse.emf.edit.provider.IWrapperItemProvider contextProvider, boolean includeReferencedScopes)
model resource scope
of the model descriptor
of the context provider
.contextProvider
- The provider
used as context object for investigation.includeReferencedModels
- Determines if the model resource scopes
referenced by the context
provider
's model resource scope
must be considered
for the research.provider
's model resource
scope
.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInScope(org.eclipse.emf.ecore.util.FeatureMap.Entry contextEntry, boolean includeReferencedScopes)
model resource scope
of the model descriptor
of the context feature map entry
.contextEntry
- The feature map entry
used as context object for investigation.includeReferencedModels
- Determines if the model resource scopes
referenced by the context
feature map entry
's model resource scope
must be
considered for the research.feature map entry
's model
resource scope
.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInScope(TransientItemProvider contextProvider, boolean includeReferencedScopes)
model resource scope
of the model descriptor
of the context provider
.contextProvider
- The provider
used as context object for investigation.includeReferencedModels
- Determines if the model resource scopes
referenced by the context
provider
's model resource scope
must be
considered for the research.provider
's model
resource scope
.public static java.util.Collection<org.eclipse.emf.ecore.resource.Resource> getResourcesInScopes(org.eclipse.core.resources.IContainer contextContainer, boolean includeReferencedScopes)
model resource scope
s of the model descriptor
s of the context container
.contextContainer
- The container
used as context object for investigation.includeReferencedModels
- Determines if the model resource scopes
referenced by the context
container
's model resource scope
must be considered for the
research.container
's model resource scope
.public static org.eclipse.core.runtime.jobs.ISchedulingRule createSaveNewSchedulingRule(java.util.Collection<ModelResourceDescriptor> modelResourceDescriptors)
public static org.eclipse.core.runtime.jobs.ISchedulingRule createSaveSchedulingRule(org.eclipse.emf.ecore.resource.Resource resource)
resource
.resource
- The resource to be saved.resource
.public static org.eclipse.core.runtime.jobs.ISchedulingRule createSaveSchedulingRule(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources)
resource
s.resources
- The resources to be saved (for which scheduling rules must be created.resources
.public static void addNewModelResource(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.core.runtime.IPath path, java.lang.String contentTypeId, org.eclipse.emf.ecore.EObject content, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
Resource
to the provided TransactionalEditingDomain
, created by using
content
as basis for the containing model.editingDomain
- The TransactionalEditingDomain
where to add new resource.path
- The relative IPath
of the new Resource
.contentTypeId
- The contenType ID of the contained model.content
- The root element of the model to include in the new Resource
.async
- Boolean parameter to determine if the execution must be synchronous or asynchronous.monitor
- The IProgressMonitor
.public static void addNewModelResources(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, java.util.Collection<ModelResourceDescriptor> modelResourceDescriptors, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
resource
s described by modelResourceDescriptors to the provided
editingDomain
.editingDomain
- The TransactionalEditingDomain
where to add new resource.modelResourceDescriptors
- The list of ModelResourceDescriptor
describing new resources to add.async
- Boolean parameter to determine if the execution must be synchronous or asynchronous.monitor
- The IProgressMonitor
.public static void saveNewModelResource(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.core.runtime.IPath path, java.lang.String contentTypeId, org.eclipse.emf.ecore.EObject content, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
public static void saveNewModelResources(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, java.util.Collection<ModelResourceDescriptor> modelResourceDescriptors, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
public static void saveNewModelResource(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.core.runtime.IPath path, java.lang.String contentTypeId, org.eclipse.emf.ecore.EObject content, java.util.Map<?,?> options, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
public static void saveNewModelResources(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, java.util.Collection<ModelResourceDescriptor> modelResourceDescriptors, java.util.Map<?,?> options, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
public static void saveModel(java.lang.Object contextObject, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
contextResource
- The object resource identifying the model to save.async
- If true
, model will be saved within a workspace job.monitor
- The progress monitor to use for showing save process progress.public static void saveModel(java.lang.Object contextObject, java.util.Map<?,?> options, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
contextObject
- The object context identifying the models to save.options
- The save options.async
- When passing true
the model will be saved within a workspace job.monitor
- The progress monitor to use for showing save process progress.public static void saveProject(org.eclipse.core.resources.IProject project, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
resource
s of all models behind the specified project
including all referenced projects ( i.e. all resources in the context of the given project).project
- The project
identifying the models to save.async
- If true
, models will be saved within a workspace job.monitor
- The progress monitor to use for showing save process progress.public static void saveProject(org.eclipse.core.resources.IProject project, java.util.Map<?,?> options, boolean async, org.eclipse.core.runtime.IProgressMonitor monitor)
Resource
s of all models behind the specified project including all referenced
IProject
s ( i.e. all resources in the context of the given project).project
- The project
identifying the models to save.options
- The save options.async
- If true
, models will be saved within a workspace job.monitor
- The progress monitor to use for showing save process progress.public static void unloadFile(org.eclipse.core.resources.IFile file)
file
.file
- The file
containing the model.unloadFile(TransactionalEditingDomain, IFile)
public static void unloadFile(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.core.resources.IFile file)
file
- The file containing the model.editingDomain
- The editing domain the file
belongs to.public static void unloadFiles(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, java.util.Collection<org.eclipse.core.resources.IFile> files, boolean memoryOptimized, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.OperationCanceledException
files
- The file
s containing the models.editingDomain
- The editing domain
the file
s belong to.org.eclipse.core.runtime.OperationCanceledException
public static void unloadResources(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources, boolean memoryOptimized, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.OperationCanceledException
memoryOptimized
- resources
- The resources to unload.editingDomain
- The editing domain owning resource
s.org.eclipse.core.runtime.OperationCanceledException
public static void unloadAllResources(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.OperationCanceledException
editingDomain
- The editing domain owning resource
s.org.eclipse.core.runtime.OperationCanceledException
public static void validate(org.eclipse.core.resources.IFile file, java.net.URL schemaURL) throws org.xml.sax.SAXException, java.io.IOException
file
and validates it against XSD schema with specified url
. Raises an
exception if the file
's content is not compliant with respect to XSD schema.file
- The file
to be validated.schemaURL
- The url
of the XSD schema to be used for validation.org.xml.sax.SAXException
java.io.IOException