org.eclipse.core.resources.mapping
Class ModelProvider

java.lang.Object
  extended by org.eclipse.core.runtime.PlatformObject
      extended by org.eclipse.core.resources.mapping.ModelProvider
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable
Direct Known Subclasses:
ResourceModelProvider, TestModelProvider

public abstract class ModelProvider
extends org.eclipse.core.runtime.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

Field Summary
static java.lang.String RESOURCE_MODEL_PROVIDER_ID
          The model provider id of the Resources model.
 
Constructor Summary
ModelProvider()
           
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 IModelProviderDescriptor getDescriptor()
          Return the descriptor of this model provider.
 java.lang.String getId()
          Returns the unique identifier of this model provider.
 ResourceMapping[] getMappings(IResource[] resources, ResourceMappingContext context, org.eclipse.core.runtime.IProgressMonitor monitor)
          Return the set of mappings that cover the given resources.
 ResourceMapping[] getMappings(IResource resource, ResourceMappingContext context, org.eclipse.core.runtime.IProgressMonitor monitor)
          Return the resource mappings that cover the given resource.
 ResourceMapping[] getMappings(ResourceTraversal[] traversals, ResourceMappingContext context, org.eclipse.core.runtime.IProgressMonitor monitor)
          Return the set of mappings that overlap with the given resource traversals.
static IModelProviderDescriptor getModelProviderDescriptor(java.lang.String id)
          Return the descriptor for the model provider of the given id or null if the provider has not been registered.
static IModelProviderDescriptor[] getModelProviderDescriptors()
          Return the descriptors for all model providers that are registered.
 ResourceTraversal[] getTraversals(ResourceMapping[] mappings, ResourceMappingContext context, org.eclipse.core.runtime.IProgressMonitor monitor)
          Return a set of traversals that cover the given resource mappings.
 int hashCode()
           
 void init(IModelProviderDescriptor desc)
          This method is called by the model provider framework when the model provider is instantiated.
 org.eclipse.core.runtime.IStatus validateChange(IResourceDelta delta, org.eclipse.core.runtime.IProgressMonitor monitor)
          Validate the proposed changes contained in the given delta.
 
Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE_MODEL_PROVIDER_ID

public static final java.lang.String RESOURCE_MODEL_PROVIDER_ID
The model provider id of the Resources model.

See Also:
Constant Field Values
Constructor Detail

ModelProvider

public ModelProvider()
Method Detail

getModelProviderDescriptor

public static IModelProviderDescriptor getModelProviderDescriptor(java.lang.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(java.lang.Object obj)
Overrides:
equals in class java.lang.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 java.lang.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,
                                     org.eclipse.core.runtime.IProgressMonitor monitor)
                              throws org.eclipse.core.runtime.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:
org.eclipse.core.runtime.CoreException

getMappings

public ResourceMapping[] getMappings(IResource[] resources,
                                     ResourceMappingContext context,
                                     org.eclipse.core.runtime.IProgressMonitor monitor)
                              throws org.eclipse.core.runtime.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:
org.eclipse.core.runtime.CoreException

getMappings

public ResourceMapping[] getMappings(ResourceTraversal[] traversals,
                                     ResourceMappingContext context,
                                     org.eclipse.core.runtime.IProgressMonitor monitor)
                              throws org.eclipse.core.runtime.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:
org.eclipse.core.runtime.CoreException

getTraversals

public ResourceTraversal[] getTraversals(ResourceMapping[] mappings,
                                         ResourceMappingContext context,
                                         org.eclipse.core.runtime.IProgressMonitor monitor)
                                  throws org.eclipse.core.runtime.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:
org.eclipse.core.runtime.CoreException

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.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

validateChange

public org.eclipse.core.runtime.IStatus validateChange(IResourceDelta delta,
                                                       org.eclipse.core.runtime.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.