Class PageEventAction
- All Implemented Interfaces:
IAction,ActionFactory.IWorkbenchAction,IPageListener,IPartListener
- Direct Known Subclasses:
CloseAllSavedAction,NavigationHistoryAction
getActivePage) and provides a convenient place to monitor page
lifecycle events that could affect the availability of the action.
Subclasses must implement the following IAction method:
run- to do the action's work
Subclasses may extend any of the IPartListener methods if the
action availablity needs to be recalculated:
partActivatedpartDeactivatedpartOpenedpartClosedpartBroughtToTop
Subclasses may extend any of the IPageListener methods if the
action availability needs to be recalculated:
pageActivatedpageClosedpageOpened
This method implements the IPartListener and
IPageListenerinterfaces, and automatically registers listeners
so that it can keep its enablement state up to date. Ordinarily, the window's
references to these listeners will be dropped automatically when the window
closes. However, if the client needs to get rid of an action while the window
is still open, the client must call dispose
to give the action an opportunity to deregister its listeners and to perform
any other cleanup.
-
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
ConstructorsModifierConstructorDescriptionprotectedPageEventAction(String text, IWorkbenchWindow window) Creates a new action with the given text. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()ThePageEventActionimplementation of thisActionFactory.IWorkbenchActionmethod deregisters the part and page listener adding by the constructor.final IWorkbenchPageReturns the currently active page in the workbench window.final IWorkbenchWindowReturns the workbench window this action applies to.voidpageActivated(IWorkbenchPage page) ThePageEventActionimplementation of thisIPageListenermethod records that the given page is active.voidpageClosed(IWorkbenchPage page) ThePageEventActionimplementation of thisIPageListenermethod clears the active page if it just closed.voidpageOpened(IWorkbenchPage page) ThePageEventActionimplementation of thisIPageListenermethod does nothing.Methods inherited from class org.eclipse.ui.actions.PartEventAction
getActivePart, partActivated, partBroughtToTop, partClosed, partDeactivated, partOpenedMethods 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, setToolTipTextMethods inherited from class org.eclipse.jface.action.AbstractAction
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListenerMethods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.jface.action.IAction
addPropertyChangeListener, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, removePropertyChangeListener, run, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
-
Constructor Details
-
PageEventAction
Creates a new action with the given text. Register this action with the workbench window for page lifecycle events.- Parameters:
text- the string used as the text for the action, ornullif there is no textwindow- the workbench window this action is registered with
-
-
Method Details
-
getActivePage
Returns the currently active page in the workbench window.- Returns:
- currently active page in the workbench window, or
nullin none
-
getWorkbenchWindow
Returns the workbench window this action applies to.- Returns:
- the workbench window, or
nullif this action has been disposed
-
pageActivated
ThePageEventActionimplementation of thisIPageListenermethod records that the given page is active. Subclasses may extend this method if action availability has to be recalculated.- Specified by:
pageActivatedin interfaceIPageListener- Parameters:
page- the page that was activated- See Also:
-
pageClosed
ThePageEventActionimplementation of thisIPageListenermethod clears the active page if it just closed. Subclasses may extend this method if action availability has to be recalculated.- Specified by:
pageClosedin interfaceIPageListener- Parameters:
page- the page that was closed- See Also:
-
pageOpened
ThePageEventActionimplementation of thisIPageListenermethod does nothing. Subclasses should extend this method if action availability has to be recalculated.- Specified by:
pageOpenedin interfaceIPageListener- Parameters:
page- the page that was opened- See Also:
-
dispose
public void dispose()ThePageEventActionimplementation of thisActionFactory.IWorkbenchActionmethod deregisters the part and page listener adding by the constructor. Subclasses should extend this method to do additional cleanup.- Specified by:
disposein interfaceActionFactory.IWorkbenchAction- Since:
- 3.0
-