1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
package tim.prune.cmd;
import tim.prune.data.TrackInfo;
/**
* Superclass of all commands, which can be executed on the TrackInfo object
*/
public abstract class Command
{
private Command _inverse;
private final boolean _isUndo;
// description is used for undo and redo
private String _descriptionText = null;
private String _confirmText = null;
protected Command(Command inParent) {
_inverse = inParent;
_isUndo = (_inverse != null);
}
public Command getInverse() {
return _inverse;
}
protected boolean isUndo() {
return _isUndo;
}
public final boolean execute(TrackInfo inInfo)
{
if (_inverse == null)
{
_inverse = makeInverse(inInfo);
assert _inverse == null || _inverse._inverse != null;
}
return executeCommand(inInfo);
}
protected void setInverse(Command inCommand) {
_inverse = inCommand;
}
protected abstract boolean executeCommand(TrackInfo inInfo);
protected abstract Command makeInverse(TrackInfo inInfo);
public String getDescription() {
return _descriptionText;
}
public String getConfirmText() {
return _confirmText;
}
public void setDescription(String inText) {
_descriptionText = inText;
}
public void setConfirmText(String inText) {
_confirmText = inText;
}
public abstract int getUpdateFlags();
}
|