Class 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
    • Field Detail

      • 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
    • Constructor Detail

      • ModelProvider

        public ModelProvider()
    • Method Detail

      • getModelProviderDescriptor

        public static IModelProviderDescriptor getModelProviderDescriptor​(String id)
        Returns 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()
        Returns the descriptors for all model providers that are registered.
        Returns:
        the descriptors for all model providers that are registered.
      • getDescriptor

        public final IModelProviderDescriptor getDescriptor()
        Returns 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[] 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 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 - in case of error; depends on actual implementation
      • 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 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 - in case of error; depends on actual implementation
      • 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
        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

        public IStatus validateChange​(IResourceDelta delta,
                                      IProgressMonitor monitor)
        Validates 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.