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.behaviour;
16:
17: import net.refractions.udig.project.command.UndoRedoCommand;
18: import net.refractions.udig.project.command.UndoableMapCommand;
19: import net.refractions.udig.tools.edit.Behaviour;
20: import net.refractions.udig.tools.edit.EditPlugin;
21: import net.refractions.udig.tools.edit.EditToolHandler;
22: import net.refractions.udig.tools.edit.commands.DefaultCancelEditingCommand;
23:
24: import org.eclipse.core.runtime.NullProgressMonitor;
25:
26: /**
27: * This behaviour sets the current state to NONE, the Current Edit Feature to null, the Current Shape to null and
28: * clears the current map's blackboards.
29: *
30: * @author Jesse
31: * @since 1.1.0
32: */
33: public class DefaultCancelBehaviour implements Behaviour {
34:
35: public boolean isValid(EditToolHandler handler) {
36: return true;
37: }
38:
39: public UndoableMapCommand getCommand(EditToolHandler handler) {
40: DefaultCancelEditingCommand defaultCancelEditingCommand = new DefaultCancelEditingCommand(
41: handler);
42: defaultCancelEditingCommand.setMap(handler.getContext()
43: .getMap());
44: try {
45: defaultCancelEditingCommand.run(new NullProgressMonitor());
46: } catch (Exception e) {
47: throw (RuntimeException) new RuntimeException(e);
48: }
49: return new UndoRedoCommand(defaultCancelEditingCommand);
50: }
51:
52: public void handleError(EditToolHandler handler, Throwable error,
53: UndoableMapCommand command) {
54: EditPlugin.log("", error); //$NON-NLS-1$
55: }
56:
57: }
|