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 String
ASYNCHRONOUS
the 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 anAction
object with a default description string and default icon.AbstractBaseAction(String name)
Defines anAction
object with the specified description string and a default icon.AbstractBaseAction(String name, String icon)
Defines anAction
object with the specified description string and a the specified icon.AbstractBaseAction(String name, Icon icon)
Defines anAction
object with the specified description string and a the specified icon.AbstractBaseAction(Icon icon)
Defines anAction
object with the specified icon.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(ActionEvent e)
Invoked when an action occurs.void
cleanUp()
Cleans up data structures, frees up memory.protected abstract void
doActionPerformed(ActionEvent e)
Invoked when an action occurs.KeyStroke
getAccelerator()
Returns the accelerator (KeyStroke) in use for the action.Icon
getIcon()
Returns the icon the action (stored under SMALL_ICON).Integer
getMnemonic()
Returns the mnemonic in use for the action.String
getName()
Returns the name of the action, i.e., the menuitem/button caption.String
getToolTipText()
Returns the TipText in use for the action.boolean
hasAccelerator()
Checks whether a keystroke is available for this action.boolean
hasIcon()
Checks whether an icon is present.boolean
hasMnemonic()
Checks whether a mnemonic is available for this action.boolean
hasToolTipText()
Checks whether a tip text is available for this action.protected void
initialize()
Initializes the action.boolean
isAsynchronous()
Returns whether to launch the menu item asynchronously using a swingworker.boolean
isSelected()
Returns the name of the action, i.e., the menuitem/button caption.protected void
postActionPerformed(ActionEvent e)
Invoked when an action occurs (hook method after executing the actual action code).protected void
preActionPerformed(ActionEvent e)
Invoked when an action occurs (hook method before executing the actual action code).void
setAccelerator(String value)
Sets the accelerator (KeyStroke) to use for the action.void
setAsynchronous(boolean value)
Sets whether to launch the menu item asynchronously using a swingworker.void
setIcon(String name)
Sets the icon of the action, i.e., the menuitem/button icon.void
setIcon(Icon value)
Sets the icon of the action, i.e., the menuitem/button icon.void
setMnemonic(int value)
Sets the mnemonic to use for the action.void
setName(String value)
Sets the name of the action, i.e., the menuitem/button caption.void
setSelected(boolean value)
Sets the name of the action, i.e., the menuitem/button caption.void
setToolTipText(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 anAction
object with a default description string and default icon.
-
AbstractBaseAction
public AbstractBaseAction(String name)
Defines anAction
object with the specified description string and a default icon.- Parameters:
name
- the description
-
AbstractBaseAction
public AbstractBaseAction(String name, Icon icon)
Defines anAction
object with the specified description string and a the specified icon.- Parameters:
name
- the descriptionicon
- the icon
-
AbstractBaseAction
public AbstractBaseAction(String name, String icon)
Defines anAction
object 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 anAction
object 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:
setName
in interfaceBaseAction
- Parameters:
value
- the name
-
getName
public String getName()
Returns the name of the action, i.e., the menuitem/button caption.- Specified by:
getName
in interfaceBaseAction
- Returns:
- the name
-
setIcon
public void setIcon(String name)
Sets the icon of the action, i.e., the menuitem/button icon.- Specified by:
setIcon
in 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:
setIcon
in interfaceBaseAction
- Parameters:
value
- the icon
-
getIcon
public Icon getIcon()
Returns the icon the action (stored under SMALL_ICON).- Specified by:
getIcon
in 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:
setSelected
in interfaceBaseAction
- Parameters:
value
- the name
-
isSelected
public boolean isSelected()
Returns the name of the action, i.e., the menuitem/button caption.- Specified by:
isSelected
in interfaceBaseAction
- Returns:
- the name
-
setMnemonic
public void setMnemonic(int value)
Sets the mnemonic to use for the action.- Specified by:
setMnemonic
in 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:
hasMnemonic
in interfaceBaseAction
- Returns:
- true if a mnemonic is available
-
getMnemonic
public Integer getMnemonic()
Returns the mnemonic in use for the action.- Specified by:
getMnemonic
in 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:
setAccelerator
in 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:
hasAccelerator
in interfaceBaseAction
- Returns:
- true if a keystroke is available
-
getAccelerator
public KeyStroke getAccelerator()
Returns the accelerator (KeyStroke) in use for the action.- Specified by:
getAccelerator
in 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:
setToolTipText
in interfaceBaseAction
- Parameters:
value
- the tip text
-
hasToolTipText
public boolean hasToolTipText()
Checks whether a tip text is available for this action.- Specified by:
hasToolTipText
in interfaceBaseAction
- Returns:
- true if a tip text is available
-
getToolTipText
public String getToolTipText()
Returns the TipText in use for the action.- Specified by:
getToolTipText
in 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:
setAsynchronous
in interfaceBaseAction
- Parameters:
value
- true if asynchronous
-
isAsynchronous
public boolean isAsynchronous()
Returns whether to launch the menu item asynchronously using a swingworker.- Specified by:
isAsynchronous
in 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:
actionPerformed
in interfaceActionListener
- Parameters:
e
- the event
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.
Default implementation does nothing.- Specified by:
cleanUp
in interfaceBaseAction
- Specified by:
cleanUp
in interfaceCleanUpHandler
-
-