|
GEF v2.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This interface represents basic behaviour that every command is expected to support. A command can be tested for executability, it can be executed, it can be tested for undoability, it can be undone, and can then be redone. A comand also provides access to a result collection, an affected-objects collection, a label, and a description.
There are important constraints on the valid order in which the various methods may be invoked, e.g., you cannot ask for the result before you've executed the command. These constraints are documented with the various methods.
| Field Summary | |
static String |
copyright
|
| Method Summary | |
boolean |
canExecute()
This indicates whether the comamad is valid to execute. |
boolean |
canUndo()
This returns whether the command can be undone. |
Command |
chain(Command command)
This logically chains the given command to this command, by returning a command that represents the composition. |
void |
dispose()
This is called to indicate that the command will never be used again. |
void |
execute()
This will perform the command activity required for the effect. |
Collection |
getAffectedObjects()
This returns the collection of things which this command wishes to present as the objects affected by the command. |
String |
getDescription()
This returns a string suitable to help describe the effect of this command. |
String |
getLabel()
This returns a string suitable to represent the label that identifies this command. |
Collection |
getResult()
This returns collection of things which this command wishes to present as it's result. |
void |
redo()
This will again perform the command activity required to redo the effect after undoing the effect. |
void |
undo()
This will perform the command activity required to undo the effects of a preceding execute (or redo). |
| Field Detail |
public static final String copyright
| Method Detail |
public boolean canExecute()
UnexecutableCommand.INSTANCE.canExecute() always returns false.
This public void execute()
public boolean canUndo()
public void undo()
public void redo()
public Collection getResult()
public Collection getAffectedObjects()
public String getLabel()
public String getDescription()
public void dispose()
public Command chain(Command command)
Instead of the following pattern of usage
Command result = x; if (condition) result = result.chain(y);you should consider using a
CompoundCommand
and using CompoundCommand.unwrap() to optimize the result:
CompoundCommand subcommands = new CompoundCommand(); subcommands.append(x); if (condition) subcommands.append(y); Command result = subcommands.unwrap();This gives you more control over how the compound command composes it's result and affected objects.
|
GEF v2.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||