Class ModelSynchronizeParticipant

All Implemented Interfaces:
IAdaptable, IExecutableExtension, ISynchronizeParticipant

public class ModelSynchronizeParticipant extends AbstractSynchronizeParticipant
Synchronize participant that obtains it's synchronization state from a ISynchronizationContext.

This class may be subclassed by clients.

Since:
3.2
  • Field Details

    • P_VISIBLE_MODEL_PROVIDER

      public static final String P_VISIBLE_MODEL_PROVIDER
      Property constant used to store and retrieve the id of the active ModelProvider from an ISynchronizePageConfiguration. The active model provider will be the only one visible in the page. If null or ALL_MODEL_PROVIDERS_ACTIVE is returned, all model providers are considered active and are visible.
      See Also:
    • ALL_MODEL_PROVIDERS_VISIBLE

      public static final String ALL_MODEL_PROVIDERS_VISIBLE
      Constant used with the P_ACTIVE_MODEL_PROVIDER property to indicate that all enabled model providers are active.
      See Also:
    • PROP_ENABLED_MODEL_PROVIDERS

      public static final String PROP_ENABLED_MODEL_PROVIDERS
      Property constant used during property change notification to indicate that the enabled model providers for this participant have changed.
      See Also:
    • PROP_ACTIVE_SAVEABLE

      public static final String PROP_ACTIVE_SAVEABLE
      Property constant used during property change notification to indicate that the active model of this participant has changed.
      See Also:
    • PROP_DIRTY

      public static final String PROP_DIRTY
      Property constant used during property change notification to indicate that the dirty state for the active saveable model of this participant has changed.
      See Also:
  • Constructor Details

    • ModelSynchronizeParticipant

      public ModelSynchronizeParticipant(SynchronizationContext context)
      Create a participant for the given context
      Parameters:
      context - the synchronization context
    • ModelSynchronizeParticipant

      public ModelSynchronizeParticipant()
      Create a participant in order to restore it from saved state.
  • Method Details

    • createParticipant

      public static ModelSynchronizeParticipant createParticipant(SynchronizationContext context, String name)
      Create a participant for the given context and name
      Parameters:
      context - the synchronization context
      name - the name of the participant
      Returns:
      a participant for the given context
    • 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
      Overrides:
      getName in class AbstractSynchronizeParticipant
      Returns:
      the name of this synchronize participant
    • getShortName

      protected final String getShortName()
      Return the name of the participant as specified in the plugin manifest file. This method is provided to give access to this name since it is masked by the getName() method defined in this class.
      Returns:
      the name of the participant as specified in the plugin manifest file
      Since:
      3.1
    • initializeConfiguration

      protected void initializeConfiguration(ISynchronizePageConfiguration configuration)
      Description copied from class: AbstractSynchronizeParticipant
      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.
      Specified by:
      initializeConfiguration in class AbstractSynchronizeParticipant
      Parameters:
      configuration - the newly create page configuration
    • createMergeActionGroup

      protected ModelSynchronizeParticipantActionGroup createMergeActionGroup()
      Create the merge action group for this participant. Subclasses can override in order to provide a merge action group that configures certain aspects of the merge actions.
      Returns:
      the merge action group for this participant
    • createPage

      public final IPageBookViewPage createPage(ISynchronizePageConfiguration configuration)
      Description copied from interface: ISynchronizeParticipant
      Creates and returns a new page for this synchronize participant. The page is displayed using the parameters from the configuration. For example, the configuration defines the context in which the page is shown, via the ISynchronizePageSite.
      Parameters:
      configuration - used to initialize the page
      Returns:
      a page book view page representation of this synchronize participant
    • run

      public void run(IWorkbenchPart part)
      Description copied from interface: ISynchronizeParticipant
      Runs the participants action. Typically this would be some action to refresh the synchronization state of the participant. This action is run from the global synchronize drop-down.
      Parameters:
      part - the part in which the action is run or null if the action is not being run in a workbench part.
    • refresh

      public final void refresh(IWorkbenchSite site, ResourceMapping[] mappings)
      Refresh a participant in the background the result of the refresh are shown in the progress view. Refreshing can also be considered synchronizing, or refreshing the synchronization state. Basically this is a long running operation that will update the participant's context with new changes detected on the server.
      Parameters:
      site - the workbench site the synchronize is running from. This can be used to notify the site that a job is running.
      mappings - the resource mappings to be refreshed
    • dispose

      public void dispose()
      Description copied from interface: ISynchronizeParticipant
      Disposes of this synchronize participant and is called to free the resources associated with a participant. When a participant is added to the ISynchronizeManager this method is called when the manager is shutdown or the participant is removed from the manager.

      Within this method a participant may release any resources, fonts, images, etc. held by this part. It is also very important to remove all listeners.

      Clients should not call this method (the synchronize manager calls this method at appropriate times).

    • initializeContext

      protected void initializeContext(SynchronizationContext context)
      Set the context of this participant. This method must be invoked before a page is obtained from the participant.
      Parameters:
      context - the context for this participant
    • getContext

      public ISynchronizationContext getContext()
      Return the synchronization context for this participant.
      Returns:
      the synchronization context for this participant
    • asCompareInput

      public ICompareInput asCompareInput(Object object)
      Return a compare input for the given model object or null if the object is not eligible for comparison.
      Parameters:
      object - the model object
      Returns:
      a compare input for the model object or null
    • hasCompareInputFor

      public boolean hasCompareInputFor(Object object)
      Return whether their is a compare input associated with the given object. In other words, return true if asCompareInput(Object) would return a value and false if it would return null.
      Parameters:
      object - the object.
      Returns:
      whether their is a compare input associated with the given object
    • isMergingEnabled

      public boolean isMergingEnabled()
      Return whether merge capabilities are enabled for this participant. If merging is enabled, merge actions can be shown. If merging is disabled, no merge actions should be surfaced.
      Returns:
      whether merge capabilities should be enabled for this participant
    • setMergingEnabled

      public void setMergingEnabled(boolean mergingEnabled)
      Set whether merge capabilities should be enabled for this participant.
      Parameters:
      mergingEnabled - whether merge capabilities should be enabled for this participant
    • getShortTaskName

      protected String getShortTaskName()
      Returns the short task name (e.g. no more than 25 characters) to describe the behavior of the refresh operation to the user. This is typically shown in the status line when this participant is refreshed in the background. When refreshed in the foreground, only the long task name is shown.
      Returns:
      the short task name to show in the status line.
    • getLongTaskName

      protected String getLongTaskName(ResourceMapping[] mappings)
      Returns the long task name to describe the behavior of the refresh operation to the user. This is typically shown in the status line when this subscriber is refreshed in the background.
      Parameters:
      mappings - the mappings being refreshed
      Returns:
      the long task name
      Since:
      3.1
    • 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 PlatformObject
      Type Parameters:
      T - the class type
      Parameters:
      adapter - the class to adapt to
      Returns:
      the adapted object or null
      See Also:
    • 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
      Overrides:
      saveState in class AbstractSynchronizeParticipant
      Parameters:
      memento - a memento to receive the object state
    • init

      public void init(String secondaryId, IMemento memento) throws PartInitException
      Description copied from class: AbstractSynchronizeParticipant
      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
      Overrides:
      init in class AbstractSynchronizeParticipant
      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:
    • restoreContext

      protected MergeContext restoreContext(ISynchronizationScopeManager manager) throws CoreException
      Recreate the context for this participant. This method is invoked when the participant is restored after a restart. Although it is provided with a progress monitor, long running operations should be avoided.
      Parameters:
      manager - the restored scope
      Returns:
      the context for this participant
      Throws:
      CoreException - if restoring context failed
    • createScopeManager

      protected ISynchronizationScopeManager createScopeManager(ResourceMapping[] mappings)
      Create and return a scope manager that can be used to build the scope of this participant when it is restored after a restart. By default, this method returns a scope manager that uses the local content. This method can be overridden by subclasses.
      Parameters:
      mappings - the restored mappings
      Returns:
      a scope manager that can be used to build the scope of this participant when it is restored after a restart
    • getActiveSaveable

      public SaveableComparison getActiveSaveable()
      Return the active saveable for this participant. There is at most one saveable active at any time.
      Returns:
      the active saveable for this participant or null
    • setActiveSaveable

      public void setActiveSaveable(SaveableComparison activeSaveable)
      Set the active saveable of this participant.
      Parameters:
      activeSaveable - the active saveable (may be null)
    • checkForBufferChange

      public boolean checkForBufferChange(Shell shell, ISynchronizationCompareInput input, boolean cancelAllowed, IProgressMonitor monitor) throws CoreException
      Convenience method for switching the active saveable of this participant to the saveable of the given input.
      Parameters:
      shell - a shell
      input - the compare input about to be displayed
      cancelAllowed - whether the display of the compare input can be canceled
      monitor - a progress monitor or null if progress reporting is not required
      Returns:
      whether the user choose to continue with the display of the given compare input
      Throws:
      CoreException - if an error occurs
    • getEnabledModelProviders

      public ModelProvider[] getEnabledModelProviders()
      Return the list of model providers that are enabled for the participant. By default, the list is those model providers that contain mappings in the scope. Subclasses may override to add additional model providers.
      Returns:
      the list of model providers that are active for the participant
    • 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
      Overrides:
      getPreferencePages in class AbstractSynchronizeParticipant
      Returns:
      the list of preference pages that are associated with this participant