Package adams.gui.action
Class AbstractBaseAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- adams.gui.action.AbstractBaseAction
-
- All Implemented Interfaces:
CleanUpHandler,BaseAction,ActionListener,Serializable,Cloneable,EventListener,Action
- Direct Known Subclasses:
AbstractActionWithDialog,AbstractBaseActionWithGroup,AbstractEditableDataTableAction,AbstractFileCommanderAction,AbstractFindInFilesAction,AbstractLocalFilesAction,AbstractNotificationAreaAction,AbstractPDFViewerAction,AbstractPixelSelectorAction,AbstractSelectedAttributesAction,AbstractSource,AbstractTableAction,ToggleAction
public abstract class AbstractBaseAction extends AbstractAction implements BaseAction
Action with some methods added for convenience.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringASYNCHRONOUSthe key for the asynchronous flag.-
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 Constructor Description AbstractBaseAction()Defines anActionobject with a default description string and default icon.AbstractBaseAction(String name)Defines anActionobject with the specified description string and a default icon.AbstractBaseAction(String name, String icon)Defines anActionobject with the specified description string and a the specified icon.AbstractBaseAction(String name, Icon icon)Defines anActionobject with the specified description string and a the specified icon.AbstractBaseAction(Icon icon)Defines anActionobject with the specified icon.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(ActionEvent e)Invoked when an action occurs.voidcleanUp()Cleans up data structures, frees up memory.protected abstract voiddoActionPerformed(ActionEvent e)Invoked when an action occurs.KeyStrokegetAccelerator()Returns the accelerator (KeyStroke) in use for the action.IcongetIcon()Returns the icon the action (stored under SMALL_ICON).IntegergetMnemonic()Returns the mnemonic in use for the action.StringgetName()Returns the name of the action, i.e., the menuitem/button caption.StringgetToolTipText()Returns the TipText in use for the action.booleanhasAccelerator()Checks whether a keystroke is available for this action.booleanhasIcon()Checks whether an icon is present.booleanhasMnemonic()Checks whether a mnemonic is available for this action.booleanhasToolTipText()Checks whether a tip text is available for this action.protected voidinitialize()Initializes the action.booleanisAsynchronous()Returns whether to launch the menu item asynchronously using a swingworker.booleanisSelected()Returns the name of the action, i.e., the menuitem/button caption.protected voidpostActionPerformed(ActionEvent e)Invoked when an action occurs (hook method after executing the actual action code).protected voidpreActionPerformed(ActionEvent e)Invoked when an action occurs (hook method before executing the actual action code).voidsetAccelerator(String value)Sets the accelerator (KeyStroke) to use for the action.voidsetAsynchronous(boolean value)Sets whether to launch the menu item asynchronously using a swingworker.voidsetIcon(String name)Sets the icon of the action, i.e., the menuitem/button icon.voidsetIcon(Icon value)Sets the icon of the action, i.e., the menuitem/button icon.voidsetMnemonic(int value)Sets the mnemonic to use for the action.voidsetName(String value)Sets the name of the action, i.e., the menuitem/button caption.voidsetSelected(boolean value)Sets the name of the action, i.e., the menuitem/button caption.voidsetToolTipText(String value)Sets the TipText to use for the action, i.e., button.-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.swing.Action
accept, addPropertyChangeListener, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Field Detail
-
ASYNCHRONOUS
public static final String ASYNCHRONOUS
the key for the asynchronous flag.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractBaseAction
public AbstractBaseAction()
Defines anActionobject with a default description string and default icon.
-
AbstractBaseAction
public AbstractBaseAction(String name)
Defines anActionobject with the specified description string and a default icon.- Parameters:
name- the description
-
AbstractBaseAction
public AbstractBaseAction(String name, Icon icon)
Defines anActionobject with the specified description string and a the specified icon.- Parameters:
name- the descriptionicon- the icon
-
AbstractBaseAction
public AbstractBaseAction(String name, String icon)
Defines anActionobject with the specified description string and a the specified icon.- Parameters:
name- the descriptionicon- the icon file (without path)
-
AbstractBaseAction
public AbstractBaseAction(Icon icon)
Defines anActionobject with the specified icon.- Parameters:
icon- the icon
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the action.
-
setName
public void setName(String value)
Sets the name of the action, i.e., the menuitem/button caption.- Specified by:
setNamein interfaceBaseAction- Parameters:
value- the name
-
getName
public String getName()
Returns the name of the action, i.e., the menuitem/button caption.- Specified by:
getNamein interfaceBaseAction- Returns:
- the name
-
setIcon
public void setIcon(String name)
Sets the icon of the action, i.e., the menuitem/button icon.- Specified by:
setIconin interfaceBaseAction- Parameters:
name- the icon- See Also:
setIcon(Icon),ImageManager.getIcon(String)
-
setIcon
public void setIcon(Icon value)
Sets the icon of the action, i.e., the menuitem/button icon. Sets SMALL_ICON and LARGE_ICON_KEY at the same time.- Specified by:
setIconin interfaceBaseAction- Parameters:
value- the icon
-
getIcon
public Icon getIcon()
Returns the icon the action (stored under SMALL_ICON).- Specified by:
getIconin interfaceBaseAction- Returns:
- the icon
-
hasIcon
public boolean hasIcon()
Checks whether an icon is present.- Returns:
- true if present
-
setSelected
public void setSelected(boolean value)
Sets the name of the action, i.e., the menuitem/button caption.- Specified by:
setSelectedin interfaceBaseAction- Parameters:
value- the name
-
isSelected
public boolean isSelected()
Returns the name of the action, i.e., the menuitem/button caption.- Specified by:
isSelectedin interfaceBaseAction- Returns:
- the name
-
setMnemonic
public void setMnemonic(int value)
Sets the mnemonic to use for the action.- Specified by:
setMnemonicin interfaceBaseAction- Parameters:
value- the mnemonic, e.g., KeyEvent.VK_O- See Also:
KeyEvent
-
hasMnemonic
public boolean hasMnemonic()
Checks whether a mnemonic is available for this action.- Specified by:
hasMnemonicin interfaceBaseAction- Returns:
- true if a mnemonic is available
-
getMnemonic
public Integer getMnemonic()
Returns the mnemonic in use for the action.- Specified by:
getMnemonicin interfaceBaseAction- Returns:
- the mnemonic if available (e.g., KeyEvent.VK_O), otherwise null
- See Also:
hasMnemonic()
-
setAccelerator
public void setAccelerator(String value)
Sets the accelerator (KeyStroke) to use for the action.- Specified by:
setAcceleratorin interfaceBaseAction- Parameters:
value- the keystroke, e.g., "ctrl pressed O"- See Also:
KeyStroke.getKeyStroke(String)
-
hasAccelerator
public boolean hasAccelerator()
Checks whether a keystroke is available for this action.- Specified by:
hasAcceleratorin interfaceBaseAction- Returns:
- true if a keystroke is available
-
getAccelerator
public KeyStroke getAccelerator()
Returns the accelerator (KeyStroke) in use for the action.- Specified by:
getAcceleratorin interfaceBaseAction- Returns:
- the keystroke if available, otherwise null
- See Also:
hasAccelerator()
-
setToolTipText
public void setToolTipText(String value)
Sets the TipText to use for the action, i.e., button.- Specified by:
setToolTipTextin interfaceBaseAction- Parameters:
value- the tip text
-
hasToolTipText
public boolean hasToolTipText()
Checks whether a tip text is available for this action.- Specified by:
hasToolTipTextin interfaceBaseAction- Returns:
- true if a tip text is available
-
getToolTipText
public String getToolTipText()
Returns the TipText in use for the action.- Specified by:
getToolTipTextin interfaceBaseAction- Returns:
- the tip text if available, otherwise null
- See Also:
hasToolTipText()
-
setAsynchronous
public void setAsynchronous(boolean value)
Sets whether to launch the menu item asynchronously using a swingworker.- Specified by:
setAsynchronousin interfaceBaseAction- Parameters:
value- true if asynchronous
-
isAsynchronous
public boolean isAsynchronous()
Returns whether to launch the menu item asynchronously using a swingworker.- Specified by:
isAsynchronousin interfaceBaseAction- Returns:
- true if asynchronous
-
preActionPerformed
protected void preActionPerformed(ActionEvent e)
Invoked when an action occurs (hook method before executing the actual action code).
Default implementation does nothing.- Parameters:
e- the event
-
doActionPerformed
protected abstract void doActionPerformed(ActionEvent e)
Invoked when an action occurs.- Parameters:
e- the event
-
postActionPerformed
protected void postActionPerformed(ActionEvent e)
Invoked when an action occurs (hook method after executing the actual action code).
Default implementation does nothing.- Parameters:
e- the event
-
actionPerformed
public void actionPerformed(ActionEvent e)
Invoked when an action occurs.- Specified by:
actionPerformedin interfaceActionListener- Parameters:
e- the event
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.
Default implementation does nothing.- Specified by:
cleanUpin interfaceBaseAction- Specified by:
cleanUpin interfaceCleanUpHandler
-
-