A command has a label to identify the command to be undone or
redone. Not all commands can be undone. Commands can be of one of the
following types:
kSerialUndo - Can be undone, but only in the reverse order of that
in which they were done.
Command is an abstract class. Concrete classes of Command implement
the handleDo, handleUndo, and handleRedo methods to do, undo, and
redo the command on the target. They implement the handleCanDo method
to specify conditions that must be satisfied for a change to happen.
The target object can be a Model or part of a Model which is often
specified by a ModelSelection.
Copyright (c) Taligent, Inc. 1996 - 1997.
Copyright (c) IBM Corporation 1996 - 1997.
All Rights Reserved.
- See Also:
- Model, ModelSelection
-
kCantUndo
- Command cannot be undone.
-
kNoChange
- Command does not modify the target, so it does not need to be undone.
-
kSerialUndo
- Command can be undone, but only in the reverse order of that in
which they were done.
-
Command()
- Construct a command of type kSerialUndo.
-
Command(int)
- Construct a command of the specified type.
-
Command(String)
- Construct a command with the specified label.
-
Command(String, int)
- Construct a command with the specified label and type.
-
getLabel()
- Get the command label
-
getType()
- Get the command type
-
handleCanDo()
- Can the command be done? Override this method to specify the
conditions that must be satisfied before the command can be
performed.
-
handleDo()
- Invoked by the framework to do the command.
-
handleRedo()
- Invoked by the framework to redo the command.
-
handleUndo()
- Invoked by the framework to undo the command.
-
setLabel(String)
- Set the command label
-
setType(int)
- Set the command type
kNoChange
public static final int kNoChange
- Command does not modify the target, so it does not need to be undone.
kCantUndo
public static final int kCantUndo
- Command cannot be undone.
kSerialUndo
public static final int kSerialUndo
- Command can be undone, but only in the reverse order of that in
which they were done.
Command
public Command()
- Construct a command of type kSerialUndo.
Command
public Command(String label)
- Construct a command with the specified label.
- Parameters:
- label - command label
Command
public Command(int type)
- Construct a command of the specified type.
- Parameters:
- type - command type, one of kNoChange, kCantUndo, and kSerialUndo
Command
public Command(String label,
int type)
- Construct a command with the specified label and type.
- Parameters:
- label - command label
- type - command type, one of kNoChange, kCantUndo, and kSerialUndo
getType
public int getType()
- Get the command type
setType
public void setType(int type)
- Set the command type
getLabel
public String getLabel()
- Get the command label
setLabel
public void setLabel(String label)
- Set the command label
handleCanDo
public boolean handleCanDo()
- Can the command be done? Override this method to specify the
conditions that must be satisfied before the command can be
performed. Default implementation returns true.
handleDo
protected abstract void handleDo()
- Invoked by the framework to do the command.
Must override this method.
handleUndo
protected void handleUndo()
- Invoked by the framework to undo the command. Override this method
to reverse a change to the target. There is no default
implementation.
handleRedo
protected void handleRedo()
- Invoked by the framework to redo the command. Override this method
to reapply a change to the target. There is no default
implementation.
All Packages Class Hierarchy This Package Previous Next Index