Package org.eclipse.ui.actions
Class PartEventAction
- java.lang.Object
-
- org.eclipse.core.commands.common.EventManager
-
- org.eclipse.jface.action.AbstractAction
-
- org.eclipse.jface.action.Action
-
- org.eclipse.ui.actions.PartEventAction
-
- All Implemented Interfaces:
IAction,IPartListener
- Direct Known Subclasses:
RetargetAction
public abstract class PartEventAction extends Action implements IPartListener
The abstract superclass for actions that listen to part activation and open/close events. This implementation tracks the active part (seegetActivePart) and provides a convenient place to monitor part lifecycle events that could affect the availability of the action.Subclasses must implement the following
IActionmethod:run- to do the action's work
Subclasses may extend any of the
IPartListenermethods if the action availablity needs to be recalculated:partActivatedpartDeactivatedpartOpenedpartClosedpartBroughtToTop
Although this method implements the
IPartListenerinterface, it does NOT register itself.
-
-
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
Constructors Modifier Constructor Description protectedPartEventAction(String text)Creates a new action with the given text.protectedPartEventAction(String text, int style)Creates a new action with the given text and style.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IWorkbenchPartgetActivePart()Returns the currently active part in the workbench.voidpartActivated(IWorkbenchPart part)ThePartEventActionimplementation of thisIPartListenermethod records that the given part is active.voidpartBroughtToTop(IWorkbenchPart part)ThePartEventActionimplementation of thisIPartListenermethod does nothing.voidpartClosed(IWorkbenchPart part)ThePartEventActionimplementation of thisIPartListenermethod clears the active part if it just closed.voidpartDeactivated(IWorkbenchPart part)ThePartEventActionimplementation of thisIPartListenermethod records that there is no active part.voidpartOpened(IWorkbenchPart part)ThePartEventActionimplementation of thisIPartListenermethod does nothing.-
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, runWithEvent, 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 Detail
-
PartEventAction
protected PartEventAction(String text)
Creates a new action with the given text.- Parameters:
text- the action's text, ornullif there is no text
-
PartEventAction
protected PartEventAction(String text, int style)
Creates a new action with the given text and style.- Parameters:
text- the action's text, ornullif there is no textstyle- one ofAS_PUSH_BUTTON,AS_CHECK_BOX,AS_DROP_DOWN_MENU,AS_RADIO_BUTTON, andAS_UNSPECIFIED- Since:
- 3.0
-
-
Method Detail
-
getActivePart
public IWorkbenchPart getActivePart()
Returns the currently active part in the workbench.- Returns:
- currently active part in the workbench, or
nullif none
-
partActivated
public void partActivated(IWorkbenchPart part)
ThePartEventActionimplementation of thisIPartListenermethod records that the given part is active. Subclasses may extend this method if action availability has to be recalculated.- Specified by:
partActivatedin interfaceIPartListener- Parameters:
part- the part that was activated- See Also:
IWorkbenchPage.activate(org.eclipse.ui.IWorkbenchPart)
-
partBroughtToTop
public void partBroughtToTop(IWorkbenchPart part)
ThePartEventActionimplementation of thisIPartListenermethod does nothing. Subclasses should extend this method if action availability has to be recalculated.- Specified by:
partBroughtToTopin interfaceIPartListener- Parameters:
part- the part that was surfaced- See Also:
IWorkbenchPage.bringToTop(org.eclipse.ui.IWorkbenchPart)
-
partClosed
public void partClosed(IWorkbenchPart part)
ThePartEventActionimplementation of thisIPartListenermethod clears the active part if it just closed. Subclasses may extend this method if action availability has to be recalculated.- Specified by:
partClosedin interfaceIPartListener- Parameters:
part- the part that was closed- See Also:
IWorkbenchPage.hideView(IViewPart)
-
partDeactivated
public void partDeactivated(IWorkbenchPart part)
ThePartEventActionimplementation of thisIPartListenermethod records that there is no active part. Subclasses may extend this method if action availability has to be recalculated.- Specified by:
partDeactivatedin interfaceIPartListener- Parameters:
part- the part that was deactivated- See Also:
IWorkbenchPage.activate(IWorkbenchPart)
-
partOpened
public void partOpened(IWorkbenchPart part)
ThePartEventActionimplementation of thisIPartListenermethod does nothing. Subclasses should extend this method if action availability has to be recalculated.- Specified by:
partOpenedin interfaceIPartListener- Parameters:
part- the part that was opened- See Also:
IWorkbenchPage.showView(String)
-
-