public abstract class ModelParticipantAction extends BaseSelectionListenerAction
ModelSynchronizeParticipant
.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 and Description |
---|
ModelParticipantAction(String text,
ISynchronizePageConfiguration configuration)
Create the model participant action.
|
Modifier and Type | Method and Description |
---|---|
protected SaveableComparison |
getActiveSaveable()
Return the currently active saveable.
|
protected ISynchronizePageConfiguration |
getConfiguration()
Return the page configuration.
|
protected ISynchronizationContext |
getSynchronizationContext()
Return the synchronization context associated with this action.
|
protected SaveableComparison |
getTargetSaveable()
Return the saveable that is the target of this operation.
|
protected void |
handleTargetSaveableChange()
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 selection
|
protected boolean |
isVisible(IDiff node)
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 selection
|
protected void |
setActiveSaveable(SaveableComparison saveable)
Set the active saveable.
|
void |
updateEnablement()
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.
|
clearCache, getStructuredSelection, runWithEvent, selectionChanged, selectionChanged
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
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
public ModelParticipantAction(String text, ISynchronizePageConfiguration configuration)
text
- the label of the action or null
configuration
- the configuration for the page that is surfacing the actionprotected ISynchronizePageConfiguration getConfiguration()
public void selectionChanged(ISelection selection)
selection
- the selectionprotected boolean updateSelection(IStructuredSelection selection)
BaseSelectionListenerAction
The BaseSelectionListenerAction
implementation of this method
returns true
. Subclasses may extend to react to selection
changes; however, if the super method returns false
, the
overriding method must also return false
.
updateSelection
in class BaseSelectionListenerAction
selection
- the new selectiontrue
if the action should be enabled for this selection,
and false
otherwiseprotected abstract boolean isEnabledForSelection(IStructuredSelection selection)
selection
- the selectionprotected ISynchronizationContext getSynchronizationContext()
protected boolean isVisible(IDiff node)
node
- a diff nodeprotected void handleTargetSaveableChange() throws InvocationTargetException, InterruptedException
public static void handleTargetSaveableChange(Shell shell, SaveableComparison targetSaveable, SaveableComparison activeSaveable, boolean allowCancel, IProgressMonitor monitor) throws CoreException, InterruptedException
shell
- a parent shelltargetSaveable
- the new saveableactiveSaveable
- the current saveableallowCancel
- whether canceling the action is an optionmonitor
- a progress monitorCoreException
InterruptedException
public static boolean promptToSaveChanges(Shell shell, SaveableComparison saveable, boolean allowCancel) throws InterruptedException
shell
- a shellsaveable
- a dirty saveable modelallowCancel
- whether canceling the action is an optiontrue
) or revert (false
() the modelInterruptedException
- thrown if the user choose to cancelprotected SaveableComparison getActiveSaveable()
null
if
no buffer is active).protected void setActiveSaveable(SaveableComparison saveable)
saveable
- the saveable that is now active (or null
if
no saveable is active).protected SaveableComparison getTargetSaveable()
null
is returned.public void updateEnablement()
Copyright (c) 2000, 2018 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.