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:
partActivated
partDeactivated
partOpened
partClosed
partBroughtToTop
Subclasses may extend any of the IPageListener
methods if the
action availability needs to be recalculated:
pageActivated
pageClosed
pageOpened
This method implements the IPartListener
and
IPageListener
interfaces, 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
ModifierConstructorDescriptionprotected
PageEventAction
(String text, IWorkbenchWindow window) Creates a new action with the given text. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
ThePageEventAction
implementation of thisActionFactory.IWorkbenchAction
method deregisters the part and page listener adding by the constructor.final IWorkbenchPage
Returns the currently active page in the workbench window.final IWorkbenchWindow
Returns the workbench window this action applies to.void
pageActivated
(IWorkbenchPage page) ThePageEventAction
implementation of thisIPageListener
method records that the given page is active.void
pageClosed
(IWorkbenchPage page) ThePageEventAction
implementation of thisIPageListener
method clears the active page if it just closed.void
pageOpened
(IWorkbenchPage page) ThePageEventAction
implementation of thisIPageListener
method does nothing.Methods inherited from class org.eclipse.ui.actions.PartEventAction
getActivePart, partActivated, partBroughtToTop, partClosed, partDeactivated, partOpened
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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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, ornull
if 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
null
in none
-
getWorkbenchWindow
Returns the workbench window this action applies to.- Returns:
- the workbench window, or
null
if this action has been disposed
-
pageActivated
ThePageEventAction
implementation of thisIPageListener
method records that the given page is active. Subclasses may extend this method if action availability has to be recalculated.- Specified by:
pageActivated
in interfaceIPageListener
- Parameters:
page
- the page that was activated- See Also:
-
pageClosed
ThePageEventAction
implementation of thisIPageListener
method clears the active page if it just closed. Subclasses may extend this method if action availability has to be recalculated.- Specified by:
pageClosed
in interfaceIPageListener
- Parameters:
page
- the page that was closed- See Also:
-
pageOpened
ThePageEventAction
implementation of thisIPageListener
method does nothing. Subclasses should extend this method if action availability has to be recalculated.- Specified by:
pageOpened
in interfaceIPageListener
- Parameters:
page
- the page that was opened- See Also:
-
dispose
public void dispose()ThePageEventAction
implementation of thisActionFactory.IWorkbenchAction
method deregisters the part and page listener adding by the constructor. Subclasses should extend this method to do additional cleanup.- Specified by:
dispose
in interfaceActionFactory.IWorkbenchAction
- Since:
- 3.0
-