Package org.eclipse.team.core.subscribers

## Class SubscriberMergeContext

- java.lang.Object
- - org.eclipse.core.runtime.PlatformObject
  - - org.eclipse.team.core.mapping.provider.SynchronizationContext
    - - org.eclipse.team.core.mapping.provider.MergeContext
      - - org.eclipse.team.core.subscribers.SubscriberMergeContext

All Implemented Interfaces:
  `IAdaptable`, `IMergeContext`, `ISynchronizationContext`

    public abstract class SubscriberMergeContext
    extends MergeContext

A merge context that uses a subscriber to populate the diff tree used by the context. The population of the diff tree is performed by a handler that runs in a background job.

Since:
  3.2
See Also:
  `Subscriber`, `MergeContext`

### Field Summary

### Fields inherited from interface org.eclipse.team.core.mapping.ISynchronizationContext

`THREE_WAY, TWO_WAY`

### Constructor Summary

Constructors
`protected` `SubscriberMergeContext​(Subscriber subscriber, ISynchronizationScopeManager manager)` Create a merge context for the given subscriber

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `dispose()` Dispose of the synchronization context and the cache of the context.
`<T> T` `getAdapter​(Class<T> adapter)` Returns an object which is an instance of the given class associated with this object.
`protected DiffFilter` `getDiffFilter()` Return the diff filter used to filter the differences that the merge context will present to clients.
`Subscriber` `getSubscriber()` Return the subscriber associated with this context.
`protected SyncInfo` `getSyncInfo​(IResource resource)` Return the sync info for the given resource.
`protected void` `initialize()` Initialize the diff tree of this context.
`void` `refresh​(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor)` Refresh the context in order to update the diff tree returned by `ISynchronizationContext.getDiffTree()` to include the latest synchronization state for the resources.
`protected void` `runInBackground​(IWorkspaceRunnable runnable)` Run the given runnable when the background handler for this context is idle.

### Methods inherited from class org.eclipse.team.core.mapping.provider.MergeContext

`ensureParentsExist, getMergeRule, getMergeRule, getMergeType, makeInSync, markAsMerged, merge, merge, performReplace, performThreeWayMerge, reject, run`

### Methods inherited from class org.eclipse.team.core.mapping.provider.SynchronizationContext

`getCache, getDiffTree, getScope, getScopeManager, getType, refresh`

### 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.mapping.IMergeContext

`markAsMerged, reject`

### Methods inherited from interface org.eclipse.team.core.mapping.ISynchronizationContext

`getCache, getDiffTree, getScope, getType, refresh`

### Constructor Detail

#### SubscriberMergeContext

    protected SubscriberMergeContext​(Subscriber subscriber,
                                     ISynchronizationScopeManager manager)

Create a merge context for the given subscriber

Parameters:
  `subscriber` - the subscriber
  `manager` - the scope manager

### Method Detail

#### initialize

    protected void initialize()

Initialize the diff tree of this context. This method must be called before the context is given to clients.

#### getDiffFilter

    protected DiffFilter getDiffFilter()

Return the diff filter used to filter the differences that the merge context will present to clients.

Returns:
  the diff filter used to filter the differences that the merge context will present to clients
Since:
  3.3

#### refresh

    public void refresh​(ResourceTraversal[] traversals,
                        int flags,
                        IProgressMonitor monitor)
                 throws CoreException

Description copied from interface: `ISynchronizationContext`
Refresh the context in order to update the diff tree returned by `ISynchronizationContext.getDiffTree()` to include the latest synchronization state for the resources. Any changes will be reported through the change listeners registered with the diff tree of this context.

Changes to the diff tree may be triggered by a call to this method or by a refresh triggered by some other source. Hence, the callback from the diff tree to report changes may occur in the same thread as the refresh or asynchronously in a separate thread, regardless of who triggered the refresh.

Parameters:
  `traversals` - the resource traversals which indicate which resources are to be refreshed
  `flags` - additional refresh behavior. For instance, if `RemoteResourceMappingContext.FILE_CONTENTS_REQUIRED` is one of the flags, this indicates that the client will be accessing the contents of the files covered by the traversals. `NONE` should be used when no additional behavior is required
  `monitor` - a progress monitor, or `null` if progress reporting is not desired
Throws:
  `CoreException` - if the refresh fails. Reasons include:
  - The server could not be contacted for some reason (e.g. the context in which the operation is being called must be short running). The status code will be SERVER_CONTACT_PROHIBITED.
See Also:
  `ISynchronizationContext.getDiffTree()`, `IDiffTree.addDiffChangeListener(IDiffChangeListener)`

#### dispose

    public void dispose()

Description copied from interface: `ISynchronizationContext`
Dispose of the synchronization context and the cache of the context. This method should be invoked by clients when the context is no longer needed.

Specified by:
  `dispose` in interface `ISynchronizationContext`
Overrides:
  `dispose` in class `SynchronizationContext`

#### getSyncInfo

    protected SyncInfo getSyncInfo​(IResource resource)
                            throws CoreException

Return the sync info for the given resource.

Parameters:
  `resource` - the resource
Returns:
  the sync info for the resource obtained from the subscriber
Throws:
  `CoreException` - if an error occurs

#### getSubscriber

    public Subscriber getSubscriber()

Return the subscriber associated with this context.

Returns:
  the subscriber associated with this context

#### runInBackground

    protected void runInBackground​(IWorkspaceRunnable runnable)

Run the given runnable when the background handler for this context is idle. The given runnable should not lock the workspace.

Parameters:
  `runnable` - the runnable

#### getAdapter

    public <T> T getAdapter​(Class<T> adapter)

Description copied from class: `PlatformObject`
Returns an object which is an instance of the given class associated with this object. Returns `null` if no such object can be found.

This implementation of the method declared by `IAdaptable` passes the request along to the platform's adapter manager; roughly `Platform.getAdapterManager().getAdapter(this, adapter)`. Subclasses may override this method (however, if they do so, they should invoke the method on their superclass to ensure that the Platform's adapter manager is consulted).

Specified by:
  `getAdapter` in interface `IAdaptable`
Overrides:
  `getAdapter` in class `MergeContext`
Type Parameters:
  `T` - the class type
Parameters:
  `adapter` - the class to adapt to
Returns:
  the adapted object or `null`
See Also:
  `IAdaptable.getAdapter(Class)`