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.printing.ui.internal.editor.policies;
18:
19: import net.refractions.udig.printing.model.Box;
20: import net.refractions.udig.printing.model.impl.MapBoxPrinter;
21: import net.refractions.udig.printing.ui.actions.EditMapAction;
22: import net.refractions.udig.printing.ui.internal.Messages;
23: import net.refractions.udig.project.ui.internal.ProjectExplorer;
24:
25: import org.eclipse.gef.Request;
26: import org.eclipse.gef.commands.Command;
27: import org.eclipse.gef.editpolicies.ComponentEditPolicy;
28:
29: /**
30: * Provides ...TODO summary sentence
31: * <p>
32: * TODO Description
33: * </p><p>
34: * Responsibilities:
35: * <ul>
36: * <li>
37: * <li>
38: * </ul>
39: * </p><p>
40: * Example Use:<pre><code>
41: * MapEditPolicy x = new MapEditPolicy( ... );
42: * TODO code example
43: * </code></pre>
44: * </p>
45: * @author Richard Gould
46: * @since 0.3
47: */
48: public class MapEditPolicy extends ComponentEditPolicy {
49:
50: public Command getCommand(Request request) {
51: if (EditMapAction.EDIT_MAP_REQUEST.equals(request.getType())) {
52: EditMapCommand command = new EditMapCommand();
53: command.setMapBox(((MapBoxPrinter) ((Box) getHost()
54: .getModel()).getBoxPrinter()));
55: return command;
56: }
57: return super .getCommand(request);
58: }
59:
60: static class EditMapCommand extends Command {
61: private MapBoxPrinter mapBox;
62:
63: public EditMapCommand() {
64: super (Messages.MapEditPolicy_label);
65: }
66:
67: public MapBoxPrinter getMapBox() {
68: return mapBox;
69: }
70:
71: public void setMapBox(MapBoxPrinter mapBox) {
72: this .mapBox = mapBox;
73: }
74:
75: public void execute() {
76: ProjectExplorer.getProjectExplorer().open(mapBox.getMap());
77: }
78: }
79: }
|