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.tool.info.internal;
16:
17: import net.refractions.udig.project.ui.tool.IToolHandler;
18: import net.refractions.udig.project.ui.tool.Tool;
19: import net.refractions.udig.tool.info.DistanceTool;
20:
21: import org.eclipse.core.commands.AbstractHandler;
22: import org.eclipse.core.commands.ExecutionEvent;
23: import org.eclipse.core.commands.ExecutionException;
24: import org.eclipse.jface.action.IStatusLineManager;
25:
26: public class DistanceToolCommandHandler extends AbstractHandler
27: implements IToolHandler {
28:
29: private DistanceTool tool;
30: private String current;
31: private final static String ID = "net.refractions.udig.tool.edit.clearAction"; //$NON-NLS-1$
32:
33: public void setTool(Tool tool) {
34: this .tool = (DistanceTool) tool;
35: }
36:
37: public void setCurrentCommandId(String currentCommandId) {
38: this .current = currentCommandId;
39: }
40:
41: public Object execute(ExecutionEvent event)
42: throws ExecutionException {
43: if (ID.equals(current)) {
44: tool.reset();
45: final IStatusLineManager statusBar = tool.getContext()
46: .getActionBars().getStatusLineManager();
47: if (statusBar != null) {
48: tool.getContext().updateUI(new Runnable() {
49: public void run() {
50: statusBar.setErrorMessage(null);
51: statusBar.setMessage(null);
52: }
53: });
54:
55: }
56: }
57: return null;
58: }
59:
60: }
|