Package org.eclipse.team.ui.synchronize
Class ModelParticipantAction
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.jface.action.AbstractAction
org.eclipse.jface.action.Action
org.eclipse.ui.actions.BaseSelectionListenerAction
org.eclipse.team.ui.synchronize.ModelParticipantAction
- All Implemented Interfaces:
IAction
,ISelectionChangedListener
Model provider actions for use with a
ModelSynchronizeParticipant
.- Since:
- 3.2
-
Field Summary
Fields inherited from interface org.eclipse.jface.action.IAction
AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, AS_RADIO_BUTTON, AS_UNSPECIFIED, CHECKED, DESCRIPTION, ENABLED, HANDLED, IMAGE, RESULT, TEXT, TOOL_TIP_TEXT
-
Constructor Summary
ConstructorDescriptionModelParticipantAction
(String text, ISynchronizePageConfiguration configuration) Create the model participant action. -
Method Summary
Modifier and TypeMethodDescriptionprotected SaveableComparison
Return the currently active saveable.protected ISynchronizePageConfiguration
Return the page configuration.protected ISynchronizationContext
Return the synchronization context associated with this action.protected SaveableComparison
Return the saveable that is the target of this operation.protected void
Check to see if the target saveable differs from the currently active saveable.static void
handleTargetSaveableChange
(Shell shell, SaveableComparison targetSaveable, SaveableComparison activeSaveable, boolean allowCancel, IProgressMonitor monitor) Convenience method that prompts if the currently active saveable is dirty and either saves or reverts the saveable depending on the users input.protected abstract boolean
isEnabledForSelection
(IStructuredSelection selection) Return whether the action is enabled for the given selectionprotected boolean
Return whether the given node is visible in the page based on the mode in the configuration.static boolean
promptToSaveChanges
(Shell shell, SaveableComparison saveable, boolean allowCancel) Convenience method that prompts to save changes in the given dirty model.void
selectionChanged
(ISelection selection) Set the selection of this action to the given selectionprotected void
setActiveSaveable
(SaveableComparison saveable) Set the active saveable.void
Method called when the action is about to be shown in a context menu.protected boolean
updateSelection
(IStructuredSelection selection) Updates this action in response to the given selection.Methods inherited from class org.eclipse.ui.actions.BaseSelectionListenerAction
clearCache, getStructuredSelection, runWithEvent, selectionChanged, selectionChanged
Methods inherited from class org.eclipse.jface.action.Action
convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, run, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
Methods inherited from class org.eclipse.jface.action.AbstractAction
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Constructor Details
-
ModelParticipantAction
Create the model participant action.- Parameters:
text
- the label of the action ornull
configuration
- the configuration for the page that is surfacing the action
-
-
Method Details
-
getConfiguration
Return the page configuration.- Returns:
- the page configuration
-
selectionChanged
Set the selection of this action to the given selection- Parameters:
selection
- the selection
-
updateSelection
Description copied from class:BaseSelectionListenerAction
Updates this action in response to the given selection.The
BaseSelectionListenerAction
implementation of this method returnstrue
. Subclasses may extend to react to selection changes; however, if the super method returnsfalse
, the overriding method must also returnfalse
.- Overrides:
updateSelection
in classBaseSelectionListenerAction
- Parameters:
selection
- the new selection- Returns:
true
if the action should be enabled for this selection, andfalse
otherwise
-
isEnabledForSelection
Return whether the action is enabled for the given selection- Parameters:
selection
- the selection- Returns:
- whether the action is enabled for the given selection
-
getSynchronizationContext
Return the synchronization context associated with this action.- Returns:
- the synchronization context associated with this action
-
isVisible
Return whether the given node is visible in the page based on the mode in the configuration.- Parameters:
node
- a diff node- Returns:
- whether the given node is visible in the page
-
handleTargetSaveableChange
Check to see if the target saveable differs from the currently active saveable. If it does, prompt to save changes in the active saveable if it is dirty.- Throws:
InterruptedException
- if operation is interruptedInvocationTargetException
- if an error occurs
-
handleTargetSaveableChange
public static void handleTargetSaveableChange(Shell shell, SaveableComparison targetSaveable, SaveableComparison activeSaveable, boolean allowCancel, IProgressMonitor monitor) throws CoreException, InterruptedException Convenience method that prompts if the currently active saveable is dirty and either saves or reverts the saveable depending on the users input.- Parameters:
shell
- a parent shelltargetSaveable
- the new saveableactiveSaveable
- the current saveableallowCancel
- whether canceling the action is an optionmonitor
- a progress monitor- Throws:
CoreException
- if an error occursInterruptedException
- if operation is interrupted
-
promptToSaveChanges
public static boolean promptToSaveChanges(Shell shell, SaveableComparison saveable, boolean allowCancel) throws InterruptedException Convenience method that prompts to save changes in the given dirty model.- Parameters:
shell
- a shellsaveable
- a dirty saveable modelallowCancel
- whether canceling the action is an option- Returns:
- whether the user choose to save (
true
) or revert (false
() the model - Throws:
InterruptedException
- thrown if the user choose to cancel
-
getActiveSaveable
Return the currently active saveable. By default, the active saveable is obtained from the synchronization page configuration.- Returns:
- the currently active saveable (or
null
if no buffer is active).
-
setActiveSaveable
Set the active saveable. By default to active saveable is stored with the synchronize page configuration.- Parameters:
saveable
- the saveable that is now active (ornull
if no saveable is active).
-
getTargetSaveable
Return the saveable that is the target of this operation. By default,null
is returned.- Returns:
- the saveable that is the target of this operation
-
updateEnablement
public void updateEnablement()Method called when the action is about to be shown in a context menu. This method recalculates the enablement for the current selection and uses that to set the enablement.
-