org.fife.ui.app
Class StandardAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.fife.ui.app.StandardAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
Direct Known Subclasses:
CapsLockAction, CheckForUpdatesAction, GoToMemberAction, GUIApplication.AboutAction, GUIApplication.ExitAction, GUIApplication.HelpAction, GUIApplication.ToggleStatusBarAction, GUIApplication.ToggleToolBarAction, NextDocumentAction, RunMacroAction, StopAction, StopAction, ViewTasksAction

public abstract class StandardAction
extends javax.swing.AbstractAction

The action type used by all instances of GUIApplication. This is merely an action with many ease-of-use methods.

Version:
0.6
Author:
Robert Futrell
See Also:
GUIApplication, Serialized Form

Field Summary
static java.lang.String DEFAULT_ACCELERATOR
          A property specific to StandardActions (though other custom actions can certainly use it) that stores the default accelerator for the action.
 
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
StandardAction(GUIApplication app)
          Creates the action.
StandardAction(GUIApplication app, java.util.ResourceBundle msg, java.lang.String key)
          Creates an action, initializing its properties from a resource bundle.
StandardAction(GUIApplication app, java.lang.String key)
          Creates an action, initializing its properties from the parent application's resource bundle.
StandardAction(GUIApplication app, java.lang.String key, java.lang.String icon)
          Creates an action, initializing its properties from the parent application's resource bundle.
 
Method Summary
 javax.swing.KeyStroke getAccelerator()
          Returns the accelerator for this action.
 GUIApplication getApplication()
          Returns the application.
 javax.swing.KeyStroke getDefaultAccelerator()
          Returns the default accelerator for this action.
 javax.swing.Icon getIcon()
          Returns the icon for this action.
 int getMnemonic()
          Returns the mnemonic for this action.
 java.lang.String getName()
          Returns the name of this action.
 java.lang.String getShortDescription()
          Returns the short description for this action.
 void setAccelerator(javax.swing.KeyStroke accelerator)
          Sets the accelerator for this action.
 void setDefaultAccelerator(javax.swing.KeyStroke accelerator)
          Sets the default accelerator for this action.
 void setIcon(javax.swing.Icon icon)
          Sets the icon of this action.
 void setIcon(java.lang.String res)
          Sets the icon of this action.
 void setIcon(java.net.URL res)
          Sets the icon of this action.
 void setMnemonic(int mnemonic)
          Sets the mnemonic for this action.
 void setName(java.lang.String name)
          Sets the name of this action.
 void setShortDescription(java.lang.String desc)
          Sets the short description for this action.
 
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 java.awt.event.ActionListener
actionPerformed
 

Field Detail

DEFAULT_ACCELERATOR

public static final java.lang.String DEFAULT_ACCELERATOR
A property specific to StandardActions (though other custom actions can certainly use it) that stores the default accelerator for the action. KeyStrokes should be stored with this key.

See Also:
Constant Field Values
Constructor Detail

StandardAction

public StandardAction(GUIApplication app)
Creates the action. The parent class should call setName(String), setIcon(String), or whatever other methods are necessary to set this action up.

Parameters:
app - The parent application.

StandardAction

public StandardAction(GUIApplication app,
                      java.lang.String key)
Creates an action, initializing its properties from the parent application's resource bundle. The name of the action is found using the specified key. If keys exist with the names: then those properties are set as well. Further, if an accelerator is defined, it is set as both the action's active accelerator and default accelerator.

Parameters:
app - The parent application.
key - The key in the bundle for the name of this action.

StandardAction

public StandardAction(GUIApplication app,
                      java.lang.String key,
                      java.lang.String icon)
Creates an action, initializing its properties from the parent application's resource bundle. The name of the action is found using the specified key. If keys exist with the names: then those properties are set as well. Further, if an accelerator is defined, it is set as both the action's active accelerator and default accelerator.

Parameters:
app - The parent application.
key - The key in the bundle for the name of this action.
icon - The name of the icon resource for this action, or null for no icon.

StandardAction

public StandardAction(GUIApplication app,
                      java.util.ResourceBundle msg,
                      java.lang.String key)
Creates an action, initializing its properties from a resource bundle. The name of the action is found using the specified key. If keys exist with the names: then those properties are set as well. Further, if an accelerator is defined, it is set as both the action's active accelerator and default accelerator.

Parameters:
app - The parent application.
msg - The bundle to localize from. If this is null, then app.getResourceBundle() is used.
key - The key in the bundle for the name of this action.
Method Detail

getAccelerator

public javax.swing.KeyStroke getAccelerator()
Returns the accelerator for this action.

Returns:
The accelerator.
See Also:
setAccelerator(KeyStroke)

getApplication

public GUIApplication getApplication()
Returns the application.

Returns:
The application.

getDefaultAccelerator

public javax.swing.KeyStroke getDefaultAccelerator()
Returns the default accelerator for this action. This is the accelerator that should be restored if the user chooses to "restore defaults" in the options dialog.

Returns:
The default accelerator.
See Also:
setDefaultAccelerator(KeyStroke), getAccelerator(), DEFAULT_ACCELERATOR

getIcon

public javax.swing.Icon getIcon()
Returns the icon for this action.

Returns:
The icon.
See Also:
setIcon(Icon)

getMnemonic

public int getMnemonic()
Returns the mnemonic for this action.

Returns:
The mnemonic, or -1 if not defined.
See Also:
setMnemonic(int)

getName

public java.lang.String getName()
Returns the name of this action.

Returns:
The name of this action.
See Also:
setName(String)

getShortDescription

public java.lang.String getShortDescription()
Returns the short description for this action.

Returns:
The description.
See Also:
setShortDescription(String)

setAccelerator

public void setAccelerator(javax.swing.KeyStroke accelerator)
Sets the accelerator for this action.

Parameters:
accelerator - The new accelerator, or null for none.
See Also:
getAccelerator(), setDefaultAccelerator(KeyStroke)

setDefaultAccelerator

public void setDefaultAccelerator(javax.swing.KeyStroke accelerator)
Sets the default accelerator for this action. Applications typically won't call this method directly, as the default accelerator is usually set from the properties file we're loaded from.

Parameters:
accelerator - The new default accelerator, which may be null.
See Also:
getDefaultAccelerator(), setAccelerator(KeyStroke), DEFAULT_ACCELERATOR

setIcon

public void setIcon(javax.swing.Icon icon)
Sets the icon of this action.

Parameters:
icon - The icon.
See Also:
getIcon(), setIcon(String), setIcon(URL)

setIcon

public void setIcon(java.lang.String res)
Sets the icon of this action. This method is equivalent to:
setIcon(getClass().getResource(res))
.

Parameters:
res - The resource containing the icon.
See Also:
getIcon(), setIcon(URL), setIcon(Icon)

setIcon

public void setIcon(java.net.URL res)
Sets the icon of this action.

Parameters:
res - The resource containing the icon.
See Also:
getIcon(), setIcon(String), setIcon(Icon)

setMnemonic

public void setMnemonic(int mnemonic)
Sets the mnemonic for this action.

Parameters:
mnemonic - The new mnemonic. A value of -1 means "no mnemonic."
See Also:
getMnemonic()

setName

public void setName(java.lang.String name)
Sets the name of this action.

Parameters:
name - The name of this action.
See Also:
getName()

setShortDescription

public void setShortDescription(java.lang.String desc)
Sets the short description for this action.

Parameters:
desc - The description.
See Also:
getShortDescription()