Eclipse Platform
Release 3.2

org.eclipse.team.core.mapping.provider
Class SynchronizationScopeManager

java.lang.Object
  extended byorg.eclipse.team.core.mapping.provider.SynchronizationScopeManager
All Implemented Interfaces:
ISynchronizationScopeManager
Direct Known Subclasses:
SubscriberScopeManager

public class SynchronizationScopeManager
extends Object
implements ISynchronizationScopeManager

Class for translating a set of ResourceMapping objects representing a view selection into the complete set of resources to be operated on.

Here's a summary of the scope generation algorithm:

  1. Obtain selected mappings
  2. Project mappings onto resources using the appropriate context(s) in order to obtain a set of ResourceTraverals
  3. Determine what model providers are interested in the targeted resources
  4. From those model providers, obtain the set of affected resource mappings
  5. If the original set is the same as the new set, we are done.
  6. if the set differs from the original selection, rerun the mapping process for any new mappings

This implementation does not involve participants in the scope management process. It is up to subclasses that wish to support a longer life cycle for scopes to provide for participation. For example, the SubscriberScopeManager class includes participates in the scope management process.

This class is can be subclasses by clients.

EXPERIMENTAL. This class or interface has been added as part of a work in progress. There is a guarantee neither that this API will work nor that it will remain the same. Please do not use this API without consulting with the Platform/Team team.

Since:
3.2
See Also:
ResourceMapping, SubscriberScopeManager

Constructor Summary
SynchronizationScopeManager(org.eclipse.core.resources.mapping.ResourceMapping[] inputMappings, org.eclipse.core.resources.mapping.ResourceMappingContext resourceMappingContext, boolean consultModels)
          Create a scope manager that uses the given context to determine what resources should be included in the scope.
 
Method Summary
protected  org.eclipse.core.resources.mapping.ResourceTraversal[] addMappingToScope(org.eclipse.core.resources.mapping.ResourceMapping mapping, org.eclipse.core.resources.mapping.ResourceTraversal[] traversals)
          Add the mapping and its calculated traversals to the scope.
protected  org.eclipse.core.resources.mapping.ResourceTraversal[] adjustInputTraversals(org.eclipse.core.resources.mapping.ResourceTraversal[] traversals)
          Adjust the given set of input resources to include any additional resources required by a particular repository provider for the current operation.
protected  ISynchronizationScope createScope(org.eclipse.core.resources.mapping.ResourceMapping[] inputMappings)
          Create the scope that will be populated and returned by the builder.
 void dispose()
          Method to be invoked when the scope of this manager is no longer needed.
 org.eclipse.core.resources.mapping.ResourceMappingContext getContext()
          Return the resource mapping contxt that the scope uses to obtain traversals from resource mappings in order to determine what resources are in the scope.
static org.eclipse.core.resources.mapping.ResourceMapping[] getMappingsFromProviders(org.eclipse.core.resources.mapping.ResourceTraversal[] traversals, org.eclipse.core.resources.mapping.ResourceMappingContext context, IProgressMonitor monitor)
          Convenience method for obtaining the set of resource mappings from all model providers that overlap with the given resources.
 IProject[] getProjects()
          Return the projects that apply to this manager.
 ISchedulingRule getSchedulingRule()
          Return the scheduling rule that is used when initializing and refreshing the scope.
 ISynchronizationScope getScope()
          Return the scope that is managed by this manager.
 void initialize(IProgressMonitor monitor)
          Build the scope that is used to determine the complete set of resource mappings, and hence resources, that an operation should be performed on.
 boolean isInitialized()
          Return whether the scope has been initialized.
 void refresh(org.eclipse.core.resources.mapping.ResourceMapping[] mappings)
          Refresh the given mapping asynchronously.
 org.eclipse.core.resources.mapping.ResourceTraversal[] refresh(org.eclipse.core.resources.mapping.ResourceMapping[] mappings, IProgressMonitor monitor)
          Refresh the scope of this manager for the given mappings.
protected  void setHasAdditionalMappings(ISynchronizationScope scope, boolean hasAdditionalMappings)
          set whether the scope has additional mappings.
protected  void setHasAdditionalResources(boolean hasAdditionalResources)
          set whether the scope has additional resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SynchronizationScopeManager

public SynchronizationScopeManager(org.eclipse.core.resources.mapping.ResourceMapping[] inputMappings,
                                   org.eclipse.core.resources.mapping.ResourceMappingContext resourceMappingContext,
                                   boolean consultModels)
Create a scope manager that uses the given context to determine what resources should be included in the scope. If consultModels is true then the moel providers will be queried in order to determine if additional mappings should be included in the scope

Parameters:
inputMappings - the input mappings
resourceMappingContext - a resource mapping context
consultModels - whether modle providers should be consulted
Method Detail

getMappingsFromProviders

public static org.eclipse.core.resources.mapping.ResourceMapping[] getMappingsFromProviders(org.eclipse.core.resources.mapping.ResourceTraversal[] traversals,
                                                                                            org.eclipse.core.resources.mapping.ResourceMappingContext context,
                                                                                            IProgressMonitor monitor)
                                                                                     throws CoreException
Convenience method for obtaining the set of resource mappings from all model providers that overlap with the given resources.

Parameters:
traversals - the resource traversals
context - the resource mapping context
monitor - a progress monitor
Returns:
the resource mappings
Throws:
CoreException

isInitialized

public boolean isInitialized()
Description copied from interface: ISynchronizationScopeManager
Return whether the scope has been initialized.

Specified by:
isInitialized in interface ISynchronizationScopeManager
Returns:
whether the scope has been initialized.

getSchedulingRule

public ISchedulingRule getSchedulingRule()
Return the scheduling rule that is used when initializing and refreshing the scope. By default, it is the workspace root if the resource mapping context is a local context. If the context is a RemoteResourceMappingContext, the rule is a multi-rule that covers the projects of the context.

Returns:
the scheduling rule that is used when initializing and refreshing the scope

initialize

public void initialize(IProgressMonitor monitor)
                throws CoreException
Description copied from interface: ISynchronizationScopeManager
Build the scope that is used to determine the complete set of resource mappings, and hence resources, that an operation should be performed on.

This method obtaines a lock on the workspace root to avoid workspace changes while calculating the scope.

Specified by:
initialize in interface ISynchronizationScopeManager
Parameters:
monitor - a progress monitor when building the scope
Throws:
CoreException

refresh

public org.eclipse.core.resources.mapping.ResourceTraversal[] refresh(org.eclipse.core.resources.mapping.ResourceMapping[] mappings,
                                                                      IProgressMonitor monitor)
                                                               throws CoreException
Description copied from interface: ISynchronizationScopeManager
Refresh the scope of this manager for the given mappings. Changes in the scope will be reported as a property change event fired from the scope. Clients should call this method when a change in the workspace or a change issued from this manager have resulted in a change in the resources that should be included in the scope.

Specified by:
refresh in interface ISynchronizationScopeManager
Parameters:
mappings - the mappings to be refreshed
monitor - a progress monitor
Returns:
a set of traversals that cover the given mappings
Throws:
CoreException

setHasAdditionalMappings

protected final void setHasAdditionalMappings(ISynchronizationScope scope,
                                              boolean hasAdditionalMappings)
set whether the scope has additional mappings. This method is not intended to be overridden.

Parameters:
hasAdditionalMappings - a boolean indicating if the scope has additional mappings

setHasAdditionalResources

protected final void setHasAdditionalResources(boolean hasAdditionalResources)
set whether the scope has additional resources. This method is not intended to be overridden.

Parameters:
hasAdditionalResources - a boolean indicating if the scope has additional resources

createScope

protected final ISynchronizationScope createScope(org.eclipse.core.resources.mapping.ResourceMapping[] inputMappings)
Create the scope that will be populated and returned by the builder. This method is not intended to be overridden by clients.

Parameters:
inputMappings - the input mappings
Returns:
a newly created scope that will be populated and returned by the builder

adjustInputTraversals

protected org.eclipse.core.resources.mapping.ResourceTraversal[] adjustInputTraversals(org.eclipse.core.resources.mapping.ResourceTraversal[] traversals)
Adjust the given set of input resources to include any additional resources required by a particular repository provider for the current operation. By default the original set is returned but subclasses may override. Overriding methods should return a set of resources that include the original resource either explicitly or implicitly as a child of a returned resource.

Subclasses may override this method to include additional resources

Parameters:
traversals - the input resource traversals
Returns:
the input resource traversals adjusted to include any additional resources required for the current operation

addMappingToScope

protected final org.eclipse.core.resources.mapping.ResourceTraversal[] addMappingToScope(org.eclipse.core.resources.mapping.ResourceMapping mapping,
                                                                                         org.eclipse.core.resources.mapping.ResourceTraversal[] traversals)
Add the mapping and its calculated traversals to the scope. Return the resources that were not previously covered by the scope. This method is not intended to be subclassed by clients.

Parameters:
mapping - the resource mapping
traversals - the resource mapping's traversals
Returns:
the resource traversals that were not previously covered by the scope

getContext

public org.eclipse.core.resources.mapping.ResourceMappingContext getContext()
Description copied from interface: ISynchronizationScopeManager
Return the resource mapping contxt that the scope uses to obtain traversals from resource mappings in order to determine what resources are in the scope.

Specified by:
getContext in interface ISynchronizationScopeManager
Returns:
the resource mapping contxt that the scope uses to obtain traversals from resource mappings
See Also:
ResourceMapping.getTraversals(ResourceMappingContext, org.eclipse.core.runtime.IProgressMonitor)

getScope

public ISynchronizationScope getScope()
Description copied from interface: ISynchronizationScopeManager
Return the scope that is managed by this manager.

Specified by:
getScope in interface ISynchronizationScopeManager
Returns:
the scope that is managed by this manager

getProjects

public IProject[] getProjects()
Description copied from interface: ISynchronizationScopeManager
Return the projects that apply to this manager. The projects returned will depend on the type of context used to generate this scope. If the context is a local context, all workspace projects are returned. If it is a remote context, the projects are the same as those returned from RemoteResourceMappingContext.getProjects()

Specified by:
getProjects in interface ISynchronizationScopeManager
Returns:
the projects that apply to this manager

dispose

public void dispose()
Description copied from interface: ISynchronizationScopeManager
Method to be invoked when the scope of this manager is no longer needed. It is typically the reponsibility of the client that creates a scope manager to dispose of it.

Specified by:
dispose in interface ISynchronizationScopeManager

refresh

public void refresh(org.eclipse.core.resources.mapping.ResourceMapping[] mappings)
Description copied from interface: ISynchronizationScopeManager
Refresh the given mapping asynchronously. This method is called by ISynchronizationScopeParticipant instances when they detect changes that require the scope to be adjusted.

Specified by:
refresh in interface ISynchronizationScopeManager
Parameters:
mappings - the mappings to be refeshed.

Eclipse Platform
Release 3.2

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.