public class ModelDescriptorRegistry
extends java.lang.Object
This registry provides methods allowing to add, remove or retrieve one (or several) model descriptor(s). Registry is kept up-to-date thanks to a resource set listener that is notified when any resource is loaded or unloaded.
IModelDescriptor
Modifier and Type | Field and Description |
---|---|
static ModelDescriptorRegistry |
INSTANCE
The singleton instance of this registry.
|
protected java.util.Map<IMetaModelDescriptor,java.util.Set<IModelDescriptor>> |
modelDescriptors
The described models.
|
Modifier and Type | Method and Description |
---|---|
void |
addModel(org.eclipse.core.resources.IFile file)
Adds the model descriptor for the specified
file to this registry. |
void |
addModel(IMetaModelDescriptor mmDescriptor,
IMetaModelDescriptor targetMMDescriptor,
org.eclipse.core.resources.IResource resourceScopeRoot)
Adds the model descriptor corresponding to the specified
meta-model descriptor, target meta-model
descriptor and resource scope
root to this registry. |
void |
addModel(org.eclipse.emf.ecore.resource.Resource resource)
Adds the model descriptor for the specified
resource to this
registry. |
void |
addModelDescriptorChangeListener(IModelDescriptorChangeListener listener)
Adds the given listener for
model descriptor change events to this
modelDescriptorRegistry. |
void |
addModels(org.eclipse.core.resources.IProject project) |
java.util.Collection<IModelDescriptor> |
getAllModels()
Returns all registered model descriptors.
|
java.util.Collection<IModelDescriptor> |
getAllModels(IMetaModelDescriptor mmDescriptor)
Returns all registered model descriptors for the specified
meta-model descriptor.
|
IModelDescriptor |
getModel(org.eclipse.core.resources.IFile file)
Returns the
descriptor of the model the specified file belongs to. |
IModelDescriptor |
getModel(org.eclipse.emf.ecore.resource.Resource resource)
Returns the
descriptor of the model the specified resource belongs to. |
java.util.Collection<IModelDescriptor> |
getModels(org.eclipse.core.resources.IContainer container) |
java.util.Collection<IModelDescriptor> |
getModels(org.eclipse.core.resources.IContainer container,
IMetaModelDescriptor mmFilter) |
IModelDescriptor |
getOldModel(org.eclipse.core.resources.IFile file)
Returns the old
descriptor of the model the specified file did belong to
before it was changed or deleted. |
IModelDescriptor |
getOldModel(org.eclipse.emf.ecore.resource.Resource resource)
Returns the old
descriptor of the model the specified resource did
belong to before it was changed or unloaded. |
boolean |
isModelFile(org.eclipse.core.resources.IFile file)
Check if specified file is a Sphinx model file
|
void |
moveModels(org.eclipse.core.resources.IProject oldProject,
org.eclipse.core.resources.IProject newProject)
Moves all
model descriptor s from specified old project , if any, to
specified new project .Usually called when specified old project has been
renamed. |
void |
printAllModels() |
void |
removeModel(org.eclipse.core.resources.IFile file)
Removes the model descriptor for the specified
file from this
registry. |
void |
removeModel(IModelDescriptor modelDescriptor)
Removes the specified model descriptor this registry.
|
void |
removeModel(org.eclipse.emf.ecore.resource.Resource resource)
Removes the model descriptor for the specified
resource from this
registry. |
void |
removeModelDescriptorChangeListener(IModelDescriptorChangeListener listener)
remove the given listener for
model descriptor change events from this
modelDescriptorRegistry. |
void |
removeModels(org.eclipse.core.resources.IContainer container) |
public static ModelDescriptorRegistry INSTANCE
protected java.util.Map<IMetaModelDescriptor,java.util.Set<IModelDescriptor>> modelDescriptors
This map - which represents an association between a root model project and the models it owns - contains an entry for each loaded model.
public void addModel(org.eclipse.core.resources.IFile file)
file
to this registry.
Usually called when the resource corresponding to the specified file
has just
been loaded.file
- The file for which corresponding model descriptor
must be added/upgraded.public void addModel(org.eclipse.emf.ecore.resource.Resource resource)
resource
to this
registry. Usually called when the resource has just been loaded.resource
- The resource for which corresponding model
descriptor must be added/upgraded.public void addModel(IMetaModelDescriptor mmDescriptor, IMetaModelDescriptor targetMMDescriptor, org.eclipse.core.resources.IResource resourceScopeRoot)
root
to this registry. The model
descriptor is also added for the resource scopes referenced by the resource scope behind specified
resourceScopeRoot.mmDescriptor
- The meta-model descriptor of the model to add.targetMMDescriptor
- The target meta-model descriptor of the model to add.resourceScopeRoot
- The root of the resource scope of the model to add.public void addModels(org.eclipse.core.resources.IProject project)
public IModelDescriptor getModel(org.eclipse.core.resources.IFile file)
descriptor
of the model the specified file
belongs to.file
- The file whose model descriptor
is to be retrieved.descriptor
of the model the specified file
belongs to, or
null
if file
is not part of any model.public boolean isModelFile(org.eclipse.core.resources.IFile file)
file
- the file be checked.true
if specified file is a Sphinx model file. Otherwise false
.public IModelDescriptor getModel(org.eclipse.emf.ecore.resource.Resource resource)
descriptor
of the model the specified resource
belongs to.resource
- The resource whose model descriptor
is to be retrieved.descriptor
of the model the specified resource belongs
to, or null
if file
is not part of any model.public IModelDescriptor getOldModel(org.eclipse.core.resources.IFile file)
descriptor
of the model the specified file
did belong to
before it was changed or deleted.file
- The file whose old model descriptor
is to be retrieved.descriptor
of the model the specified file
did belong to, or
null
if file
hadn't been part of any model before it was changed or deleted.public IModelDescriptor getOldModel(org.eclipse.emf.ecore.resource.Resource resource)
descriptor
of the model the specified resource
did
belong to before it was changed or unloaded.file
- The file whose old model descriptor
is to be retrieved.descriptor
of the model the specified resource
did belong
to, or null
if resource
hadn't been part of any model before it was changed
or unloaded.public java.util.Collection<IModelDescriptor> getModels(org.eclipse.core.resources.IContainer container)
container
- The container for which model descriptors must
be returned; can be an instance of IWorkspaceRoot, IProject or
IFolder.container
.public java.util.Collection<IModelDescriptor> getModels(org.eclipse.core.resources.IContainer container, IMetaModelDescriptor mmFilter)
container
- The container for which model descriptors must
be returned; can be an instance of IWorkspaceRoot, IProject or
IFolder.mmFilter
- meta-model desciptor used to filter model descriptors returnedpublic java.util.Collection<IModelDescriptor> getAllModels()
public java.util.Collection<IModelDescriptor> getAllModels(IMetaModelDescriptor mmDescriptor)
mmDescriptor
- The meta-model descriptor to use in order to filter the model descriptors in the registry.public void moveModels(org.eclipse.core.resources.IProject oldProject, org.eclipse.core.resources.IProject newProject)
model descriptor
s from specified old project
, if any, to
specified new project
.Usually called when specified old project
has been
renamed.oldProject
- The old project
whose meta-model descriptor
s are to be
moved.newProject
- The new project
to which the old project
's
meta-model descriptor
s are to be moved.public void removeModel(org.eclipse.core.resources.IFile file)
file
from this
registry. Usually called when the resource corresponding to the specified file
has just been unloaded.file
- The file for which corresponding model descriptor
must be upgraded/removed.public void removeModel(org.eclipse.emf.ecore.resource.Resource resource)
resource
from this
registry. Usually called when the resource has just been unloaded.resource
- The resource for which corresponding model
descriptor must be upgraded/removed.public void removeModel(IModelDescriptor modelDescriptor)
modelDescriptor
.modelDescriptor
- The model descriptor to remove from this registry.public void removeModels(org.eclipse.core.resources.IContainer container)
public void addModelDescriptorChangeListener(IModelDescriptorChangeListener listener)
model descriptor
change events to this
modelDescriptorRegistry. Has no effect if an identical listener is already registered.listener
- the listenerIModelDescriptorChangeListener
public void removeModelDescriptorChangeListener(IModelDescriptorChangeListener listener)
model descriptor
change events from this
modelDescriptorRegistry. Has no effect if such a listener is not registered.listener
- the listenerIModelDescriptorChangeListener
public void printAllModels()