01: /* uDig - User Friendly Desktop Internet GIS client
02: * http://udig.refractions.net
03: * (C) 2004, Refractions Research Inc.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation;
08: * version 2.1 of the License.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: */
15: package net.refractions.udig.project.command;
16:
17: import org.eclipse.core.runtime.IProgressMonitor;
18:
19: /**
20: * This class will only rollback and redo the command it wraps.
21: * In the case of where commands are required to interact with the UI it is often desirable to execute the command and then put it on the
22: * command stack so that it can be undone.
23: *
24: * @author Jesse
25: * @since 1.1.0
26: */
27: public class UndoRedoCommand extends AbstractCommand implements
28: UndoableMapCommand {
29:
30: UndoableMapCommand wrapped;
31: boolean undone = false;
32:
33: public UndoRedoCommand(UndoableMapCommand addVertexCommand) {
34: this .wrapped = addVertexCommand;
35: }
36:
37: public String getName() {
38: return null;
39: }
40:
41: public void run(IProgressMonitor monitor) throws Exception {
42: if (undone)
43: wrapped.run(monitor);
44: }
45:
46: public void rollback(IProgressMonitor monitor) throws Exception {
47: undone = true;
48: wrapped.rollback(monitor);
49: }
50:
51: }
|