Package org.eclipse.team.ui.synchronize

## Class AbstractSynchronizeParticipant

- java.lang.Object
- - org.eclipse.core.runtime.PlatformObject
  - - org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant

All Implemented Interfaces:
  `IAdaptable`, `IExecutableExtension`, `ISynchronizeParticipant`

Direct Known Subclasses:
  `ModelSynchronizeParticipant`, `SubscriberParticipant`

    public abstract class AbstractSynchronizeParticipant
    extends PlatformObject
    implements ISynchronizeParticipant

This class is the abstract base class for all synchronize view participants. Clients must subclass this class instead of directly implementing `ISynchronizeParticipant`.

This class provides lifecycle support and hooks for configuration of synchronize view pages.

Since:
  3.0
See Also:
  `ISynchronizeParticipant`

### Field Summary

Fields
`protected IConfigurationElement` `configElement`
`static String` `P_PINNED` Property key used in the property change event fired when the pinned state of a participant changes.
`static String` `P_SCHEDULED` Property key used in the property change event fired when the participants refresh schedule changes.

### Fields inherited from interface org.eclipse.team.ui.synchronize.ISynchronizeParticipant

`P_CONTENT`

### Constructor Summary

Constructors
`AbstractSynchronizeParticipant()` Default constructor is a no-op.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`void` `addPropertyChangeListener​(IPropertyChangeListener listener)` Adds a listener for changes to properties of this synchronize participant.
`ISynchronizePageConfiguration` `createPageConfiguration()` Creates the configuration for the participant page.
`boolean` `doesSupportSynchronize()` Return whether this participant can be refreshed.
`boolean` `equals​(Object obj)`
`void` `firePropertyChange​(Object source, String property, Object oldValue, Object newValue)` Notify all listeners that the given property has changed.
`String` `getHelpContextId()` Returns the help context id of this participant or value of `IHelpContextIds.SYNC_VIEW` when no specific id has been provided.
`String` `getId()` Returns the unique id that identified the type of this synchronize participant.
`ImageDescriptor` `getImageDescriptor()` Returns an image descriptor for this synchronize participant, or `null` if none.
`String` `getName()` Returns the name of this synchronize participant.
`PreferencePage[]` `getPreferencePages()` Return the list of preference pages that are associated with this participant
`String` `getSecondaryId()` Returns the instance id that identified the unique instance of this participant.
`int` `hashCode()`
`void` `init​(String secondaryId, IMemento memento)` Classes that are persisted must override this method and perform the following initialization.
`protected abstract void` `initializeConfiguration​(ISynchronizePageConfiguration configuration)` This method is invoked after a page configuration is created but before it is returned by the `createPageConfiguration` method.
`boolean` `isPinned()` Returns if this participant is pinned.
`protected boolean` `isViewerContributionsSupported()` Return whether this participant supports the contribution of actions to the context menu by contributing a `viewerContribution` to the `org.eclipse.ui.popupMenus` extension point.
`protected void` `pinned​(boolean pinned)` Called when the pinned state is changed.
`void` `prepareCompareInput​(ISynchronizeModelElement element, CompareConfiguration config, IProgressMonitor monitor)` Default implementation will update the labels in the given configuration using information from the provided element if it adapts to `SyncInfo`.
`void` `removePropertyChangeListener​(IPropertyChangeListener listener)` Removes the given property listener from this synchronize participant.
`void` `saveState​(IMemento memento)` Saves the participants object state within the memento.
`protected void` `setImageDescriptor​(ImageDescriptor imageDescriptor)` Sets the image descriptor for this participant to the specified value and notifies property listeners of the change.
`void` `setInitializationData​(IConfigurationElement config, String propertyName, Object data)` This method is called by the implementation of the method `IConfigurationElement.createExecutableExtension` on a newly constructed extension, passing it its relevant configuration information.
`protected void` `setInitializationData​(ISynchronizeParticipantDescriptor descriptor)`
`protected void` `setName​(String name)` Sets the name of this participant to the specified value and notifies property listeners of the change.
`void` `setPinned​(boolean pinned)` Sets whether this participant is pinned.
`protected void` `setSecondaryId​(String secondaryId)` Sets the secondary id for this participant.

### Methods inherited from class org.eclipse.core.runtime.PlatformObject

`getAdapter`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.eclipse.core.runtime.IAdaptable

`getAdapter`

### Methods inherited from interface org.eclipse.team.ui.synchronize.ISynchronizeParticipant

`createPage, dispose, run`

### Field Detail

#### P_PINNED

    public static final String P_PINNED

Property key used in the property change event fired when the pinned state of a participant changes.

See Also:
  Constant Field Values

#### P_SCHEDULED

    public static final String P_SCHEDULED

Property key used in the property change event fired when the participants refresh schedule changes.

Since:
  3.2
See Also:
  Constant Field Values

#### configElement

    protected IConfigurationElement configElement

### Constructor Detail

#### AbstractSynchronizeParticipant

    public AbstractSynchronizeParticipant()

Default constructor is a no-op. Subclasses that are persistable must support a no-arg constructor and

### Method Detail

#### getName

    public String getName()

Description copied from interface: `ISynchronizeParticipant`
Returns the name of this synchronize participant. This name is displayed to the user.

Specified by:
  `getName` in interface `ISynchronizeParticipant`
Returns:
  the name of this synchronize participant

#### getImageDescriptor

    public ImageDescriptor getImageDescriptor()

Description copied from interface: `ISynchronizeParticipant`
Returns an image descriptor for this synchronize participant, or `null` if none.

Specified by:
  `getImageDescriptor` in interface `ISynchronizeParticipant`
Returns:
  an image descriptor for this synchronize participant, or `null` if none

#### getId

    public String getId()

Description copied from interface: `ISynchronizeParticipant`
Returns the unique id that identified the type of this synchronize participant. The synchronize manager supports registering several instances of the same participant type.

Specified by:
  `getId` in interface `ISynchronizeParticipant`
Returns:
  the unique id that identified the type of this synchronize participant.

#### getSecondaryId

    public String getSecondaryId()

Description copied from interface: `ISynchronizeParticipant`
Returns the instance id that identified the unique instance of this participant. The synchronize manager supports registering several instances of the same participant type and this id is used to differentiate between them.

Specified by:
  `getSecondaryId` in interface `ISynchronizeParticipant`
Returns:
  the instance id that identified the unique instance of this participant or `null` if this participant doesn't support multiple instances.

#### getHelpContextId

    public String getHelpContextId()

Returns the help context id of this participant or value of `IHelpContextIds.SYNC_VIEW` when no specific id has been provided.

Specified by:
  `getHelpContextId` in interface `ISynchronizeParticipant`
Returns:
  the help context id of this participant
Since:
  3.5
See Also:
  `ISynchronizeParticipant.getHelpContextId()`, `IHelpContextIds.SYNC_VIEW`
Restriction:
  This method is not intended to be re-implemented or extended by clients.

#### setPinned

    public final void setPinned​(boolean pinned)

Description copied from interface: `ISynchronizeParticipant`
Sets whether this participant is pinned.

Specified by:
  `setPinned` in interface `ISynchronizeParticipant`
Parameters:
  `pinned` - sets if the participant is pinned.

#### isPinned

    public final boolean isPinned()

Description copied from interface: `ISynchronizeParticipant`
Returns if this participant is pinned. Pinned participants will only be removed from the synchronize manager until they are un-pinned.

Specified by:
  `isPinned` in interface `ISynchronizeParticipant`
Returns:
  `true` if this participant is pinned and `false` otherwise.

#### pinned

    protected void pinned​(boolean pinned)

Called when the pinned state is changed. Allows subclasses to react to pin state changes.

Parameters:
  `pinned` - whether the participant is pinned.

#### equals

    public boolean equals​(Object obj)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### doesSupportSynchronize

    public boolean doesSupportSynchronize()

Return whether this participant can be refreshed. Participants that can be refreshed may have a Synchronize menu item contributed to their context menu and can also be refreshed from the Synchronize drop-down toolbar item. When refreshed from the toolbar item, the `ISynchronizeParticipant.run(org.eclipse.ui.IWorkbenchPart)` method is called.

Returns:
  whether this participant can be refreshed

#### addPropertyChangeListener

    public void addPropertyChangeListener​(IPropertyChangeListener listener)

Description copied from interface: `ISynchronizeParticipant`
Adds a listener for changes to properties of this synchronize participant. Has no effect if an identical listener is already registered.

The changes supported by the synchronize view are as follows:

- `IBasicPropertyConstants.P_TEXT`- indicates the name of a synchronize participant has changed
- `IBasicPropertyConstants.P_IMAGE`- indicates the image of a synchronize participant has changed

Clients may define additional properties as required.

Specified by:
  `addPropertyChangeListener` in interface `ISynchronizeParticipant`
Parameters:
  `listener` - a property change listener

#### removePropertyChangeListener

    public void removePropertyChangeListener​(IPropertyChangeListener listener)

Description copied from interface: `ISynchronizeParticipant`
Removes the given property listener from this synchronize participant. Has no effect if an identical listener is not already registered.

Specified by:
  `removePropertyChangeListener` in interface `ISynchronizeParticipant`
Parameters:
  `listener` - a property listener

#### firePropertyChange

    public void firePropertyChange​(Object source,
                                   String property,
                                   Object oldValue,
                                   Object newValue)

Notify all listeners that the given property has changed.

Parameters:
  `source` - the object on which a property has changed
  `property` - identifier of the property that has changed
  `oldValue` - the old value of the property, or `null`
  `newValue` - the new value of the property, or `null`

#### setInitializationData

    public void setInitializationData​(IConfigurationElement config,
                                      String propertyName,
                                      Object data)
                               throws CoreException

Description copied from interface: `IExecutableExtension`
This method is called by the implementation of the method `IConfigurationElement.createExecutableExtension` on a newly constructed extension, passing it its relevant configuration information. Most executable extensions only make use of the first two call arguments.

Regular executable extensions specify their Java implementation class name as an attribute of the configuration element for the extension. For example

         <action run="com.example.BaseAction"/>

In the above example, this method would be called with a reference to the `<action>` element (first argument), and `"run"` as the name of the attribute that defined this executable extension (second argument).

The last parameter is for the specific use of extension adapters and is typically not used by regular executable extensions.

There are two supported ways of associating additional adapter-specific data with the configuration in a way that is transparent to the extension point implementor:

(1) by specifying adapter data as part of the implementation class attribute value. The Java class name can be followed by a ":" separator, followed by any adapter data in string form. For example, if the extension point specifies an attribute `"run"` to contain the name of the extension implementation, an adapter can be configured as

         <action run="com.example.ExternalAdapter:./cmds/util.exe -opt 3"/>

(2) by converting the attribute used to specify the executable extension to a child element of the original configuration element, and specifying the adapter data in the form of xml markup. Using this form, the example above would become

         <action>
             <run class="com.xyz.ExternalAdapter">
                 <parameter name="exec" value="./cmds/util.exe"/>
                 <parameter name="opt"  value="3"/>
             </run>
         </action>

Form (2) will typically only be used for extension points that anticipate the majority of extensions configured into it will in fact be in the form of adapters.

In either case, the specified adapter class is instantiated using its 0-argument public constructor. The adapter data is passed as the last argument of this method. The data argument is defined as Object. It can have the following values:

- `null`, if no adapter data was supplied
- in case (1), the initialization data string is passed as a `String`
- in case (2), the initialization data is passed as a `Hashtable` containing the actual parameter names and values (both `String`s)

Specified by:
  `setInitializationData` in interface `IExecutableExtension`
Parameters:
  `config` - the configuration element used to trigger this execution. It can be queried by the executable extension for specific configuration properties
  `propertyName` - the name of an attribute of the configuration element used on the `createExecutableExtension(String)` call. This argument can be used in the cases where a single configuration element is used to define multiple executable extensions.
  `data` - adapter data in the form of a `String`, a `Hashtable`, or `null`.
Throws:
  `CoreException` - if error(s) detected during initialization processing
See Also:
  `IConfigurationElement.createExecutableExtension(String)`

#### setInitializationData

    protected void setInitializationData​(ISynchronizeParticipantDescriptor descriptor)
                                  throws CoreException

Throws:
  `CoreException`

#### setName

    protected void setName​(String name)

Sets the name of this participant to the specified value and notifies property listeners of the change.

Parameters:
  `name` - the new name

#### setImageDescriptor

    protected void setImageDescriptor​(ImageDescriptor imageDescriptor)

Sets the image descriptor for this participant to the specified value and notifies property listeners of the change.

Parameters:
  `imageDescriptor` - the new image descriptor

#### setSecondaryId

    protected void setSecondaryId​(String secondaryId)

Sets the secondary id for this participant.

Parameters:
  `secondaryId` - the secondary id for this participant.

#### init

    public void init​(String secondaryId,
                     IMemento memento)
              throws PartInitException

Classes that are persisted must override this method and perform the following initialization.

                    super.init(secondaryId, memento);
                    try {
                            ISynchronizeParticipantDescriptor descriptor = TeamUI.getSynchronizeManager().getParticipantDescriptor(PARTICIPANT_ID);
                            setInitializationData(descriptor);
                    } catch (CoreException e) {
                            TeamUIPlugin.log(e);
                    }

where `PARTICIPANT_ID` is the id of the participant as defined in the plugin manifest.

Specified by:
  `init` in interface `ISynchronizeParticipant`
Parameters:
  `secondaryId` - the secondayId of this participant instance or `null` if this participant doesn't support multiple instances.
  `memento` - the participant state or `null` if there is no previous saved state
Throws:
  `PartInitException` - if this participant was not initialized successfully
See Also:
  `ISynchronizeParticipant.init(String, org.eclipse.ui.IMemento)`

#### saveState

    public void saveState​(IMemento memento)

Description copied from interface: `ISynchronizeParticipant`
Saves the participants object state within the memento. This state will be available when the participant is restored via `init`.

This method can be called multiple times during the lifetime of the participant object.

Specified by:
  `saveState` in interface `ISynchronizeParticipant`
Parameters:
  `memento` - a memento to receive the object state

#### createPageConfiguration

    public final ISynchronizePageConfiguration createPageConfiguration()

Description copied from interface: `ISynchronizeParticipant`
Creates the configuration for the participant page. The configuration controls the options for displaying the participant. The configuration used to initialize the page when `ISynchronizeParticipant.createPage(ISynchronizePageConfiguration)` is called and as such can be used to pre-configure visual properties of the displayed page.

Specified by:
  `createPageConfiguration` in interface `ISynchronizeParticipant`
Returns:
  the configuration for the participant page.

#### initializeConfiguration

    protected abstract void initializeConfiguration​(ISynchronizePageConfiguration configuration)

This method is invoked after a page configuration is created but before it is returned by the `createPageConfiguration` method. Subclasses can implement this method to tailor the configuration in ways appropriate to the participant.

Parameters:
  `configuration` - the newly create page configuration

#### prepareCompareInput

    public void prepareCompareInput​(ISynchronizeModelElement element,
                                    CompareConfiguration config,
                                    IProgressMonitor monitor)
                             throws TeamException

Default implementation will update the labels in the given configuration using information from the provided element if it adapts to `SyncInfo`. It will also cache the contents for the remote and base if the element is sync info based.

Specified by:
  `prepareCompareInput` in interface `ISynchronizeParticipant`
Parameters:
  `element` - the sync model element whose contents are about to be displayed to the user in a compare editor or compare dialog
  `config` - the compare configuration that will be used to configure the compare editor or dialog
  `monitor` - a progress monitor that can be used if contacting a server to prepare the element and configuration
Throws:
  `TeamException` - if an error occurred that should prevent the display of the compare editor containing the element
Since:
  3.1
See Also:
  `ISynchronizeParticipant.prepareCompareInput(org.eclipse.team.ui.synchronize.ISynchronizeModelElement, org.eclipse.compare.CompareConfiguration, org.eclipse.core.runtime.IProgressMonitor)`

#### getPreferencePages

    public PreferencePage[] getPreferencePages()

Description copied from interface: `ISynchronizeParticipant`
Return the list of preference pages that are associated with this participant

Specified by:
  `getPreferencePages` in interface `ISynchronizeParticipant`
Returns:
  the list of preference pages that are associated with this participant

#### isViewerContributionsSupported

    protected boolean isViewerContributionsSupported()

Return whether this participant supports the contribution of actions to the context menu by contributing a `viewerContribution` to the `org.eclipse.ui.popupMenus` extension point. By default, `false` is returned. If a subclasses overrides to return `true`, the `id` of the participant is used as the `targetId`. Here is an extension that could be added to the plugin manifest to contribute an action to the context menu for a participant

        <extension point="org.eclipse.ui.popupMenus">
                    <viewerContribution
                 id="org.eclipse.team.cvs.ui.viewContributionId"
                 targetID="org.eclipse.team.cvs.ui.cvsworkspace-participant">
                            <action
                    label="Add"
                    menubarPath="additions"
                    tooltip="Add a file to CVS version control"
                    class="org.eclipse.team.internal.ccvs.ui.actions.AddAction"
                    helpContextId="org.eclipse.team.cvs.ui.workspace_subscriber_add"
                    id="org.eclipse.team.ccvs.ui.CVSWorkspaceSubscriber.add">
              </action>
                    </viewerContribution>
       </extension>

Returns:
  whether this participant supports the contribution of actions to the context menu using the `org.eclipse.ui.popupMenus` extension point
Since:
  3.1