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;
16:
17: import net.refractions.udig.project.command.UndoableMapCommand;
18:
19: /**
20: * This is a Stategy object for the (@link net.refractions.udig.tools.edit.latest.EditToolHandler} behaviour.
21: * Each Behaviour is valid in a particular context and will be run by the
22: * (@link net.refractions.udig.tools.edit.latest.EditToolHandler} if the isValid method returns true.
23: *
24: * @author jones
25: * @since 1.1.0
26: */
27: public interface Behaviour {
28:
29: /**
30: * Called to determine whether this Behaviour is applicable and should be run.
31: * @param handler handler that calls this Behaviour
32: * @return true if this mode is applicable and should be run.
33: */
34: public boolean isValid(EditToolHandler handler);
35:
36: /**
37: * The action to be performed by this Behaviour. This action takes place in the event thread so it must
38: * perform quickly.
39: *
40: * @param handler handler that calls this Behaviour
41: * @return Command that will be executed in order to perform the behaviour
42: */
43: public UndoableMapCommand getCommand(EditToolHandler handler);
44:
45: /**
46: * This method is called if an exception occurs during the execution of the run method.
47: * <p>
48: * This method should:
49: * <ol>
50: * <li>Rollback the changes made during the run method</li>
51: * <li>Log the error in the plugin's log</li>
52: * </ol>
53: * @param error Error that occurred
54: * @param command Command retrieved from getCommandMethod. May be null if exception occurred while
55: * executing getCommand();
56: */
57: public void handleError(EditToolHandler handler, Throwable error,
58: UndoableMapCommand command);
59: }
|