|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.AbstractAction | +--org.erights.e.ui.awt.EAction
Untamed: Enables an E-language programmer to effectively parameterize an
javax.swing.AbstractAction
, even though E cannot subclass Java.
AbstractAction was designed to be parameterized by subclassing. E-language code cannot subclass Java classes, so EAction provides a bridge between these issues. EAction is a subclass of AbstractAction whose behavior is determined by its properties, which is settable by E language code.
In addition, it provides various conveniences absent from Action and AbstractAction, such as the ability to use a description string like "Save &As" to set the Name ("Save As"), action Verb ("doSaveAs"), and mnemonic ('A').
The actual action represented by an EAction is the eventual sending of a message (verb and arguments) to a recipient.
Field Summary | |
private static IntTable |
ModNames
|
private Object[] |
myArgs
|
private Object |
myRecip
The recipient of the myVerb(myArgs...) message |
private Vat |
myVat
Captures the current vat at the time of creation so it can be restored when this EAction is invoked. |
private String |
myVerb
|
Fields inherited from class javax.swing.AbstractAction |
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON |
Constructor Summary | |
EAction()
Enabled: When created this way, it's useless until parameterized with the property setting methods. |
|
EAction(Object recip,
String desc)
Enabled: Creates an action with a name, verb, and mnemonic derived from desc, which will 'recip <- verb()'. |
|
EAction(Object recip,
String desc,
String acceleration)
Enabled: As with the two argument constructor, but will also associate the described acceleration key with the action. |
Method Summary | |
void |
__printOn(TextWriter out)
Enabled: |
void |
accelerate(String acceleration)
Enabled: Parse an accelation description string into an acceleration keyStroke, and setAccelerator to that keyStroke. |
void |
actionPerformed(ActionEvent e)
Enabled: Invoked by Swing when the EAction's action should be invoked. |
static int |
descToMnemonic(String desc)
Enabled: The mnemonic key is the character following the '&', or -1 if there isn't one. |
static String |
descToName(String desc)
Enabled: Extract the string to show in the menu. |
static String |
descToVerb(String desc)
Enabled: Derive a message name. |
KeyStroke |
getAccelerator()
Enabled: Actually gets the AbstractAction's ACCELERATOR_KEY property. |
int |
getMnemonic()
Enabled: Actually gets the AbstractAction's MNEMONIC_KEY property. |
String |
getName()
Enabled: Actually gets the AbstractAction's NAME property. |
String |
getTip()
Enabled: Actually gets the AbstractAction's SHORT_DESCRIPTION property. |
void |
setAccelerator(KeyStroke newKey)
Enabled: Actually sets the AbstractAction's ACCELERATOR_KEY property. |
void |
setAction(Object recip)
Enabled: Sets the action to 'recip <- run()', so action should be a Runnable or a Thunk. |
void |
setAction(Object recip,
String verb)
Enabled: Sets the action to 'recip <- verb()' |
void |
setAction(Object recip,
String verb,
Object[] args)
Enabled: Sets the action to 'recip <- verb(args...)' |
void |
setDesc(Object recip,
String desc)
Enabled: Sets the name, verb, and mnemonic according to desc, and the action to 'recip <- verb()'. |
void |
setMnemonic(int newMnemonic)
Enabled: Actually sets the AbstractAction's MNEMONIC_KEY property. |
void |
setName(String newName)
Enabled: Actually sets the AbstractAction's NAME property. |
void |
setTip(String newTip)
Enabled: Actually sets the AbstractAction's SHORT_DESCRIPTION property. |
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 |
private static final IntTable ModNames
private final Vat myVat
This is necessary since this EAction can be (and generally is) invoked during an AWT event that's not a vat turn.
private Object myRecip
private String myVerb
private Object[] myArgs
Constructor Detail |
public EAction()
public EAction(Object recip, String desc)
For example, 'EAction new(foo, "Save &As")' will have the name "Save As", the mnemonic 'A', and when invoked will 'foo <- doSaveAs()'.
public EAction(Object recip, String desc, String acceleration)
The acceleration parameter is in approximately the format in which acceleration are displayed on Windows menus. For example, the acceleration parameter "Ctrl+A" sets the acceleration keystroke to be Control-A.
Method Detail |
public static String descToName(String desc)
"Save &As.." => "Save As.."
public static String descToVerb(String desc)
"Save &As.." => "doSaveAs"
public static int descToMnemonic(String desc)
"Save &As" => 'A'
public void setDesc(Object recip, String desc)
For example, 'ea.setDesc(foo, "Save &As")' will set the name to "Save As", the mnemonic 'A', and the action to be invoked to 'foo <- doSaveAs()'.
public void actionPerformed(ActionEvent e)
Does a sendOnly of 'recip <- verb(args...)'
public void setAction(Object recip)
public void setAction(Object recip, String verb)
public void setAction(Object recip, String verb, Object[] args)
public KeyStroke getAccelerator()
public void setAccelerator(KeyStroke newKey)
public void accelerate(String acceleration)
public String getName()
public void setName(String newName)
public int getMnemonic()
public void setMnemonic(int newMnemonic)
public String getTip()
public void setTip(String newTip)
public void __printOn(TextWriter out) throws IOException
IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |