Class SwingAction

All Implemented Interfaces:
Activatable, ActionListener, Serializable, Cloneable, EventListener, Action
Direct Known Subclasses:
CascadeWindowAction, CheckForUpdateAction, DataRequestAction, DisplayDisablementExplanationAction, EvalScriptAction, GoToSnapshotAction, HelpContentsAction, HelpIndexAction, HelpSearchAction, HistoryAction, LaunchWindowDialogWindowAction, Log4jPrefsAction, RedoAction, SwingWorkersAction, ThreadPrefsAction, TileHorizontallyWindowAction, TileVerticallyWindowAction, UndoAction

public abstract class SwingAction extends AbstractActivateableAction
Wraps actions so that enablement and errors can be more easily handled. If the wrapped ActionListener.actionPerformed(ActionEvent) throws an exception, the decorator will catch the error and display a friendly dialog. If any other class has reason to disable the action, the decorator can add it to a list and ensure that the action remains disabled until the list is empty. This approach should greatly simplify disablements that occur because of busy threads. In general, the underlying action should always be enabled.
See Also:
  • Field Details

    • ELIPSIS

      public static final String ELIPSIS
      String suffix that indicates that an action requires further input from a user prior to completion.
      See Also:
  • Constructor Details

    • SwingAction

      protected SwingAction()
    • SwingAction

      protected SwingAction(String pText)
      See Also:
    • SwingAction

      protected SwingAction(String pText, Icon pIcon)
      Parameters:
      pText - Action name.
      pIcon - Action icon.
  • Method Details

    • getModifiers

      protected int getModifiers()
    • decorateAction

      public static SwingAction decorateAction(Action pAction)
      Wrap an ordinary action in a SwingAction. The wrapped action's "actionPerformed" method must be able to accept a null parameter.
      Parameters:
      pAction - Wrapped action.
      Returns:
      A SwingAction that wraps an ordinary action.
    • actionPerformed

      public final void actionPerformed(ActionEvent pEvt)
      Try to perform wrapped action. On error, display a dialog.
    • addElipsis

      protected void addElipsis()
    • execute

      public abstract void execute()
      Perform action.