Class AbstractResourceVariantTree

    • Constructor Detail

      • AbstractResourceVariantTree

        public AbstractResourceVariantTree()
    • Method Detail

      • 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 invokes refresh(IResource, int, IProgressMonitor) for each resource. Subclasses may override but should either invoke the above mentioned refresh or collectChanges in order to reconcile the resource variant tree.
        Specified by:
        refresh in interface IResourceVariantTree
        Parameters:
        resources - the resources whose variants should be refreshed
        depth - the depth of the refresh (one of IResource.DEPTH_ZERO, IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE)
        monitor - a progress monitor
        Returns:
        the array of resources whose corresponding variants have changed
        Throws:
        TeamException
      • refresh

        protected IResource[] refresh​(IResource resource,
                                      int depth,
                                      IProgressMonitor monitor)
                               throws TeamException
        Helper method invoked from refresh(IResource[], int, IProgressMonitor monitor) for each resource. The default implementation performs the following steps:
        1. get the resource variant handle corresponding to the local resource by calling getRemoteTree.
        2. pass the local resource and the resource variant handle to collectChanges
        Subclasses may override but should perform roughly the same steps.
        Parameters:
        resource - the resource being refreshed
        depth - the depth of the refresh (one of IResource.DEPTH_ZERO, IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE)
        monitor - a progress monitor
        Returns:
        the resource's whose variants have changed
        Throws:
        TeamException
      • 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 refreshed
        remote - the corresponding resource variant
        depth - the depth of the refresh (one of IResource.DEPTH_ZERO, IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE)
        monitor - a progress monitor
        Returns:
        the resource's whose variants have changed
        Throws:
        TeamException
      • 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 when fetchVariant was called or may fetch the children directly (i.e. this method may contact the server).
        Parameters:
        variant - the resource variant
        progress - 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 by fetchMembers(IResourceVariant, IProgressMonitor).
        Parameters:
        resource - the local resource
        depth - the depth of the refresh (one of IResource.DEPTH_ZERO, IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE)
        monitor - a progress monitor
        Returns:
        the resource variant corresponding to the given local resource
        Throws:
        TeamException
      • collectedMembers

        protected IResource[] collectedMembers​(IResource local,
                                               IResource[] members)
                                        throws TeamException
        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 resource
        members - 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 resource
        remote - the newly fetched resource variant
        Returns:
        true if the resource variant changed
        Throws:
        TeamException