public abstract class WorkbenchPartAction extends Action implements Disposable, UpdateAction
IAdaptable.getAdapter(java.lang.Class)
.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 |
---|
WorkbenchPartAction(IWorkbenchPart part)
Constructs a WorkbenchPartAction for the given part.
|
WorkbenchPartAction(IWorkbenchPart part,
int style)
Constructs a WorkbenchPartAction for the given part and style.
|
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
calculateEnabled()
Calculates and returns the enabled state of this action.
|
void |
dispose()
Disposes the action when it is no longer needed.
|
protected void |
execute(Command command)
Executes the given
Command using the command stack. |
protected CommandStack |
getCommandStack()
Returns the editor's command stack.
|
protected IWorkbenchPart |
getWorkbenchPart()
Returns the workbench part given in the constructor
|
protected void |
init()
Initializes this action.
|
boolean |
isEnabled()
Returns
true if the action is enabled. |
protected void |
refresh()
Refreshes the properties of this action.
|
void |
setLazyEnablementCalculation(boolean value)
Sets lazy calculation of the isEnabled property.
|
protected void |
setWorkbenchPart(IWorkbenchPart part)
Sets the workbench part.
|
void |
update()
Called to update the receiver.
|
convertAccelerator, 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, setToolTipText
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
public WorkbenchPartAction(IWorkbenchPart part)
part
- the workbench partpublic WorkbenchPartAction(IWorkbenchPart part, int style)
part
- the workbench partstyle
- one of AS_PUSH_BUTTON
, AS_CHECK_BOX
,
AS_DROP_DOWN_MENU
, AS_RADIO_BUTTON
,
and AS_UNSPECIFIED
.protected abstract boolean calculateEnabled()
true
if the action is enabledpublic void dispose()
dispose
in interface Disposable
protected void execute(Command command)
Command
using the command stack. The stack is
obtained by calling getCommandStack()
, which uses
IAdapatable
to retrieve the stack from the workbench part.command
- the command to executeprotected CommandStack getCommandStack()
IAdaptable.getAdapter(java.lang.Class)
.protected IWorkbenchPart getWorkbenchPart()
protected void init()
public boolean isEnabled()
true
if the action is enabled. If the action
determines enablemenu lazily, then calculateEnabled()
is always
called. Otherwise, the enablement state set using
Action.setEnabled(boolean)
is returned.isEnabled
in interface IAction
isEnabled
in class Action
true
if the action is enabledsetLazyEnablementCalculation(boolean)
protected void refresh()
public void setLazyEnablementCalculation(boolean value)
true
, then the action will always use
calculateEnabled()
whenever isEnabled()
is called.
Sometimes a value of false
can be used to improve
performance and reduce the number of times calculateEnabled()
is
called. However, the client must then call the update()
method
at the proper times to force the update of enablement.
Sometimes a value of true
can be used to improve
performance. If an Action
only 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
.
value
- true
if the enablement should be lazyprotected void setWorkbenchPart(IWorkbenchPart part)
part
- the workbench partpublic void update()
UpdateAction
update
in interface UpdateAction
UpdateAction.update()
Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.