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.activator;
16:
17: import net.refractions.udig.tools.edit.Activator;
18: import net.refractions.udig.tools.edit.EditPlugin;
19: import net.refractions.udig.tools.edit.EditToolHandler;
20: import net.refractions.udig.tools.edit.handler.AdvancedBehaviourCommandHandler;
21:
22: import org.eclipse.core.commands.Command;
23: import org.eclipse.core.commands.IHandler;
24: import org.eclipse.ui.PlatformUI;
25: import org.eclipse.ui.commands.ICommandService;
26:
27: /**
28: * Enables the {@link net.refractions.udig.tools.edit.handler.SnapBehaviourCommandHandler} on the CycleSnapBehaviour command.
29: * @author Jesse
30: * @since 1.1.0
31: */
32: public class AdvancedBehaviourCommandHandlerActivator implements
33: Activator {
34: private static final String COMMAND_ID = "net.refractions.udig.tool.edit.advanced.edit.command"; //$NON-NLS-1$
35: ICommandService service = (ICommandService) PlatformUI
36: .getWorkbench().getAdapter(ICommandService.class);
37: private IHandler commandHandler;;
38:
39: public void activate(EditToolHandler handler) {
40: commandHandler = new AdvancedBehaviourCommandHandler(handler
41: .getContext().getMapDisplay());
42: Command command = service.getCommand(COMMAND_ID);
43: if (command != null)
44: command.setHandler(commandHandler);
45: }
46:
47: public void deactivate(EditToolHandler handler) {
48: commandHandler = null;
49: Command command = service.getCommand(COMMAND_ID);
50: if (command != null)
51: command.setHandler(null);
52: }
53:
54: public void handleActivateError(EditToolHandler handler,
55: Throwable error) {
56: EditPlugin.log("", error); //$NON-NLS-1$
57: }
58:
59: public void handleDeactivateError(EditToolHandler handler,
60: Throwable error) {
61: EditPlugin.log("", error); //$NON-NLS-1$
62: }
63:
64: }
|