01: package org.tcat.citd.sim.udig.bookmarks.internal.command;
02:
03: import net.refractions.udig.project.IMap;
04: import net.refractions.udig.project.command.Command;
05: import net.refractions.udig.project.internal.ProjectPlugin;
06: import net.refractions.udig.project.internal.command.navigation.AbstractNavCommand;
07: import net.refractions.udig.project.render.IViewportModel;
08: import net.refractions.udig.project.ui.ApplicationGIS;
09:
10: import org.eclipse.core.runtime.IProgressMonitor;
11: import org.eclipse.emf.common.util.URI;
12: import org.tcat.citd.sim.udig.bookmarks.Bookmark;
13:
14: import com.vividsolutions.jts.geom.Envelope;
15:
16: /**
17: * TODO Purpose of
18: * <p>
19: * </p>
20: *
21: * @author cole.markham
22: * @since 1.0.0
23: */
24: public class GotoBookmarkCommand extends AbstractNavCommand {
25: private Bookmark target;
26:
27: /**
28: * @param target
29: */
30: public GotoBookmarkCommand(Bookmark target) {
31: this .target = target;
32: }
33:
34: @Override
35: protected void runImpl(IProgressMonitor monitor) throws Exception {
36: URI mapID = target.getMap().getMapID();
37: IMap map = (IMap) (ProjectPlugin.getPlugin()
38: .getProjectRegistry().eResource().getResourceSet()
39: .getResource(mapID, true).getContents().get(0));
40: ApplicationGIS.openMap(map);
41: IViewportModel v = map.getViewportModel();
42: Envelope env = v.getBounds();
43: //TODO: perform CRS conversion if needed
44: // Check if env is a ReferencedEnvelope, if not create one using v.getCRS()
45: if (!env.equals(target.getEnvelope())) {
46: model.zoomToBox(target.getEnvelope());
47: }
48: }
49:
50: public Command copy() {
51: return null;
52: }
53:
54: public String getName() {
55: return null;
56: }
57:
58: }
|