Package org.eclipse.team.core.variants
Class AbstractResourceVariantTree
java.lang.Object
org.eclipse.team.core.variants.AbstractResourceVariantTree
- All Implemented Interfaces:
IResourceVariantTree
- Direct Known Subclasses:
ResourceVariantTree
An implementation of
IResourceVariantTree
that provides the logic for
refreshing the tree and collecting the results so they can be cached locally.
This class does not perform the caching but relies on subclasses to do that by
overriding the setVariant
method. The subclass
ResourceVariantTree
does provide caching.- Since:
- 3.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected IResource[]
collectChanges
(IResource local, IResourceVariant remote, int depth, IProgressMonitor monitor) Collect the changes in the remote tree to the specified depth.protected IResource[]
collectedMembers
(IResource local, IResource[] members) Method that is invoked during collection to let subclasses know which members were collected for the given resource.protected abstract IResourceVariant[]
fetchMembers
(IResourceVariant variant, IProgressMonitor progress) Fetch the members of the given resource variant handle.protected abstract IResourceVariant
fetchVariant
(IResource resource, int depth, IProgressMonitor monitor) Fetch the resource variant corresponding to the given resource.refresh
(IResource[] resources, int depth, IProgressMonitor monitor) Refreshes the resource variant tree for the specified resources and possibly their descendants, depending on the depth.protected IResource[]
refresh
(IResource resource, int depth, IProgressMonitor monitor) Helper method invoked fromrefresh(IResource[], int, IProgressMonitor monitor)
for each resource.protected abstract boolean
setVariant
(IResource local, IResourceVariant remote) Set the variant associated with the local resource to the newly fetched resource variant.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.team.core.variants.IResourceVariantTree
flushVariants, getResourceVariant, hasResourceVariant, members, roots
-
Constructor Details
-
AbstractResourceVariantTree
public AbstractResourceVariantTree()
-
-
Method Details
-
refresh
public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException Refreshes the resource variant tree for the specified resources and possibly their descendants, depending on the depth. The default implementation of this method invokesrefresh(IResource, int, IProgressMonitor)
for each resource. Subclasses may override but should either invoke the above mentioned refresh orcollectChanges
in order to reconcile the resource variant tree.- Specified by:
refresh
in interfaceIResourceVariantTree
- Parameters:
resources
- the resources whose variants should be refresheddepth
- the depth of the refresh (one ofIResource.DEPTH_ZERO
,IResource.DEPTH_ONE
, orIResource.DEPTH_INFINITE
)monitor
- a progress monitor- Returns:
- the array of resources whose corresponding variants have changed
- Throws:
TeamException
- if an error occurs
-
refresh
protected IResource[] refresh(IResource resource, int depth, IProgressMonitor monitor) throws TeamException Helper method invoked fromrefresh(IResource[], int, IProgressMonitor monitor)
for each resource. The default implementation performs the following steps:- get the resource variant handle corresponding to the local resource by calling
getRemoteTree
. - pass the local resource and the resource variant handle to
collectChanges
- Parameters:
resource
- the resource being refresheddepth
- the depth of the refresh (one ofIResource.DEPTH_ZERO
,IResource.DEPTH_ONE
, orIResource.DEPTH_INFINITE
)monitor
- a progress monitor- Returns:
- the resource's whose variants have changed
- Throws:
TeamException
- if an error occurs
- get the resource variant handle corresponding to the local resource by calling
-
collectChanges
protected IResource[] collectChanges(IResource local, IResourceVariant remote, int depth, IProgressMonitor monitor) throws TeamException Collect the changes in the remote tree to the specified depth.- Parameters:
local
- the local resource being refreshedremote
- the corresponding resource variantdepth
- the depth of the refresh (one ofIResource.DEPTH_ZERO
,IResource.DEPTH_ONE
, orIResource.DEPTH_INFINITE
)monitor
- a progress monitor- Returns:
- the resource's whose variants have changed
- Throws:
TeamException
- if an error occurs
-
fetchMembers
protected abstract IResourceVariant[] fetchMembers(IResourceVariant variant, IProgressMonitor progress) throws TeamException Fetch the members of the given resource variant handle. This method may return members that were fetched whenfetchVariant
was called or may fetch the children directly (i.e. this method may contact the server).- Parameters:
variant
- the resource variantprogress
- a progress monitor- Returns:
- the members of the resource variant.
- Throws:
TeamException
-
fetchVariant
protected abstract IResourceVariant fetchVariant(IResource resource, int depth, IProgressMonitor monitor) throws TeamException Fetch the resource variant corresponding to the given resource. The depth parameter indicates the depth of the refresh operation and also indicates the depth to which the resource variant's descendants will be traversed. This method may pre-fetch the descendants to the provided depth or may just return the variant handle corresponding to the given local resource, in which case the descendant variants will be fetched byfetchMembers(IResourceVariant, IProgressMonitor)
.- Parameters:
resource
- the local resourcedepth
- the depth of the refresh (one ofIResource.DEPTH_ZERO
,IResource.DEPTH_ONE
, orIResource.DEPTH_INFINITE
)monitor
- a progress monitor- Returns:
- the resource variant corresponding to the given local resource
- Throws:
TeamException
-
collectedMembers
Method that is invoked during collection to let subclasses know which members were collected for the given resource. Implementors should purge any cached state for children of the local resource that are no longer members. Any such resources should be returned to allow clients to clear any state they maintain for those resources.- Parameters:
local
- the local resourcemembers
- the collected members- Returns:
- any resources that were previously collected whose state has been flushed
- Throws:
TeamException
-
setVariant
protected abstract boolean setVariant(IResource local, IResourceVariant remote) throws TeamException Set the variant associated with the local resource to the newly fetched resource variant. This method is invoked during change collection and should return whether the variant associated with the local resource has changed- Parameters:
local
- the local resourceremote
- the newly fetched resource variant- Returns:
true
if the resource variant changed- Throws:
TeamException
- if an error occurs
-