Package org.eclipse.gef.ui.actions
Class WorkbenchPartAction
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.jface.action.AbstractAction
org.eclipse.jface.action.Action
org.eclipse.gef.ui.actions.WorkbenchPartAction
- All Implemented Interfaces:
- Disposable,- UpdateAction,- IAction
- Direct Known Subclasses:
- CopyTemplateAction,- EditorPartAction,- PrintAction,- SelectionAction,- StackAction
Base class for actions involving a WorkbenchPart. The workbench part is
 useful for obtaining data needed by the action. For example, selection can be
 obtained using the part's site. Anything can potentially be obtained using
 
IAdaptable.getAdapter(java.lang.Class).- 
Field SummaryFields inherited from interface org.eclipse.jface.action.IActionAS_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 SummaryConstructorsConstructorDescriptionConstructs a WorkbenchPartAction for the given part.WorkbenchPartAction(IWorkbenchPart part, int style) Constructs a WorkbenchPartAction for the given part and style.
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract booleanCalculates and returns the enabled state of this action.voiddispose()Disposes the action when it is no longer needed.protected voidExecutes the givenCommandusing the command stack.protected CommandStackReturns the editor's command stack.protected IWorkbenchPartReturns the workbench part given in the constructorprotected voidinit()Initializes this action.booleanReturnstrueif the action is enabled.protected voidrefresh()Refreshes the properties of this action.voidsetLazyEnablementCalculation(boolean value) Sets lazy calculation of the isEnabled property.protected voidSets the workbench part.voidupdate()Called to update the receiver.Methods inherited from class org.eclipse.jface.action.ActionconvertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, run, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipTextMethods inherited from class org.eclipse.jface.action.AbstractActionaddPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListenerMethods inherited from class org.eclipse.core.commands.common.EventManageraddListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
- 
Constructor Details- 
WorkbenchPartActionConstructs a WorkbenchPartAction for the given part.- Parameters:
- part- the workbench part
 
- 
WorkbenchPartActionConstructs a WorkbenchPartAction for the given part and style.- Parameters:
- part- the workbench part
- style- one of- AS_PUSH_BUTTON,- AS_CHECK_BOX,- AS_DROP_DOWN_MENU,- AS_RADIO_BUTTON, and- AS_UNSPECIFIED.
 
 
- 
- 
Method Details- 
calculateEnabledprotected abstract boolean calculateEnabled()Calculates and returns the enabled state of this action.- Returns:
- trueif the action is enabled
 
- 
disposepublic void dispose()Disposes the action when it is no longer needed.- Specified by:
- disposein interface- Disposable
 
- 
executeExecutes the givenCommandusing the command stack. The stack is obtained by callinggetCommandStack(), which usesIAdapatableto retrieve the stack from the workbench part.- Parameters:
- command- the command to execute
 
- 
getCommandStackReturns the editor's command stack. This is done by asking the workbench part for its CommandStack viaIAdaptable.getAdapter(java.lang.Class).- Returns:
- the command stack
 
- 
getWorkbenchPartReturns the workbench part given in the constructor- Returns:
- the workbench part
 
- 
initprotected void init()Initializes this action.
- 
isEnabledpublic boolean isEnabled()Returnstrueif the action is enabled. If the action determines enablemenu lazily, thencalculateEnabled()is always called. Otherwise, the enablement state set usingAction.setEnabled(boolean)is returned.
- 
refreshprotected void refresh()Refreshes the properties of this action.
- 
setLazyEnablementCalculationpublic void setLazyEnablementCalculation(boolean value) Sets lazy calculation of the isEnabled property. If this value is set totrue, then the action will always usecalculateEnabled()wheneverisEnabled()is called.Sometimes a value of falsecan be used to improve performance and reduce the number of timescalculateEnabled()is called. However, the client must then call theupdate()method at the proper times to force the update of enablement.Sometimes a value of truecan be used to improve performance. If anActiononly appears in a dynamic context menu, then there is no reason to agressively update its enablement status because the user cannot see the Action. Instead, its enablement only needs to be determined when asked for, or lazily.The default value for this setting is true.- Parameters:
- value-- trueif the enablement should be lazy
 
- 
setWorkbenchPartSets the workbench part.- Parameters:
- part- the workbench part
 
- 
updatepublic void update()Description copied from interface:UpdateActionCalled to update the receiver.- Specified by:
- updatein interface- UpdateAction
- See Also:
 
 
-