01: package fr.aliacom.commands;
02:
03: /**
04: * SyncCommand are commands that block the UI thread.
05: *
06: * SyncCommand implementations might provide undo support.
07: *
08: * @author tom
09: *
10: * (c) 2001, 2003 Thomas Cataldo
11: */
12: public abstract class SyncCommand extends Command {
13:
14: public SyncCommand() {
15: }
16:
17: public void run() {
18: fireStateChange(Command.STATE_BEGIN);
19: doIt();
20: fireStateChange(Command.STATE_END);
21: }
22:
23: /**
24: * Undo the action associated to a command using the provided
25: * memento.
26: *
27: * @param memento
28: * @throws NoUndoPossibleException
29: */
30: public abstract void undoIt(IMemento memento)
31: throws NoUndoPossibleException;
32:
33: /**
34: * @return true if the user will be able to undo the action after the command execution.
35: */
36: public abstract boolean isUndoPossible();
37:
38: /**
39: * Returns all the data that will be necessary to undo
40: * an action. The returned object should be stacked to
41: * implement the undo/redo mechanism.
42: *
43: * @return the data necessary to undo what the last execution did.
44: * @throws NoUndoPossibleException
45: */
46: public IMemento getMemento() throws NoUndoPossibleException {
47: return null;
48: }
49:
50: }
|