01: /*
02: * uDig - User Friendly Desktop Internet GIS client
03: * http://udig.refractions.net
04: * (C) 2004, Refractions Research Inc.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: */
17: package net.refractions.udig.tools.internal;
18:
19: import net.refractions.udig.project.ui.tool.IToolHandler;
20: import net.refractions.udig.project.ui.tool.Tool;
21:
22: import org.eclipse.core.commands.AbstractHandler;
23: import org.eclipse.core.commands.ExecutionEvent;
24: import org.eclipse.core.commands.ExecutionException;
25:
26: /**
27: * Handles the pan right,left,up and down commands
28: *
29: * @author jeichar
30: * @since 0.6.0
31: */
32: public class PanHandler extends AbstractHandler implements IToolHandler {
33:
34: private static Pan TOOL;
35: private String id;
36: private static final String LEFT = "net.refractions.udig.tools.panLeftCommand"; //$NON-NLS-1$
37: private static final String RIGHT = "net.refractions.udig.tools.panRightCommand"; //$NON-NLS-1$
38: private static final String UP = "net.refractions.udig.tools.panUpCommand"; //$NON-NLS-1$
39: private static final String DOWN = "net.refractions.udig.tools.panDownCommand"; //$NON-NLS-1$
40: private static UpdateThread PANNER = UpdateThread.getUpdater();
41:
42: public void setTool(Tool tool) {
43: TOOL = (Pan) tool;
44: }
45:
46: /**
47: * @see net.refractions.udig.project.ui.tool.IToolHandler#setCurrentCommandId(java.lang.String)
48: */
49: public void setCurrentCommandId(String currentCommandId) {
50: id = currentCommandId;
51: }
52:
53: public Object execute(ExecutionEvent event)
54: throws ExecutionException {
55: if (id.equals(LEFT))
56: PANNER.left(TOOL.getContext());
57: if (id.equals(RIGHT))
58: PANNER.right(TOOL.getContext());
59: if (id.equals(UP))
60: PANNER.up(TOOL.getContext());
61: if (id.equals(DOWN))
62: PANNER.down(TOOL.getContext());
63: return null;
64: }
65:
66: }
|