Class PageEventAction

All Implemented Interfaces:
IAction, ActionFactory.IWorkbenchAction, IPageListener, IPartListener
Direct Known Subclasses:
CloseAllSavedAction, NavigationHistoryAction

public abstract class PageEventAction extends PartEventAction implements IPageListener, ActionFactory.IWorkbenchAction
The abstract superclass for actions that listen to page activation and open/close events. This implementation tracks the active page (see 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 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.

  • Constructor Details

    • PageEventAction

      protected PageEventAction(String text, IWorkbenchWindow window)
      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, or null if there is no text
      window - the workbench window this action is registered with
  • Method Details

    • getActivePage

      public final IWorkbenchPage getActivePage()
      Returns the currently active page in the workbench window.
      Returns:
      currently active page in the workbench window, or null in none
    • getWorkbenchWindow

      public final IWorkbenchWindow getWorkbenchWindow()
      Returns the workbench window this action applies to.
      Returns:
      the workbench window, or null if this action has been disposed
    • pageActivated

      public void pageActivated(IWorkbenchPage page)
      The PageEventAction implementation of this IPageListener method records that the given page is active. Subclasses may extend this method if action availability has to be recalculated.
      Specified by:
      pageActivated in interface IPageListener
      Parameters:
      page - the page that was activated
      See Also:
    • pageClosed

      public void pageClosed(IWorkbenchPage page)
      The PageEventAction implementation of this IPageListener 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 interface IPageListener
      Parameters:
      page - the page that was closed
      See Also:
    • pageOpened

      public void pageOpened(IWorkbenchPage page)
      The PageEventAction implementation of this IPageListener method does nothing. Subclasses should extend this method if action availability has to be recalculated.
      Specified by:
      pageOpened in interface IPageListener
      Parameters:
      page - the page that was opened
      See Also:
    • dispose

      public void dispose()
      The PageEventAction implementation of this ActionFactory.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 interface ActionFactory.IWorkbenchAction
      Since:
      3.0