- java.lang.Object
-
- javax.swing.AbstractAction
-
- com.iamsoft.util.ui.swing.activation.AbstractActivateableAction
-
- com.iamsoft.util.ui.swing.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringELIPSISString suffix that indicates that an action requires further input from a user prior to completion.-
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
-
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSwingAction()protectedSwingAction(String pText)protectedSwingAction(String pText, Icon pIcon)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(ActionEvent pEvt)Try to perform wrapped action.protected voidaddElipsis()static SwingActiondecorateAction(Action pAction)Wrap an ordinary action in a SwingAction.abstract voidexecute()Perform action.protected intgetModifiers()-
Methods inherited from class com.iamsoft.util.ui.swing.activation.AbstractActivateableAction
addActivationCriterion, getActivatableFacade, isDisplayingDisablementReasonsByDefault, isDisplayingDisablementReasonsByOverride, putValue, setDisplayingDisablementReasonsByDefault, setEnabled, stripTooltip
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, removePropertyChangeListener
-
-
-
-
Field Detail
-
ELIPSIS
public static final String ELIPSIS
String suffix that indicates that an action requires further input from a user prior to completion.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SwingAction
protected SwingAction()
-
SwingAction
protected SwingAction(String pText)
- See Also:
SwingAction(String, Icon)
-
-
Method Detail
-
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.
-
-