Package org.eclipse.team.core.variants
Class ThreeWaySubscriber
- java.lang.Object
-
- org.eclipse.team.core.subscribers.Subscriber
-
- org.eclipse.team.core.variants.ResourceVariantTreeSubscriber
-
- org.eclipse.team.core.variants.ThreeWaySubscriber
-
- All Implemented Interfaces:
ISynchronizerChangeListener
public abstract class ThreeWaySubscriber extends ResourceVariantTreeSubscriber implements ISynchronizerChangeListener
A resource variant tree subscriber whose trees use an underlyingThreeWaySynchronizer
to store and manage the synchronization state for the local workspace. Subclasses need to provide a subclass ofThreeWayRemoteTree
and a method to create resource variant handles from the bytes cached in theThreeWaySynchronizer
.- Since:
- 3.0
- See Also:
ThreeWaySynchronizer
,ThreeWayRemoteTree
,CachedResourceVariant
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ThreeWaySubscriber(ThreeWaySynchronizer synchronizer)
Create a three-way subscriber that uses the given synchronizer to manage the synchronization state of local resources and their variants
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ThreeWayRemoteTree
createRemoteTree()
Create the three-way remote tree which provides access to the remote bytes in the three-way synchronizer.protected IResourceVariantTree
getBaseTree()
Return the base resource variant tree.protected IResourceVariantTree
getRemoteTree()
Return the remote resource variant tree.IResourceVariantComparator
getResourceComparator()
Returns the comparison criteria that will be used by the sync info created by this subscriber.abstract IResourceVariant
getResourceVariant(IResource resource, byte[] bytes)
Create the resource variant for the given local resource from the given bytes.ThreeWaySynchronizer
getSynchronizer()
Return the three-way synchronizer of this subscriber.protected void
handleRootChanged(IResource resource, boolean added)
Convenience method that can be used by subclasses to notify listeners when a root is added or removed from the subscriber.boolean
isSupervised(IResource resource)
Returnsfalse
for resources that are not children of a subscriber root, are ignored by the subscriber's synchronizer or are ignored by theTeam.ignoreHist(IResource)
.void
syncStateChanged(IResource[] resources)
Notification of synchronization state changes for the given resources.-
Methods inherited from class org.eclipse.team.core.variants.ResourceVariantTreeSubscriber
getSyncInfo, getSyncInfo, members, refresh
-
Methods inherited from class org.eclipse.team.core.subscribers.Subscriber
accept, accept, addListener, collectOutOfSync, fireTeamResourceChange, getDiff, getName, getState, refresh, removeListener, roots
-
-
-
-
Constructor Detail
-
ThreeWaySubscriber
protected ThreeWaySubscriber(ThreeWaySynchronizer synchronizer)
Create a three-way subscriber that uses the given synchronizer to manage the synchronization state of local resources and their variants- Parameters:
synchronizer
- the three-way synchronizer for this subscriber
-
-
Method Detail
-
getBaseTree
protected final IResourceVariantTree getBaseTree()
Description copied from class:ResourceVariantTreeSubscriber
Return the base resource variant tree.- Specified by:
getBaseTree
in classResourceVariantTreeSubscriber
-
getRemoteTree
protected final IResourceVariantTree getRemoteTree()
Description copied from class:ResourceVariantTreeSubscriber
Return the remote resource variant tree.- Specified by:
getRemoteTree
in classResourceVariantTreeSubscriber
-
getResourceComparator
public final IResourceVariantComparator getResourceComparator()
Description copied from class:Subscriber
Returns the comparison criteria that will be used by the sync info created by this subscriber.- Specified by:
getResourceComparator
in classSubscriber
- Returns:
- the comparator to use when computing sync states for this subscriber.
-
syncStateChanged
public void syncStateChanged(IResource[] resources)
Description copied from interface:ISynchronizerChangeListener
Notification of synchronization state changes for the given resources. Clients must query theThreeWaySynchronizer
that generated this event to determine the new synchronization state.- Specified by:
syncStateChanged
in interfaceISynchronizerChangeListener
- Parameters:
resources
- the resources whose synchronization state has changed
-
isSupervised
public boolean isSupervised(IResource resource) throws TeamException
Returnsfalse
for resources that are not children of a subscriber root, are ignored by the subscriber's synchronizer or are ignored by theTeam.ignoreHist(IResource)
. Returnstrue
otherwise.- Specified by:
isSupervised
in classSubscriber
- Parameters:
resource
- the resource being tested- Returns:
true
if this resource is supervised, andfalse
otherwise- Throws:
TeamException
- if an error occurs- See Also:
Subscriber.isSupervised(IResource)
-
getSynchronizer
public ThreeWaySynchronizer getSynchronizer()
Return the three-way synchronizer of this subscriber.- Returns:
- the three-way synchronizer of this subscriber.
-
getResourceVariant
public abstract IResourceVariant getResourceVariant(IResource resource, byte[] bytes) throws TeamException
Create the resource variant for the given local resource from the given bytes. The bytes are those that were previously returned from a call toIResourceVariant#asBytes()
.- Parameters:
resource
- the local resourcebytes
- the bytes that identify a variant of the resource- Returns:
- the resource variant handle recreated from the bytes
- Throws:
TeamException
- if an error occurs
-
createRemoteTree
protected abstract ThreeWayRemoteTree createRemoteTree()
Create the three-way remote tree which provides access to the remote bytes in the three-way synchronizer. This method is invoked once when the remote tree is first accessed. The returned object is cached and reused on subsequent accesses.- Returns:
- the remote tree
-
handleRootChanged
protected void handleRootChanged(IResource resource, boolean added)
Convenience method that can be used by subclasses to notify listeners when a root is added or removed from the subscriber. The added parameter should betrue
if the root was added andfalse
if it was removed.- Parameters:
resource
- the added or removed rootadded
-true
if the root was added andfalse
if it was removed.
-
-