Class ModelProvider
- All Implemented Interfaces:
IAdaptable
ResourceMapping
objects that are part of the same model.
This class may be subclassed by clients.
- Since:
- 3.2
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The model provider id of the Resources model. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
final IModelProviderDescriptor
Returns the descriptor of this model provider.final String
getId()
Returns the unique identifier of this model provider.getMappings
(IResource[] resources, ResourceMappingContext context, IProgressMonitor monitor) Returns the set of mappings that cover the given resources.getMappings
(IResource resource, ResourceMappingContext context, IProgressMonitor monitor) Returns the resource mappings that cover the given resource.getMappings
(ResourceTraversal[] traversals, ResourceMappingContext context, IProgressMonitor monitor) Returns the set of mappings that overlap with the given resource traversals.static IModelProviderDescriptor
Returns the descriptor for the model provider of the given id ornull
if the provider has not been registered.static IModelProviderDescriptor[]
Returns the descriptors for all model providers that are registered.getTraversals
(ResourceMapping[] mappings, ResourceMappingContext context, IProgressMonitor monitor) Returns a set of traversals that cover the given resource mappings.int
hashCode()
final void
init
(IModelProviderDescriptor desc) This method is called by the model provider framework when the model provider is instantiated.protected void
Initialization method that is called after the descriptor of this provider is set.validateChange
(IResourceDelta delta, IProgressMonitor monitor) Validates the proposed changes contained in the given delta.Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
-
Field Details
-
RESOURCE_MODEL_PROVIDER_ID
The model provider id of the Resources model.- See Also:
-
-
Constructor Details
-
ModelProvider
public ModelProvider()
-
-
Method Details
-
getModelProviderDescriptor
Returns the descriptor for the model provider of the given id ornull
if the provider has not been registered.- Parameters:
id
- a model provider id.- Returns:
- the descriptor for the model provider of the given id
or
null
if the provider has not been registered
-
getModelProviderDescriptors
Returns the descriptors for all model providers that are registered.- Returns:
- the descriptors for all model providers that are registered.
-
equals
-
getDescriptor
Returns the descriptor of this model provider. The descriptor is set during initialization so implements cannot call this method until after theinitialize
method is invoked.- Returns:
- the descriptor of this model provider
-
getId
Returns the unique identifier of this model provider.The model provider identifier is composed of the model provider's plug-in id and the simple id of the provider extension. For example, if plug-in
"com.xyz"
defines a provider extension with id"myModelProvider"
, the unique model provider identifier will be"com.xyz.myModelProvider"
.- Returns:
- the unique model provider identifier
-
getMappings
public ResourceMapping[] getMappings(IResource resource, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException Returns the resource mappings that cover the given resource. By default, an empty array is returned. Subclass may override this method but should consider overriding eithergetMappings(IResource[], ResourceMappingContext, IProgressMonitor)
orgetMappings(ResourceTraversal[], ResourceMappingContext, IProgressMonitor)
if more context is needed to determine the proper mappings.- Parameters:
resource
- the resourcecontext
- a resource mapping contextmonitor
- a progress monitor, ornull
if progress reporting is not desired- Returns:
- the resource mappings that cover the given resource.
- Throws:
CoreException
- in case of error; depends on actual implementation
-
getMappings
public ResourceMapping[] getMappings(IResource[] resources, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException Returns the set of mappings that cover the given resources. This method is used to map operations on resources to operations on resource mappings. By default, this method callsgetMapping(IResource)
for each resource.Subclasses may override this method.
- Parameters:
resources
- the resourcescontext
- a resource mapping contextmonitor
- a progress monitor, ornull
if progress reporting is not desired- Returns:
- the set of mappings that cover the given resources
- Throws:
CoreException
- in case of error; depends on actual implementation
-
getMappings
public ResourceMapping[] getMappings(ResourceTraversal[] traversals, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException Returns the set of mappings that overlap with the given resource traversals. This method is used to map operations on resources to operations on resource mappings. By default, this method callsgetMappings(IResource[], ResourceMappingContext, IProgressMonitor)
with the resources extracted from each traversal.Subclasses may override this method.
- Parameters:
traversals
- the traversalscontext
- a resource mapping contextmonitor
- a progress monitor, ornull
if progress reporting is not desired- Returns:
- the set of mappings that overlap with the given resource traversals
- Throws:
CoreException
-
getTraversals
public ResourceTraversal[] getTraversals(ResourceMapping[] mappings, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException Returns a set of traversals that cover the given resource mappings. The provided mappings must be from this provider or one of the providers this provider extends.The default implementation accumulates the traversals from the given mappings. Subclasses can override to provide a more optimal transformation.
- Parameters:
mappings
- the mappings being mapped to resourcescontext
- the context used to determine the set of traversals that cover the mappingsmonitor
- a progress monitor, ornull
if progress reporting is not desired- Returns:
- a set of traversals that cover the given mappings
- Throws:
CoreException
- in case of error; depends on actual implementation
-
hashCode
public int hashCode() -
init
This method is called by the model provider framework when the model provider is instantiated. This method should not be called by clients and cannot be overridden by subclasses. However, it invokes theinitialize
method once the descriptor is set so subclasses can override that method if they need to do additional initialization.- Parameters:
desc
- the description of the provider as it appears in the plugin manifest- Restriction:
- This method is not intended to be referenced by clients.
-
initialize
protected void initialize()Initialization method that is called after the descriptor of this provider is set. Subclasses may override. -
validateChange
Validates the proposed changes contained in the given delta.This method must return either a
ModelStatus
, or aMultiStatus
whose children areModelStatus
. The severity of the returned status indicates the severity of the possible side-effects of the operation. Any severity other thanOK
will be shown to the user. The message should be a human readable message that will allow the user to make a decision on whether to continue with the operation. The model provider id should indicate which model is flagging the possible side effects.This default implementation accepts all changes and returns a status with severity
OK
. Subclasses should override to perform validation specific to their model.- Parameters:
delta
- a delta tree containing the proposed changesmonitor
- a progress monitor, ornull
if progress reporting is not desired- Returns:
- a status indicating any potential side effects on the model that provided this validator.
-