|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--javax.swing.AbstractAction
|
+--uci.gef.Cmd
Abstract class for all editor commands. The editor serves as a command shell for executing actions in much the same way that a DOS or UNIX commmand command shell executes programs. Each command can have a Hashtable of "command-line" arguments and also look at global variables (its environment). Once an instance of a Cmd is made, it can be sent the doIt() and undoIt() messages to perform that action.
Since this is subclassed from class AbstractAction in the Swing user interface library, Cmd objects can be easily added to menus and toolbars.
needs-more-work: canDoIt, canUndoIt predicates control graying.
needs-more-work: Editor will keep a history of recent actions for undo.
Editor,
ExecuteActionWindow, Serialized Form| Field Summary | |
protected Hashtable |
_args
Arguments that configure the Cmd instance. |
static boolean |
HAS_ICON
|
static boolean |
NO_ICON
|
| Fields inherited from class javax.swing.AbstractAction |
changeSupport,
enabled |
| Constructor Summary | |
Cmd(Hashtable args,
String name)
Construct a new Cmd with the given arguments |
|
Cmd(Hashtable args,
String name,
boolean hasIcon)
|
|
Cmd(Hashtable args,
String name,
ImageIcon icon)
|
|
Cmd(String name)
Construct a new Cmd with no arguments |
|
Cmd(String name,
boolean hasIcon)
|
|
| Method Summary | |
String |
about()
Return a URL that has user and programmer documentation. |
void |
actionPerformed(ActionEvent ae)
|
static Cmd |
cmdAtIndex(int i)
Return the "well-known" Cmd at a given index. |
protected boolean |
containsArg(String key)
Reply true if this Cmd instance has the named argument defined. |
abstract void |
doIt()
Perform whatever Cmd this Cmd is meant to do. |
protected Object |
getArg(String key)
Get the object stored as an argument under the given name. |
protected Object |
getArg(String key,
Object defaultValue)
Get an argument by name. |
String |
getName()
Return a name for this Cmd suitable for display to the user |
static void |
register(Cmd c)
Add a "well-known" Cmd |
static Enumeration |
registeredCmds()
Return a list of "well-known" Cmd instances that should appear in lists for the user to pick from. |
protected void |
setArg(String key,
Object value)
Store the given argument under the given name. |
void |
setName(String n)
|
boolean |
shouldBeEnabled()
Return true if this action should be available to the user. |
abstract void |
undoIt()
Undo the Cmd using information stored during its execution. |
void |
updateEnabled()
Determine if this Cmd should be shown as grayed out in menus and toolbars. |
| Methods inherited from class javax.swing.AbstractAction |
addPropertyChangeListener,
clone,
firePropertyChange,
getValue,
isEnabled,
putValue,
removePropertyChangeListener,
setEnabled |
| Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static final boolean HAS_ICON
public static final boolean NO_ICON
protected Hashtable _args
| Constructor Detail |
public Cmd(Hashtable args,
String name)
public Cmd(Hashtable args,
String name,
boolean hasIcon)
public Cmd(String name,
boolean hasIcon)
public Cmd(Hashtable args,
String name,
ImageIcon icon)
public Cmd(String name)
| Method Detail |
public void updateEnabled()
public boolean shouldBeEnabled()
public String getName()
public void setName(String n)
protected Object getArg(String key)
protected Object getArg(String key,
Object defaultValue)
protected void setArg(String key,
Object value)
protected boolean containsArg(String key)
public String about()
public void actionPerformed(ActionEvent ae)
public abstract void doIt()
e - The event that caused this Cmd to be
performed. Generally it is a bad idea to depend on the
contents of this event too much.public abstract void undoIt()
needs-more-work: This is not currently implemented.
public static Enumeration registeredCmds()
ExecuteCmdWindowpublic static void register(Cmd c)
public static Cmd cmdAtIndex(int i)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||