Eclipse Platform
Release 3.2

org.eclipse.team.ui.mapping
Class MergeActionHandler

java.lang.Object
  extended byorg.eclipse.core.commands.common.EventManager
      extended byorg.eclipse.core.commands.AbstractHandler
          extended byorg.eclipse.team.ui.mapping.MergeActionHandler
All Implemented Interfaces:
IHandler

public abstract class MergeActionHandler
extends AbstractHandler

An abstract superclass that enables models to create handlers for the basic merge operations (merge, overwrite and mark-as-merged). This class makes use of a SynchronizationOperation to determine its enablement state and execute the handler. Enablement is detemermined using SynchronizationOperation.shouldRun() and the handler will invoke TeamOperation.run() when executed.

EXPERIMENTAL. This class or interface has been added as part of a work in progress. There is a guarantee neither that this API will work nor that it will remain the same. Please do not use this API without consulting with the Platform/Team team.

Since:
3.2
See Also:
SynchronizationActionProvider

Constructor Summary
MergeActionHandler(ISynchronizePageConfiguration configuration)
          Create the handler.
 
Method Summary
 void dispose()
          Deregister this handler from selection change events.
 Object execute(ExecutionEvent event)
          Executes with the map of parameter values by name.
protected  ISynchronizePageConfiguration getConfiguration()
          Return the configuration of the synchronize page that is surfacing the merge action to which this handler is registered.
static IHandler getDefaultHandler(String mergeActionId, ISynchronizePageConfiguration configuration)
          Return an instance of the default handler for the given merge action id.
protected abstract  SynchronizationOperation getOperation()
          Return the synchronizatio operation that performs the merge operaton.
protected  IStructuredSelection getStructuredSelection()
          Return the current selection.
 ISaveableCompareModel getTargetBuffer()
          Return the buffer that is the target of this handler.
 boolean isEnabled()
          Whether this handler is capable of executing at this time.
protected  void setEnabled(boolean isEnabled)
          Set the enablement of this handler.
protected  void updateEnablement(IStructuredSelection selection)
          Update the enablement of this handler for the new selection.
 
Methods inherited from class org.eclipse.core.commands.AbstractHandler
addHandlerListener, fireHandlerChanged, hasListeners, isHandled, removeHandlerListener
 
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MergeActionHandler

public MergeActionHandler(ISynchronizePageConfiguration configuration)
Create the handler.

Parameters:
configuration - the configiuration for the synchronize page displaying the model.
Method Detail

getDefaultHandler

public static IHandler getDefaultHandler(String mergeActionId,
                                         ISynchronizePageConfiguration configuration)
Return an instance of the default handler for the given merge action id.

Parameters:
mergeActionId - the merge action id
configuration - the ynchronization page configuration
Returns:
the default handler for the given nerge action or null

dispose

public void dispose()
Deregister this handler from selection change events.

Specified by:
dispose in interface IHandler
Overrides:
dispose in class AbstractHandler
See Also:
IHandler.dispose()

updateEnablement

protected void updateEnablement(IStructuredSelection selection)
Update the enablement of this handler for the new selection. By default, this method uses the shouldRun method of the handler's operation to determine the enablement of this handler. Subclasses may override but should either still invoke this method or setEnabled(boolean) to set the enablement.

Parameters:
selection - the selection

getConfiguration

protected final ISynchronizePageConfiguration getConfiguration()
Return the configuration of the synchronize page that is surfacing the merge action to which this handler is registered.

Returns:
the synchronize page configuration

getStructuredSelection

protected final IStructuredSelection getStructuredSelection()
Return the current selection.

Returns:
the current selection.

isEnabled

public boolean isEnabled()
Description copied from class: AbstractHandler
Whether this handler is capable of executing at this time. Subclasses may override this method.

Specified by:
isEnabled in interface IHandler
Overrides:
isEnabled in class AbstractHandler
Returns:
true

setEnabled

protected void setEnabled(boolean isEnabled)
Set the enablement of this handler.

Parameters:
isEnabled - whether the handelr is enabled

execute

public Object execute(ExecutionEvent event)
               throws ExecutionException
Description copied from interface: IHandler
Executes with the map of parameter values by name.

Parameters:
event - An event containing all the information about the current state of the application; must not be null.
Returns:
the result of the execution. Reserved for future use, must be null.
Throws:
ExecutionException - if an exception occurred during execution.

getOperation

protected abstract SynchronizationOperation getOperation()
Return the synchronizatio operation that performs the merge operaton.

Returns:
a synchronization operation

getTargetBuffer

public ISaveableCompareModel getTargetBuffer()
Return the buffer that is the target of this handler. By default, null is returned.

Returns:
the buffer that is the target of this operation

Eclipse Platform
Release 3.2

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.