Package org.eclipse.team.ui.mapping

## Interface ITeamStateProvider

All Known Implementing Classes:
  `SubscriberTeamStateProvider`, `TeamStateProvider`

    public interface ITeamStateProvider

A team state provider is used by the `SynchronizationStateTester` to obtain the team state for model elements. A team state provider is associated with a `RepositoryProviderType` using the adaptable mechanism. A default decoration provider that uses the subscriber of the type is provided.

This interface is not intended to be implemented by clients. Clients should instead subclass `TeamStateProvider` or `SubscriberTeamStateProvider`.

Since:
  3.2
See Also:
  `IAdapterManager`, `RepositoryProviderType`, `RepositoryProviderType.getSubscriber()`, `TeamStateProvider`, `SubscriberTeamStateProvider`, `SynchronizationStateTester`

### Field Summary

Fields
`static int` `USE_DECORATED_STATE_MASK` A state mask that can be passed to the `getStateDescription(Object, int, String[], IProgressMonitor)` method to indicate that only the decorated state flags are desired.

### Method Summary

All Methods Instance Methods Abstract Methods
`void` `addDecoratedStateChangeListener​(ITeamStateChangeListener listener)` Add a decorated state change listener to the provider.
`String[]` `getDecoratedProperties​(Object element)` Return the set of property identifiers that represent the set of properties that the team decorator would decorate for the given model element.
`int` `getDecoratedStateMask​(Object element)` Return the mask that indicates what state the appropriate team decorator is capable of decorating.
`ResourceMappingContext` `getResourceMappingContext​(Object element)` Return a resource mapping context that gives access to the remote state of the resources associated with the provider.
`ITeamStateDescription` `getStateDescription​(Object element, int stateMask, String[] properties, IProgressMonitor monitor)` Return the state description for the given element.
`boolean` `hasDecoratedState​(Object element)` Return whether the given element has any decorated state.
`boolean` `isDecorationEnabled​(Object element)` Return whether decoration is enabled for the given model element.
`void` `removeDecoratedStateChangeListener​(ITeamStateChangeListener listener)` Remove the decorated state change listener to the provider.

### Field Detail

#### USE_DECORATED_STATE_MASK

    static final int USE_DECORATED_STATE_MASK

A state mask that can be passed to the `getStateDescription(Object, int, String[], IProgressMonitor)` method to indicate that only the decorated state flags are desired. It is equivalent to passing he mask returned from `getDecoratedStateMask(Object)`;

See Also:
  Constant Field Values

### Method Detail

#### isDecorationEnabled

    boolean isDecorationEnabled​(Object element)

Return whether decoration is enabled for the given model element. If decoration is not enabled, the model does not need to fire label change events when the team state of the element changes.

Parameters:
  `element` - the model element
Returns:
  whether decoration is enabled for the given model element

#### hasDecoratedState

    boolean hasDecoratedState​(Object element)
                       throws CoreException

Return whether the given element has any decorated state.

Parameters:
  `element` - the element being decorated
Returns:
  whether the given element has any decorated state
Throws:
  `CoreException` - if an error occurs

#### getDecoratedStateMask

    int getDecoratedStateMask​(Object element)

Return the mask that indicates what state the appropriate team decorator is capable of decorating. Clients can used this to obtain the current decorated state from `getStateDescription(Object, int, String[], IProgressMonitor)` in order to determine if the decorated state has changed.

The state mask can consist of the following standard flags:

- The diff kinds of `IDiff.ADD`, `IDiff.REMOVE` and `IDiff.CHANGE`.
- The directions `IThreeWayDiff.INCOMING` and `IThreeWayDiff.OUTGOING`.

For convenience sake, if there are no kind flags but there is at least one direction flag then all kinds are assumed.

The mask can also consist of flag bits that are unique to the repository provider associated with the resources that the element maps to.

Parameters:
  `element` - the model element to be decorated
Returns:
  the mask that indicates what state the appropriate team decorator will decorate
See Also:
  `IDiff`, `IThreeWayDiff`

#### getDecoratedProperties

    String[] getDecoratedProperties​(Object element)

Return the set of property identifiers that represent the set of properties that the team decorator would decorate for the given model element.

Parameters:
  `element` - the model element to be decorated
Returns:
  the set of decorated properties

#### getStateDescription

    ITeamStateDescription getStateDescription​(Object element,
                                              int stateMask,
                                              String[] properties,
                                              IProgressMonitor monitor)
                                       throws CoreException

Return the state description for the given element. A `null` is return if the element is not decorated or if decoration is disabled. Only the portion of the synchronization state covered by `stateMask` is returned. The `stateMask` should be `USE_DECORATED_STATE_MASK` or the mask returned from `getDecoratedStateMask(Object)` and the requested properties should be `null` or the value returned from `getDecoratedProperties(Object)` if the client wishes to obtain the current decorated state.

Parameters:
  `element` - the model element
  `stateMask` - the mask that identifies which synchronization state flags are desired if present
  `properties` - the set of properties that should be included in the result or `null` if the decorated properties are desired
  `monitor` - a progress monitor
Returns:
  the state for the given element or `null`
Throws:
  `CoreException` - if an error occurs

#### getResourceMappingContext

    ResourceMappingContext getResourceMappingContext​(Object element)

Return a resource mapping context that gives access to the remote state of the resources associated with the provider. If a `RemoteResourceMappingContext` is returned, then the client may access the remote state.

Parameters:
  `element` - the element for which remote contents are desired
Returns:
  a resource mapping context that gives access to the remote state of the resources associated with the provider

#### addDecoratedStateChangeListener

    void addDecoratedStateChangeListener​(ITeamStateChangeListener listener)

Add a decorated state change listener to the provider. Adding the same listener more than once has no effect.

Parameters:
  `listener` - the listener

#### removeDecoratedStateChangeListener

    void removeDecoratedStateChangeListener​(ITeamStateChangeListener listener)

Remove the decorated state change listener to the provider. Removing a listener that is not registered has no effect.

Parameters:
  `listener` - the listener