Class SynchronizationScopeManager
java.lang.Object
org.eclipse.core.runtime.PlatformObject
org.eclipse.team.core.mapping.provider.SynchronizationScopeManager
- All Implemented Interfaces:
IAdaptable
,ISynchronizationScopeManager
- Direct Known Subclasses:
SubscriberScopeManager
public class SynchronizationScopeManager
extends PlatformObject
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:
- Obtain selected mappings
- Project mappings onto resources using the appropriate context(s) in order to obtain a set of ResourceTraverals
- Determine what model providers are interested in the targeted resources
- From those model providers, obtain the set of affected resource mappings
- If the original set is the same as the new set, we are done.
- If the set differs from the original selection, rerun the mapping
process for any new mappings
- Only need to query model providers for mappings for new resources
- Keep repeating until no new mappings or resources are added
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.
- Since:
- 3.2
- See Also:
-
Constructor Summary
ConstructorDescriptionSynchronizationScopeManager
(String name, ResourceMapping[] inputMappings, 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
Modifier and TypeMethodDescriptionprotected final ResourceTraversal[]
addMappingToScope
(ResourceMapping mapping, ResourceTraversal[] traversals) Add the mapping and its calculated traversals to the scope.protected ResourceTraversal[]
adjustInputTraversals
(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 final ISynchronizationScope
createScope
(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.static ResourceMapping[]
getMappingsFromProviders
(ResourceTraversal[] traversals, ResourceMappingContext context, IProgressMonitor monitor) Convenience method for obtaining the set of resource mappings from all model providers that overlap with the given resources.getName()
Returns the human readable name of this manager.Return the scheduling rule that is used when initializing and refreshing the scope.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
Return whether the scope has been initialized.void
refresh
(ResourceMapping[] mappings) Refresh the given mappings by recalculating the traversals for the mappings and adjusting the scope accordingly.refresh
(ResourceMapping[] mappings, IProgressMonitor monitor) Refresh the scope of this manager for the given mappings.protected final void
setHasAdditionalMappings
(ISynchronizationScope scope, boolean hasAdditionalMappings) Set whether the scope has additional mappings.protected final void
setHasAdditionalResources
(boolean hasAdditionalResources) Set whether the scope has additional resources.Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
-
Constructor Details
-
SynchronizationScopeManager
public SynchronizationScopeManager(String name, ResourceMapping[] inputMappings, ResourceMappingContext resourceMappingContext, boolean consultModels) Create a scope manager that uses the given context to determine what resources should be included in the scope. IfconsultModels
istrue
then the model providers will be queried in order to determine if additional mappings should be included in the scope- Parameters:
name
- the name of the scopeinputMappings
- the input mappingsresourceMappingContext
- a resource mapping contextconsultModels
- whether model providers should be consulted
-
-
Method Details
-
getMappingsFromProviders
public static ResourceMapping[] getMappingsFromProviders(ResourceTraversal[] traversals, 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 traversalscontext
- the resource mapping contextmonitor
- a progress monitor- Returns:
- the resource mappings
- Throws:
CoreException
- if an error occurs
-
isInitialized
public boolean isInitialized()Description copied from interface:ISynchronizationScopeManager
Return whether the scope has been initialized.- Specified by:
isInitialized
in interfaceISynchronizationScopeManager
- Returns:
- whether the scope has been initialized.
-
getSchedulingRule
Return the scheduling rule that is used when initializing and refreshing the scope. By default, a rule that covers all projects for the input mappings of the scope is returned. Subclasses may override.- Returns:
- the scheduling rule that is used when initializing and refreshing the scope
-
initialize
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 obtains a lock on the workspace root to avoid workspace changes while calculating the scope.
- Specified by:
initialize
in interfaceISynchronizationScopeManager
- Parameters:
monitor
- a progress monitor when building the scope- Throws:
CoreException
- if an error occurs
-
refresh
public ResourceTraversal[] refresh(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 interfaceISynchronizationScopeManager
- Parameters:
mappings
- the mappings to be refreshedmonitor
- a progress monitor- Returns:
- a set of traversals that cover the given mappings
- Throws:
CoreException
- if an error occurs
-
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
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
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 ResourceTraversal[] addMappingToScope(ResourceMapping 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 mappingtraversals
- the resource mapping's traversals- Returns:
- the resource traversals that were not previously covered by the scope
-
getContext
-
getScope
Description copied from interface:ISynchronizationScopeManager
Return the scope that is managed by this manager.- Specified by:
getScope
in interfaceISynchronizationScopeManager
- Returns:
- the scope that is managed by 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 responsibility of the client that creates a scope manager to dispose it.- Specified by:
dispose
in interfaceISynchronizationScopeManager
-
refresh
Refresh the given mappings by recalculating the traversals for the mappings and adjusting the scope accordingly.- Parameters:
mappings
- the mappings to be refreshed
-
getName
Returns the human readable name of this manager. The name is nevernull
.- Returns:
- the name associated with this scope manager
-