org.eclipse.core.resources.mapping
Class ModelProvider
java.lang.Object
org.eclipse.core.runtime.PlatformObject
org.eclipse.core.resources.mapping.ModelProvider
-
All Implemented Interfaces:
-
IAdaptable
-
public abstract class ModelProvider
- extends
PlatformObject
Represents the provider of a logical model. The main purpose of this
API is to support batch operations on sets of ResourceMapping
objects that are part of the same model.
This class may be subclassed by clients.
-
Since:
- 3.2
-
See Also:
-
ResourceMapping
RESOURCE_MODEL_PROVIDER_ID
public static final
String RESOURCE_MODEL_PROVIDER_ID
- The model provider id of the Resources model.
-
See Also:
-
Constant Field Values
ModelProvider
public ModelProvider()
getModelProviderDescriptor
public static
IModelProviderDescriptor getModelProviderDescriptor(
String id)
- Return the descriptor for the model provider of the given id
or
null
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
public static
IModelProviderDescriptor[] getModelProviderDescriptors()
- Return the descriptors for all model providers that are registered.
-
-
Returns:
- the descriptors for all model providers that are registered.
equals
public boolean equals(
Object obj)
-
-
Overrides:
-
equals
in class
Object
-
getDescriptor
public final
IModelProviderDescriptor getDescriptor()
- Return the descriptor of this model provider. The descriptor
is set during initialization so implements cannot call this method
until after the
initialize
method is invoked.
-
-
Returns:
- the descriptor of this model provider
getId
public final
String 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
- Return the resource mappings that cover the given resource.
By default, an empty array is returned. Subclass may override
this method but should consider overriding either
getMappings(IResource[], ResourceMappingContext, IProgressMonitor)
or (
getMappings(ResourceTraversal[], ResourceMappingContext, IProgressMonitor)
if more context is needed to determine the proper mappings.
-
-
Parameters:
-
resource
- the resource -
context
- a resource mapping context -
monitor
- a progress monitor, or null
if progress
reporting is not desired
-
Returns:
- the resource mappings that cover the given resource.
-
Throws:
-
CoreException
getMappings
public
ResourceMapping[] getMappings(
IResource[] resources,
ResourceMappingContext context,
IProgressMonitor monitor)
throws
CoreException
- Return 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
calls
getMapping(IResource)
for each resource.
Subclasses may override this method.
-
-
Parameters:
-
resources
- the resources -
context
- a resource mapping context -
monitor
- a progress monitor, or null
if progress
reporting is not desired
-
Returns:
- the set of mappings that cover the given resources
-
Throws:
-
CoreException
getMappings
public
ResourceMapping[] getMappings(
ResourceTraversal[] traversals,
ResourceMappingContext context,
IProgressMonitor monitor)
throws
CoreException
- Return 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
calls
getMappings(IResource[], ResourceMappingContext, IProgressMonitor)
with the resources extract from each traversal.
Subclasses may override this method.
-
-
Parameters:
-
traversals
- the traversals -
context
- a resource mapping context -
monitor
- a progress monitor, or null
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
- Return 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 resources -
context
- the context used to determine the set of traversals that
cover the mappings -
monitor
- a progress monitor, or null
if progress
reporting is not desired
-
Returns:
- a set of traversals that cover the given mappings
-
Throws:
-
CoreException
hashCode
public int hashCode()
-
-
Overrides:
-
hashCode
in class
Object
-
init
public final void init(
IModelProviderDescriptor desc)
- 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 the
initialize
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
initialize
protected void initialize()
- Initialization method that is called after the descriptor
of this provider is set. Subclasses may override.
-
validateChange
public
IStatus validateChange(
IResourceDelta delta,
IProgressMonitor monitor)
- Validate the proposed changes contained in the given delta.
This method must return either a
ModelStatus
, or a
MultiStatus
whose children are
ModelStatus
. The severity of the returned status
indicates the severity of the possible side-effects of the operation. Any
severity other than OK
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 changes -
monitor
- a progress monitor, or null
if progress
reporting is not desired
-
Returns:
- a status indicating any potential side effects
on the model that provided this validator.
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.