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.tools.edit.commands;
16:
17: import net.refractions.udig.project.command.AbstractCommand;
18: import net.refractions.udig.project.command.UndoableMapCommand;
19: import net.refractions.udig.tool.edit.internal.Messages;
20: import net.refractions.udig.tools.edit.EditState;
21: import net.refractions.udig.tools.edit.EditToolHandler;
22:
23: import org.eclipse.core.runtime.IProgressMonitor;
24:
25: /**
26: * Sets the current state in the handler.
27: *
28: * @author jones
29: * @since 1.1.0
30: */
31: public class SetEditStateCommand extends AbstractCommand implements
32: UndoableMapCommand {
33:
34: private EditToolHandler handler;
35: private EditState oldState;
36: private EditState state;
37:
38: public SetEditStateCommand(EditToolHandler handler2,
39: EditState newState) {
40: this .handler = handler2;
41: this .state = newState;
42: }
43:
44: public void run(IProgressMonitor monitor) throws Exception {
45: this .oldState = handler.getCurrentState();
46: handler.setCurrentState(state);
47: }
48:
49: public String getName() {
50: return Messages.SetEditStateCommand_name;
51: }
52:
53: public void rollback(IProgressMonitor monitor) throws Exception {
54: handler.setCurrentState(oldState);
55: }
56:
57: }
|