|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.AbstractAction
com.mucommander.ui.action.MuAction
public abstract class MuAction
MuAction extends AbstractAction to add more functionalities and make it easier to integrate within
muCommander. The biggest difference with AbstractAction is that MuAction instances are bound to a
specific MainFrame.
Note that by being an Action, MuAction can be used in every Swing components that accept Action instances.
The MuAction class is abstract. MuAction subclasses must implement the performAction() method
to provide a response to the action trigger, and must provide a constructor with the
MuAction(MainFrame, java.util.Hashtable) signature.
MuAction subclasses should not be instanciated directly, ActionManager's getActionInstance
methods should be used instead. Using ActionManager to retrieve a MuAction ensures that only one instance
exists for a given MainFrame. This is particularly important because actions are stateful and can be used
in several components of a MainFrame at the same time; if an action's state changes, the change must be reflected
everywhere the action is used. It is also important for performance reasons: sharing one action throughout a
MainFrame saves some memory and also CPU cycles as some actions listen to particular events to change
their state accordingly.
ActionManager,
ActionKeymap,
Serialized Form| Field Summary | |
|---|---|
static java.lang.String |
ALTERNATE_ACCELERATOR_PROPERTY_KEY
Name of the alternate accelerator KeyStroke property |
protected MainFrame |
mainFrame
The MainFrame associated with this MuAction |
| 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 | |
|---|---|
MuAction(MainFrame mainFrame,
java.util.Hashtable properties)
Convenience constructor which has the same effect as calling MuAction(MainFrame, Hashtable, boolean, boolean, boolean )
with standard labels, icon and accelerators enabled. |
|
MuAction(MainFrame mainFrame,
java.util.Hashtable properties,
boolean useStandardLabels)
Convenience constructor which has the same effect as calling MuAction(MainFrame, Hashtable, boolean, boolean, boolean)
with standard icon and accelerators enabled. |
|
MuAction(MainFrame mainFrame,
java.util.Hashtable properties,
boolean useStandardLabels,
boolean useStandardIcon,
boolean useStandardAccelerators)
Creates a new MuAction associated with the specified MainFrame. |
|
| Method Summary | |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Intercepts action events and filters them out when the MainFrame associated with this action is in
'no events' mode and honourNoEventsMode() returns true. |
javax.swing.KeyStroke |
getAccelerator()
Returns the accelerator KeyStroke of this action, null if this action has no accelerator. |
java.lang.String |
getAcceleratorText()
Returns a displayable String representation of this action's accelerator, in the [modifier]+[modifier]+...+key format. |
javax.swing.KeyStroke |
getAlternateAccelerator()
Returns the alternate accelerator KeyStroke of this action, null if it doesn't have any. |
javax.swing.ImageIcon |
getIcon()
Return the icon of this action, null if this action has no icon. |
static java.lang.String |
getKeyStrokeRepresentation(javax.swing.KeyStroke ks)
Returns a String representation for the given KeyStroke, in the following format: modifier+modifier+...+key |
java.lang.String |
getLabel()
Returns the label of this action, null if this action has no label. |
MainFrame |
getMainFrame()
Return the MainFrame this MuAction is associated. |
static java.lang.String |
getModifiersRepresentation(int modifiers)
Returns a String representations of the given modifiers bitwise mask, in the following format: modifier+...+modifier |
javax.swing.KeyStroke |
getStandardAccelerator()
Shorthand for getStandardAccelerator(Class) called with the Class instance returned by Object.getClass(). |
static javax.swing.KeyStroke |
getStandardAccelerator(java.lang.Class action)
Queries ActionKeymap for an accelerator corresponding to the specified action. |
javax.swing.KeyStroke |
getStandardAlternateAccelerator()
Shorthand for getStandardAlternateAccelerator(Class) called with the Class instance returned by Object.getClass(). |
static javax.swing.KeyStroke |
getStandardAlternateAccelerator(java.lang.Class action)
Queries ActionKeymap for an alternate accelerator corresponding to the specified action. |
javax.swing.ImageIcon |
getStandardIcon()
Shorthand for getStandardIcon(Class) called with the Class instance returned by Object.getClass(). |
static javax.swing.ImageIcon |
getStandardIcon(java.lang.Class action)
Queries IconManager for an image icon corresponding to the specified action using standard icon path
conventions. |
java.lang.String |
getStandardIconPath()
Shorthand for getStandardIconPath(Class) called with the Class instance returned by Object.getClass(). |
static java.lang.String |
getStandardIconPath(java.lang.Class action)
Returns the standard path to the icon image for the specified MuAction class. |
java.lang.String |
getStandardLabel()
Shorthand for getStandardLabel(Class) called with the Class instance returned by Object.getClass(). |
static java.lang.String |
getStandardLabel(java.lang.Class action)
Queries Translator for a label corresponding to the specified action using standard naming conventions. |
java.lang.String |
getStandardLabelKey()
Shorthand for getStandardLabelKey(Class) called with the Class instance returned by Object.getClass(). |
static java.lang.String |
getStandardLabelKey(java.lang.Class action)
Returns the dictionary key for the specified action's label, using the following standard naming convention: |
java.lang.String |
getStandardTooltip()
Shorthand for getStandardTooltip(Class) called with the Class instance returned by Object.getClass(). |
static java.lang.String |
getStandardTooltip(java.lang.Class action)
Queries Translator for a tooltip corresponding to the specified action using standard naming conventions. |
java.lang.String |
getStandardTooltipKey()
Shorthand for getStandardTooltipKey(Class) called with the Class instance returned by Object.getClass(). |
static java.lang.String |
getStandardTooltipKey(java.lang.Class action)
Returns the dictionary key for the specified action's tooltip, using the following standard naming convention: |
java.lang.String |
getToolTipText()
Returns the tooltip text of this action, null if this action has no tooltip. |
boolean |
honourNoEventsMode()
Return true if action events are ignored while the MainFrame associated with this
action is in 'no events mode' (see MainFrame for an explanation about this mode). |
boolean |
isAccelerator(javax.swing.KeyStroke keyStroke)
Returns true if the given KeyStroke is one of this action's accelerators. |
abstract void |
performAction()
Called when this action has been triggered. |
boolean |
performActionInSeparateThread()
Returns true if performAction() is called from a separate thread (and not from the event
thread) when this action is performed. |
protected void |
reportError(java.lang.String message)
Opens a dialog with the specified error message. |
protected void |
reportError(java.lang.String title,
java.lang.String message)
Opens an error dialog with the specified title and message. |
protected void |
reportGenericError()
Opens a dialog with a generic error message. |
void |
setAccelerator(javax.swing.KeyStroke keyStroke)
Sets the accelerator KeyStroke for this action, null for no accelerator. |
void |
setAlternateAccelerator(javax.swing.KeyStroke keyStroke)
Sets the alternate accelerator KeyStroke for this action, null for none. |
void |
setHonourNoEventsMode(boolean honourNoEventsMode)
Sets whether action events are to be ignored while the MainFrame associated with this action is in
'no events mode' (see MainFrame for an explanation about this mode). |
void |
setIcon(javax.swing.ImageIcon icon)
Sets the icon for this action, null if this action has no icon. |
void |
setLabel(java.lang.String label)
Sets the label for this action, null for no label. |
void |
setPerformActionInSeparateThread(boolean performActionInSeparateThread)
Sets whether performAction() is called from a separate thread (and not from the event thread) when this
action is performed. |
void |
setToolTipText(java.lang.String toolTipText)
Sets the tooltip for this action, null for no tooltip. |
| 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 |
| Field Detail |
|---|
protected MainFrame mainFrame
public static final java.lang.String ALTERNATE_ACCELERATOR_PROPERTY_KEY
| Constructor Detail |
|---|
public MuAction(MainFrame mainFrame,
java.util.Hashtable properties)
MuAction(MainFrame, Hashtable, boolean, boolean, boolean )
with standard labels, icon and accelerators enabled.
mainFrame - the MainFrame to associate with this new MuActionproperties - the initial properties to use in this action. The Hashtable may simply be empty if no initial
properties are specified.
public MuAction(MainFrame mainFrame,
java.util.Hashtable properties,
boolean useStandardLabels)
MuAction(MainFrame, Hashtable, boolean, boolean, boolean)
with standard icon and accelerators enabled.
mainFrame - the MainFrame to associate with this new MuActionproperties - the initial properties to use in this action. The Hashtable may simply be empty if no initial
properties are specified.useStandardLabels - if true, standard label and tooltip (if any) will be retrieved with
getStandardLabel(Class) and getStandardTooltip(Class) and used
public MuAction(MainFrame mainFrame,
java.util.Hashtable properties,
boolean useStandardLabels,
boolean useStandardIcon,
boolean useStandardAccelerators)
MainFrame. The properties contained by the given
Hashtable are used to initialize this action's property map.
The useStandardLabels, useStandardIcon and useStandardAccelerators
parameters control whether standard property values are automatically retrieved and used. These should
be disabled if custom values are used.
mainFrame - the MainFrame to associate with this new MuActionproperties - the initial properties to use in this action. The Hashtable may simply be empty if no initial
properties are specified.useStandardLabels - if true, standard label and tooltip (if any) will be retrieved with
getStandardLabel() and getStandardTooltip() and useduseStandardIcon - if true, standard icon (if any) will be retrieved using getStandardIcon()
and useduseStandardAccelerators - if true, standard accelerator and alternate accelerator (if any) will
be retrieved with getStandardAccelerator() and getStandardAlternateAccelerator() and used| Method Detail |
|---|
public MainFrame getMainFrame()
MainFrame this MuAction is associated.
public java.lang.String getLabel()
null if this action has no label.
The label value is stored in the Action.NAME property.
null if this action has no labelpublic void setLabel(java.lang.String label)
null for no label.
The label value is stored in the Action.NAME property.
label - the new text label for this action, replacing the previous one (if any)public java.lang.String getToolTipText()
null if this action has no tooltip.
The tooltip value is stored in the Action.SHORT_DESCRIPTION property.
null if this action has no tooltippublic void setToolTipText(java.lang.String toolTipText)
null for no tooltip.
The tooltip value is stored in the Action.SHORT_DESCRIPTION property.
toolTipText - the new tooltip text for this action replacing the previous one (if any)public javax.swing.ImageIcon getIcon()
null if this action has no icon.
The icon value is stored in the Action.SMALL_ICON property.
null if this action has no iconpublic void setIcon(javax.swing.ImageIcon icon)
null if this action has no icon.
The icon value is stored in the Action.SMALL_ICON property.
icon - the new image icon for this action, replacing the previous one (if any)public javax.swing.KeyStroke getAccelerator()
null if this action has no accelerator.
The accelerator value is stored in the Action.ACCELERATOR_KEY property.
null if this action has no acceleratorpublic void setAccelerator(javax.swing.KeyStroke keyStroke)
null for no accelerator.
The tooltip value is stored in the Action.ACCELERATOR_KEY property.
keyStroke - the new accelerator KeyStroke for this action, replacing the previous one (if any)public javax.swing.KeyStroke getAlternateAccelerator()
null if it doesn't have any.
The accelerator accelerator value is stored in the ALTERNATE_ACCELERATOR_PROPERTY_KEY property.
null if it doesn't have anypublic void setAlternateAccelerator(javax.swing.KeyStroke keyStroke)
null for none.
The accelerator accelerator value is stored in the ALTERNATE_ACCELERATOR_PROPERTY_KEY property.
keyStroke - the new alternate accelerator KeyStroke for this action, replacing the previous one (if any)public boolean isAccelerator(javax.swing.KeyStroke keyStroke)
keyStroke - the KeyStroke to test against this action's acccelerators
public java.lang.String getAcceleratorText()
[modifier]+[modifier]+...+key format.
This method returns null if this action has no accelerator.
null if this action has no accelerator.public boolean honourNoEventsMode()
true if action events are ignored while the MainFrame associated with this
action is in 'no events mode' (see MainFrame for an explanation about this mode).
By default, this method returns true.
true if action events are ignored while the MainFrame associated with this
action is in 'no events' modepublic void setHonourNoEventsMode(boolean honourNoEventsMode)
MainFrame associated with this action is in
'no events mode' (see MainFrame for an explanation about this mode).
By default (unless this method has been called), 'no events mode' is honoured.
honourNoEventsMode - if true, actions events will be ignored while the MainFrame associated
with this action is in 'no events mode'public boolean performActionInSeparateThread()
true if performAction() is called from a separate thread (and not from the event
thread) when this action is performed. By default, false is returned, i.e. actions are performed
from the main event thread.
Actions that have the potential to hold the caller thread for a substantial amount of time should perform the action in a separate thread, to avoid locking the event thread.
true if performAction() is called from a separate thread (and not from the event
thread) when this action is performedpublic void setPerformActionInSeparateThread(boolean performActionInSeparateThread)
performAction() is called from a separate thread (and not from the event thread) when this
action is performed. By default (unless this method has been called), actions are performed from the main event
thread.
Actions that have the potential to hold the caller thread for a substantial amount of time should perform the action in a separate thread, to avoid locking the event thread.
performActionInSeparateThread - true to have performAction() called from a separate
thread (and not from the event thread) when this action is performedpublic java.lang.String getStandardLabel()
getStandardLabel(Class) called with the Class instance returned by Object.getClass().
null if none was foundpublic java.lang.String getStandardLabelKey()
getStandardLabelKey(Class) called with the Class instance returned by Object.getClass().
public java.lang.String getStandardTooltip()
getStandardTooltip(Class) called with the Class instance returned by Object.getClass().
null if none was foundpublic java.lang.String getStandardTooltipKey()
getStandardTooltipKey(Class) called with the Class instance returned by Object.getClass().
public javax.swing.KeyStroke getStandardAccelerator()
getStandardAccelerator(Class) called with the Class instance returned by Object.getClass().
null if none was foundpublic javax.swing.KeyStroke getStandardAlternateAccelerator()
getStandardAlternateAccelerator(Class) called with the Class instance returned by Object.getClass().
null if none was foundpublic javax.swing.ImageIcon getStandardIcon()
getStandardIcon(Class) called with the Class instance returned by Object.getClass().
null if none was foundpublic java.lang.String getStandardIconPath()
getStandardIconPath(Class) called with the Class instance returned by Object.getClass().
public static java.lang.String getStandardLabel(java.lang.Class action)
Translator for a label corresponding to the specified action using standard naming conventions.
Returns the label or null if no corresponding entry was found in the dictionary.
action - a MuAction class descriptor
null if none was foundpublic static java.lang.String getStandardLabelKey(java.lang.Class action)
action_classname.label
where action_classname is the fully qualified action class's name, as returned by Class.getName().
action - a MuAction class descriptor
public static java.lang.String getStandardTooltip(java.lang.Class action)
Translator for a tooltip corresponding to the specified action using standard naming conventions.
Returns the tooltip or null if no corresponding entry was found in the dictionary.
action - a MuAction class descriptor
null if none was foundpublic static java.lang.String getStandardTooltipKey(java.lang.Class action)
action_classname.tooltip
where action_classname is the fully qualified action class's name, as returned by Class.getName().
action - a MuAction class descriptor
public static javax.swing.KeyStroke getStandardAccelerator(java.lang.Class action)
ActionKeymap for an accelerator corresponding to the specified action.
Returns the accelerator's KeyStroke or null if no corresponding accelerator was found.
action - a MuAction class descriptor
null if none was foundpublic static javax.swing.KeyStroke getStandardAlternateAccelerator(java.lang.Class action)
ActionKeymap for an alternate accelerator corresponding to the specified action.
Returns the accelerator's KeyStroke or null if no corresponding accelerator was found.
action - a MuAction class descriptor
null if none was foundpublic static javax.swing.ImageIcon getStandardIcon(java.lang.Class action)
IconManager for an image icon corresponding to the specified action using standard icon path
conventions. Returns the image icon, null if none was found.
action - a MuAction class descriptor
null if none was foundpublic static java.lang.String getStandardIconPath(java.lang.Class action)
MuAction class. The returned path is
relative to the application's JAR file.
action - a MuAction class descriptor
public static java.lang.String getKeyStrokeRepresentation(javax.swing.KeyStroke ks)
modifier+modifier+...+key
For example, KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK|InputEvent.ALT_MASK)
will return Ctrl+Alt+C.
ks - the KeyStroke for which to return a String representation
[modifier]+[modifier]+...+key formatpublic static java.lang.String getModifiersRepresentation(int modifiers)
modifier+...+modifier
The modifiers' order in the returned String tries to mimick the keyboard layout of the current platform as
much as possible:
- Under Mac OS X, the order is:
Shift, Ctrl, Alt, Meta
- Under other platforms, the order is
Shift, Ctrl, Meta, Alt
- Parameters:
modifiers - a modifiers bitwise mask
- Returns:
- a String representations of the given modifiers bitwise mask
protected void reportGenericError()
This is a convenience method and is strictly equivalent to calling
reportError(Translator.get(("error"),
Translator.get(("generic_error"))
protected void reportError(java.lang.String message)
This is a convenience method and is strictly equivalent to calling
reportError(Translator.get(("error"), message)
message - error message to display.
protected void reportError(java.lang.String title,
java.lang.String message)
title - title for the error dialog.message - message contained by the error dialog.public void actionPerformed(java.awt.event.ActionEvent e)
MainFrame associated with this action is in
'no events' mode and honourNoEventsMode() returns true.
If the action event is not filtered out, performAction() is called to provide a response to the action event.
public abstract void performAction()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard