From 4b7e368aff5a44079fa8bf35a44cc6f44baec06c Mon Sep 17 00:00:00 2001 From: Frank Gasdorf Date: Tue, 8 Dec 2020 23:57:36 +0100 Subject: [PATCH] Refactoring (Nav)Commands Change-Id: I9a9fba0a7f96014c357a77f22aff213634fe2231 Signed-off-by: Frank Gasdorf --- .../internal/command/GotoBookmarkCommand.java | 14 +- .../wmt/ui/view/WMTZoomLevelSwitcher.java | 2 +- .../udig/issues/FeatureIssue.java | 41 ++- .../udig/location/ui/LocationView.java | 2 +- .../AbstractToggleMapGraphicAction.java | 13 +- .../printing/model/impl/MapBoxPrinter.java | 2 +- .../udig/printing/ui/pdf/ExportPDFWizard.java | 2 +- .../commands/SetScaleCommandTest.java | 7 +- .../TestDrawCoordinateCommandHandler.java | 2 +- .../project/ui/controls/ScaleRatioLabel.java | 2 +- .../project/ui/internal/CRSPropertyPage.java | 2 +- .../ui/internal/actions/ZoomToLayer.java | 2 +- .../GeometryPropertyDescriptor.java | 2 +- .../project/ui/internal/tool/ToolContext.java | 8 - .../ui/internal/tool/display/ToolManager.java | 4 +- .../internal/tool/impl/ToolContextImpl.java | 21 +- .../udig/project/ui/tool/IToolContext.java | 18 - .../udig/project/ui/viewers/MapViewer.java | 2 +- .../META-INF/MANIFEST.MF | 43 ++- .../project/command/BasicCommandFactory.java | 91 ----- .../udig/project/command/Command.java | 16 - .../udig/project/command/CommandManager.java | 95 ++--- .../udig/project/command/NavCommand.java | 8 +- .../command/NavigationCommandFactory.java | 158 -------- .../command/factory/BasicCommandFactory.java | 173 --------- .../factory/NavigationCommandFactory.java | 171 --------- .../navigation/AbstractNavCommand.java | 108 ++++++ .../command/navigation/NavComposite.java | 2 +- .../command/navigation/PanCommand.java | 17 +- .../command/navigation/SetBoundsCommand.java | 24 ++ .../navigation}/SetScaleCommand.java | 15 +- .../navigation/SetViewportBBoxCommand.java | 119 +++++++ .../navigation/SetViewportCenterCommand.java | 45 ++- .../command/navigation/SetViewportHeight.java | 15 +- .../command/navigation/SetViewportWidth.java | 15 +- .../command/navigation/ZoomCommand.java | 30 +- .../command/navigation/ZoomExtentCommand.java | 14 +- .../udig/project/internal/Messages.java | 336 ++++++++++++------ .../navigation/AbstractNavCommand.java | 106 ------ .../navigation/SetViewportBBoxCommand.java | 131 ------- .../internal/commands/ChangeCRSCommand.java | 68 ++-- .../udig/project/internal/messages.properties | 4 +- .../udig/tools/internal/CursorPosition.java | 2 +- .../udig/tools/internal/FixedScalePan.java | 211 ----------- .../tools/internal/InvalidateCommand.java | 41 --- .../internal/NavigationUpdateThread.java | 6 +- .../locationtech/udig/tools/internal/Pan.java | 62 +--- .../udig/tools/internal/PanTool.java | 108 ++---- .../udig/tools/internal/Zoom.java | 2 +- .../udig/tools/internal/ZoomExtent.java | 2 +- .../internal/commands/PanAndInvalidate.java | 53 +++ .../ValidToolDetectionActivator.java | 4 +- .../tool/select/internal/ZoomSelection.java | 2 +- .../featuremovieview/FeatureMovieView.java | 2 +- .../jgrass/navigationview/NavigationView.java | 40 ++- .../internal/view/MergeFeaturesCommand.java | 4 - .../preferredzoomlevels/ZoomToFeatures.java | 2 +- .../udig/tutorials/rcp/MapView.java | 31 +- .../udig/tutorials/rcp/OverviewMapView.java | 2 +- .../tracking/glasspane/TrackSeagullOp.java | 2 +- 60 files changed, 841 insertions(+), 1685 deletions(-) delete mode 100644 plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/BasicCommandFactory.java delete mode 100644 plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavigationCommandFactory.java delete mode 100644 plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/factory/BasicCommandFactory.java delete mode 100644 plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/factory/NavigationCommandFactory.java create mode 100644 plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/AbstractNavCommand.java rename plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/{internal => }/command/navigation/NavComposite.java (98%) rename plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/{internal => }/command/navigation/PanCommand.java (80%) create mode 100644 plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetBoundsCommand.java rename plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/{internal/commands => command/navigation}/SetScaleCommand.java (84%) create mode 100644 plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportBBoxCommand.java rename plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/{internal => }/command/navigation/SetViewportCenterCommand.java (64%) rename plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/{internal => }/command/navigation/SetViewportHeight.java (81%) rename plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/{internal => }/command/navigation/SetViewportWidth.java (79%) rename plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/{internal => }/command/navigation/ZoomCommand.java (81%) rename plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/{internal => }/command/navigation/ZoomExtentCommand.java (71%) delete mode 100644 plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/AbstractNavCommand.java delete mode 100644 plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportBBoxCommand.java delete mode 100644 plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/FixedScalePan.java delete mode 100644 plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/InvalidateCommand.java create mode 100644 plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/commands/PanAndInvalidate.java diff --git a/plugins/org.locationtech.udig.bookmarks/src/org/locationtech/udig/bookmarks/internal/command/GotoBookmarkCommand.java b/plugins/org.locationtech.udig.bookmarks/src/org/locationtech/udig/bookmarks/internal/command/GotoBookmarkCommand.java index 6b4a3477a6..d1e42f35f0 100644 --- a/plugins/org.locationtech.udig.bookmarks/src/org/locationtech/udig/bookmarks/internal/command/GotoBookmarkCommand.java +++ b/plugins/org.locationtech.udig.bookmarks/src/org/locationtech/udig/bookmarks/internal/command/GotoBookmarkCommand.java @@ -10,9 +10,8 @@ package org.locationtech.udig.bookmarks.internal.command; import org.locationtech.udig.project.IMap; -import org.locationtech.udig.project.command.Command; +import org.locationtech.udig.project.command.navigation.AbstractNavCommand; import org.locationtech.udig.project.internal.ProjectPlugin; -import org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand; import org.locationtech.udig.project.render.IViewportModel; import org.locationtech.udig.project.ui.ApplicationGIS; @@ -47,7 +46,7 @@ protected void runImpl( IProgressMonitor monitor ) throws Exception { .getResourceSet().getResource(mapID, true).getContents().get(0)); ApplicationGIS.openMap(map); IViewportModel v = map.getViewportModel(); - + final ReferencedEnvelope bookmarkEnvelope = target.getEnvelope(); final Envelope viewportBounds = v.getBounds(); @@ -55,7 +54,7 @@ protected void runImpl( IProgressMonitor monitor ) throws Exception { final CoordinateReferenceSystem bookmarkCrs = bookmarkEnvelope.getCoordinateReferenceSystem(); final ReferencedEnvelope bookmarkedEnvelopeInVieportCRS; - + if(bookmarkCrs.equals(viewportCrs)){ bookmarkedEnvelopeInVieportCRS = bookmarkEnvelope; }else{ @@ -71,12 +70,9 @@ protected void runImpl( IProgressMonitor monitor ) throws Exception { } } - public Command copy() { - return null; - } - + @Override public String getName() { - return null; + return null; // TODO NLS } } diff --git a/plugins/org.locationtech.udig.catalog.wmt/src/org/locationtech/udig/catalog/internal/wmt/ui/view/WMTZoomLevelSwitcher.java b/plugins/org.locationtech.udig.catalog.wmt/src/org/locationtech/udig/catalog/internal/wmt/ui/view/WMTZoomLevelSwitcher.java index 0770c34289..6e26189919 100644 --- a/plugins/org.locationtech.udig.catalog.wmt/src/org/locationtech/udig/catalog/internal/wmt/ui/view/WMTZoomLevelSwitcher.java +++ b/plugins/org.locationtech.udig.catalog.wmt/src/org/locationtech/udig/catalog/internal/wmt/ui/view/WMTZoomLevelSwitcher.java @@ -23,8 +23,8 @@ import org.locationtech.udig.project.IMap; import org.locationtech.udig.project.IMapCompositionListener; import org.locationtech.udig.project.MapCompositionEvent; +import org.locationtech.udig.project.command.navigation.SetScaleCommand; import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.commands.SetScaleCommand; import org.locationtech.udig.project.render.IViewportModelListener; import org.locationtech.udig.project.render.ViewportModelEvent; import org.locationtech.udig.project.ui.ApplicationGIS; diff --git a/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/FeatureIssue.java b/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/FeatureIssue.java index 50d006d07c..d206f87856 100644 --- a/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/FeatureIssue.java +++ b/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/FeatureIssue.java @@ -34,6 +34,7 @@ import org.locationtech.udig.project.IProject; import org.locationtech.udig.project.command.NavCommand; import org.locationtech.udig.project.command.UndoableComposite; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.ui.ApplicationGIS; import org.locationtech.udig.project.ui.internal.ApplicationGISInternal; import org.locationtech.udig.project.ui.internal.FeatureEditorLoader; @@ -50,7 +51,7 @@ /** * Represents a problem or issue with a feature. The map containing the feature and the * FeatureEditor will both be show. The map will be zoomed to show the feature. - * + * * @author jones * @since 1.0.0 */ @@ -60,7 +61,7 @@ public class FeatureIssue extends AbstractIssue { private static final String LAYER_KEY = "layer"; //$NON-NLS-1$ private static final String PROJECT_KEY = "project"; //$NON-NLS-1$ private static final String FEATURE_KEY = "feature"; //$NON-NLS-1$ - + private SimpleFeature feature; private String viewid; private FeatureEditorLoader featureEditorLoader; @@ -75,33 +76,33 @@ public class FeatureIssue extends AbstractIssue { private static boolean testing=false; public FeatureIssue( ){ - + } - + public FeatureIssue( Priority priority, String description, ILayer containingLayer, SimpleFeature feature, String groupId ) { assert groupId!=null && priority!=null && containingLayer!=null && feature!=null; - + setPriority(priority); setDescription(description); this.layer=containingLayer; this.feature = feature; featureEditorLoader = ApplicationGISInternal.getFeatureEditorLoader(feature); viewid = featureEditorLoader.getViewId(); - + setGroupId(groupId); setBounds(new ReferencedEnvelope(feature.getBounds())); } - + @Override public void setId( String id ) { super.setId(id); } - + @Override public String getEditorID() { return MapEditorWithPalette.ID; } - + @Override public IEditorInput getEditorInput() { return new MapEditorInput(getLayer().getMap()); @@ -110,11 +111,12 @@ public IEditorInput getEditorInput() { @Override public String getViewPartId() { if( viewid==null ){ - + } return viewid; } + @Override public String getProblemObject() { SimpleFeature feature = getFeature(); SimpleFeatureType featureType = feature.getFeatureType(); @@ -135,7 +137,7 @@ public String getProblemObject() { private String getAttribute(SimpleFeature feature, SimpleFeatureType featureType, String attName) { - int attributeIndex = featureType.indexOf(attName); + int attributeIndex = featureType.indexOf(attName); if ( attributeIndex!=-1 ){ Object attribute = feature.getAttribute(attributeIndex); return attribute.toString(); @@ -143,15 +145,17 @@ private String getAttribute(SimpleFeature feature, SimpleFeatureType featureType return null; } + @Override public void fixIssue( IViewPart part, IEditorPart editor ) { if( getLayer() == null ){ Display.getDefault().asyncExec(new Runnable() { - public void run() { + @Override + public void run() { Shell parent = Display.getCurrent().getActiveShell(); String title = Messages.FeatureIssue_DialogText; String message = Messages.FeatureIssue_DialogMessage; MessageDialog.openInformation(parent, title, message); - + } }); return; @@ -169,7 +173,7 @@ public void run() { if( tool !=null ){ tool.run(); } - NavCommand zoom = context.getNavigationFactory().createSetViewportBBoxCommand( + NavCommand zoom = new SetViewportBBoxCommand( bounds, crs); context.sendASyncCommand(zoom); composite.getCommands().add(context.getSelectionFactory().createFIDSelectCommand(getLayer(),getFeature())); @@ -177,10 +181,12 @@ public void run() { context.sendASyncCommand(composite); } - public String getExtensionID() { + @Override + public String getExtensionID() { return EXT_ID; } + @Override public void init( IMemento memento, IMemento viewMemento, String issueId, String groupId, ReferencedEnvelope bounds ) { if( !testing || memento!=null ){ mapID=memento.getString(MAP_KEY); @@ -194,6 +200,7 @@ public void init( IMemento memento, IMemento viewMemento, String issueId, String setBounds(bounds); } + @Override public void save( IMemento memento ) { memento.putString(MAP_KEY, getLayer().getMap().getID().toString()); memento.putString(LAYER_KEY, getLayer().getID().toString()); @@ -248,7 +255,7 @@ private ILayer getLayer() { } if( foundMap==null ) throw new IllegalStateException("This issue is not legal for this uDig instance because the map:"+mapID+" cannot be found."); //$NON-NLS-1$//$NON-NLS-2$ - + List layers= foundMap.getMapLayers(); for( ILayer layer : layers ) { if( layer.getID().toString().equals(layerID) ){ @@ -268,5 +275,5 @@ public static void setTesting( boolean b ) { testing=b; } - + } diff --git a/plugins/org.locationtech.udig.location/src/org/locationtech/udig/location/ui/LocationView.java b/plugins/org.locationtech.udig.location/src/org/locationtech/udig/location/ui/LocationView.java index dd162bcd3a..148d3360c6 100644 --- a/plugins/org.locationtech.udig.location/src/org/locationtech/udig/location/ui/LocationView.java +++ b/plugins/org.locationtech.udig.location/src/org/locationtech/udig/location/ui/LocationView.java @@ -21,7 +21,7 @@ import org.locationtech.udig.location.internal.Messages; import org.locationtech.udig.project.IMap; import org.locationtech.udig.project.command.NavCommand; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.ui.ApplicationGIS; import org.locationtech.udig.ui.SearchPart; diff --git a/plugins/org.locationtech.udig.mapgraphic/src/org/locationtech/udig/mapgraphic/AbstractToggleMapGraphicAction.java b/plugins/org.locationtech.udig.mapgraphic/src/org/locationtech/udig/mapgraphic/AbstractToggleMapGraphicAction.java index 2abb498751..4e24119084 100644 --- a/plugins/org.locationtech.udig.mapgraphic/src/org/locationtech/udig/mapgraphic/AbstractToggleMapGraphicAction.java +++ b/plugins/org.locationtech.udig.mapgraphic/src/org/locationtech/udig/mapgraphic/AbstractToggleMapGraphicAction.java @@ -21,9 +21,9 @@ import org.locationtech.udig.mapgraphic.internal.MapGraphicService; import org.locationtech.udig.project.ILayer; import org.locationtech.udig.project.command.UndoableComposite; -import org.locationtech.udig.project.command.factory.BasicCommandFactory; import org.locationtech.udig.project.internal.Layer; import org.locationtech.udig.project.internal.Map; +import org.locationtech.udig.project.internal.commands.AddLayerCommand; import org.locationtech.udig.project.internal.commands.DeleteLayerCommand; import org.locationtech.udig.project.ui.ApplicationGIS; import org.locationtech.udig.project.ui.internal.ApplicationGISInternal; @@ -39,8 +39,8 @@ * This is a helper class for MapGraphics that should be toggled on and off. Some good candidates * are: Scalebar and legend. *

- * This Example is the adding a Toggle action for LegendGraphic. - * + * This Example is the adding a Toggle action for LegendGraphic. + * *

The following xml snippet must be added to the plugin.xml

*

*

@@ -72,10 +72,10 @@
  *   protected String getExtensionID() {
  *       return "legend"; //$NON-NLS-1$
  *   }
- *   
+ *
  *   public void init( IWorkbenchWindow window ) {
  *   }
- * 
+ *
  * }
  * 
*

@@ -151,7 +151,7 @@ private void addLegend() { if (legendResource == null) return; Layer layer = map.getLayerFactory().createLayer(legendResource); - map.sendCommandSync(BasicCommandFactory.getInstance().createAddLayer(layer)); + map.sendCommandSync(new AddLayerCommand(layer)); } catch (MalformedURLException e) { MapGraphicPlugin.log("", e); //$NON-NLS-1$ } catch (IOException e) { @@ -164,6 +164,7 @@ private void addLegend() { protected abstract String getExtensionID(); + @Override public void init( IWorkbenchWindow window ) { } diff --git a/plugins/org.locationtech.udig.printing.model/src/org/locationtech/udig/printing/model/impl/MapBoxPrinter.java b/plugins/org.locationtech.udig.printing.model/src/org/locationtech/udig/printing/model/impl/MapBoxPrinter.java index bd3de04407..f3257fc4f9 100644 --- a/plugins/org.locationtech.udig.printing.model/src/org/locationtech/udig/printing/model/impl/MapBoxPrinter.java +++ b/plugins/org.locationtech.udig.printing.model/src/org/locationtech/udig/printing/model/impl/MapBoxPrinter.java @@ -26,9 +26,9 @@ import org.locationtech.udig.project.LayerEvent; import org.locationtech.udig.project.MapCompositionEvent; import org.locationtech.udig.project.MapEvent; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.Layer; import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.render.ViewportModel; import org.locationtech.udig.project.render.IViewportModel; import org.locationtech.udig.project.render.IViewportModelListener; diff --git a/plugins/org.locationtech.udig.printing.ui/src/org/locationtech/udig/printing/ui/pdf/ExportPDFWizard.java b/plugins/org.locationtech.udig.printing.ui/src/org/locationtech/udig/printing/ui/pdf/ExportPDFWizard.java index a48a7fbdb1..ab188ba120 100644 --- a/plugins/org.locationtech.udig.printing.ui/src/org/locationtech/udig/printing/ui/pdf/ExportPDFWizard.java +++ b/plugins/org.locationtech.udig.printing.ui/src/org/locationtech/udig/printing/ui/pdf/ExportPDFWizard.java @@ -38,9 +38,9 @@ import org.locationtech.udig.printing.ui.internal.PrintingEngine; import org.locationtech.udig.printing.ui.internal.PrintingPlugin; import org.locationtech.udig.project.IBlackboard; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.Layer; import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.ui.ApplicationGIS; import org.locationtech.udig.project.ui.BoundsStrategy; import org.locationtech.udig.project.ui.SelectionStyle; diff --git a/plugins/org.locationtech.udig.project.tests/src/org/locationtech/udig/project/internal/commands/SetScaleCommandTest.java b/plugins/org.locationtech.udig.project.tests/src/org/locationtech/udig/project/internal/commands/SetScaleCommandTest.java index 4712254baf..2fc538bd1e 100644 --- a/plugins/org.locationtech.udig.project.tests/src/org/locationtech/udig/project/internal/commands/SetScaleCommandTest.java +++ b/plugins/org.locationtech.udig.project.tests/src/org/locationtech/udig/project/internal/commands/SetScaleCommandTest.java @@ -5,6 +5,7 @@ import org.easymock.EasyMock; import org.eclipse.core.runtime.IProgressMonitor; import org.junit.Test; +import org.locationtech.udig.project.command.navigation.SetScaleCommand; import org.locationtech.udig.project.internal.render.ViewportModel; public class SetScaleCommandTest { @@ -13,12 +14,6 @@ public class SetScaleCommandTest { private static final double PREVIOUS_SCALE = 1 / 500; - @Test - public void testCopy() throws Exception { - SetScaleCommand setScaleCommand = new SetScaleCommand(SCALE_TO_SET); - assertNotSame(setScaleCommand, setScaleCommand.copy()); - } - @Test public void ifModelIsSetSetScaleIsCalled() throws Exception { SetScaleCommand setScaleCommand = new SetScaleCommand(SCALE_TO_SET); diff --git a/plugins/org.locationtech.udig.project.ui.tests/src/org/locationtech/udig/project/tests/ui/internal/commands/draw/TestDrawCoordinateCommandHandler.java b/plugins/org.locationtech.udig.project.ui.tests/src/org/locationtech/udig/project/tests/ui/internal/commands/draw/TestDrawCoordinateCommandHandler.java index 4065057c27..c23e5eb501 100644 --- a/plugins/org.locationtech.udig.project.ui.tests/src/org/locationtech/udig/project/tests/ui/internal/commands/draw/TestDrawCoordinateCommandHandler.java +++ b/plugins/org.locationtech.udig.project.ui.tests/src/org/locationtech/udig/project/tests/ui/internal/commands/draw/TestDrawCoordinateCommandHandler.java @@ -38,7 +38,7 @@ import org.locationtech.udig.project.command.Command; import org.locationtech.udig.project.command.CompositeCommand; import org.locationtech.udig.project.command.MapCommand; -import org.locationtech.udig.project.internal.command.navigation.SetViewportCenterCommand; +import org.locationtech.udig.project.command.navigation.SetViewportCenterCommand; import org.locationtech.udig.project.ui.AnimationUpdater; import org.locationtech.udig.project.ui.ApplicationGIS; import org.locationtech.udig.project.ui.IAnimation; diff --git a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/controls/ScaleRatioLabel.java b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/controls/ScaleRatioLabel.java index 0844d634b0..6a93e6d8af 100644 --- a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/controls/ScaleRatioLabel.java +++ b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/controls/ScaleRatioLabel.java @@ -27,7 +27,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.ui.PlatformUI; -import org.locationtech.udig.project.internal.commands.SetScaleCommand; +import org.locationtech.udig.project.command.navigation.SetScaleCommand; import org.locationtech.udig.project.render.IViewportModel; import org.locationtech.udig.project.render.IViewportModelListener; import org.locationtech.udig.project.render.ViewportModelEvent.EventType; diff --git a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/CRSPropertyPage.java b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/CRSPropertyPage.java index d6a58307cf..217e09fe81 100644 --- a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/CRSPropertyPage.java +++ b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/CRSPropertyPage.java @@ -25,10 +25,10 @@ import org.locationtech.udig.project.ILayer; import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.command.UndoableComposite; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.Layer; import org.locationtech.udig.project.internal.Map; import org.locationtech.udig.project.internal.ProjectPlugin; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.commands.ChangeCRSCommand; import org.locationtech.udig.project.ui.internal.commands.SetLayerCRSCommand; import org.locationtech.udig.ui.CRSChooser; diff --git a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/actions/ZoomToLayer.java b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/actions/ZoomToLayer.java index 14edb1a248..66115bd37d 100644 --- a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/actions/ZoomToLayer.java +++ b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/actions/ZoomToLayer.java @@ -25,9 +25,9 @@ import org.eclipse.ui.actions.ActionDelegate; import org.geotools.geometry.jts.ReferencedEnvelope; import org.locationtech.jts.geom.Coordinate; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.Layer; import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.render.impl.ScaleUtils; import org.locationtech.udig.project.ui.internal.ProjectUIPlugin; import org.opengis.referencing.crs.CoordinateReferenceSystem; diff --git a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/properties/GeometryPropertyDescriptor.java b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/properties/GeometryPropertyDescriptor.java index 96000b469f..d1d9290867 100644 --- a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/properties/GeometryPropertyDescriptor.java +++ b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/properties/GeometryPropertyDescriptor.java @@ -30,8 +30,8 @@ import org.geotools.geometry.jts.JTS; import org.locationtech.jts.geom.Envelope; import org.locationtech.jts.geom.Geometry; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.ui.internal.MapEditorPart; import org.locationtech.udig.project.ui.internal.Messages; import org.locationtech.udig.project.ui.internal.ProjectUIPlugin; diff --git a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/ToolContext.java b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/ToolContext.java index 20e04c1311..4b420abfc2 100644 --- a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/ToolContext.java +++ b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/ToolContext.java @@ -15,7 +15,6 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbench; import org.locationtech.udig.project.command.factory.EditCommandFactory; -import org.locationtech.udig.project.command.factory.NavigationCommandFactory; import org.locationtech.udig.project.command.factory.SelectionCommandFactory; import org.locationtech.udig.project.internal.AbstractContext; import org.locationtech.udig.project.ui.commands.DrawCommandFactory; @@ -61,13 +60,6 @@ public interface ToolContext extends IToolContext, AbstractContext { */ EditCommandFactory getEditFactory(); - /** - * Returns a NavigationCommandFactory - * - * @return a NavigationCommandFactory - * @deprecated Please use navigation commands directly - */ - NavigationCommandFactory getNavigationFactory(); /** * Returns the current workbench. *

diff --git a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/display/ToolManager.java b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/display/ToolManager.java index 1631cbb286..e15ef678cd 100644 --- a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/display/ToolManager.java +++ b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/display/ToolManager.java @@ -1010,7 +1010,7 @@ public void run() { forwardAction.setActionDefinitionId("org.eclipse.ui.navigate.forward"); //$NON-NLS-1$ } if (activeMap != ApplicationGIS.NO_MAP) - forwardAction.setEnabled(activeMap.getCommandStack().canRedo()); + forwardAction.setEnabled(activeMap.getNavCommandStack().hasForwardHistory()); else forwardAction.setEnabled(false); return forwardAction; @@ -1099,7 +1099,7 @@ public void run() { backwardAction.setActionDefinitionId("org.eclipse.ui.navigate.back"); //$NON-NLS-1$ } if (activeMap != ApplicationGIS.NO_MAP) - backwardAction.setEnabled(activeMap.getCommandStack().canUndo()); + backwardAction.setEnabled(activeMap.getNavCommandStack().hasBackHistory()); else backwardAction.setEnabled(false); }finally{ diff --git a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/impl/ToolContextImpl.java b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/impl/ToolContextImpl.java index 6b0b9195c7..bd3cdbb3da 100644 --- a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/impl/ToolContextImpl.java +++ b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/impl/ToolContextImpl.java @@ -32,9 +32,7 @@ import org.locationtech.udig.project.command.EditCommand; import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.command.NavCommand; -import org.locationtech.udig.project.command.factory.BasicCommandFactory; import org.locationtech.udig.project.command.factory.EditCommandFactory; -import org.locationtech.udig.project.command.factory.NavigationCommandFactory; import org.locationtech.udig.project.command.factory.SelectionCommandFactory; import org.locationtech.udig.project.internal.impl.AbstractContextImpl; import org.locationtech.udig.project.internal.render.RenderManager; @@ -61,7 +59,6 @@ *

  • {@link org.locationtech.udig.project.ui.internal.tool.impl.ToolContextImpl#getViewportPane Viewport Pane}
  • *
  • {@link org.locationtech.udig.project.ui.internal.tool.impl.ToolContextImpl#getDrawFactory Draw Factory}
  • *
  • {@link org.locationtech.udig.project.ui.internal.tool.impl.ToolContextImpl#getEditFactory Edit Factory}
  • - *
  • {@link org.locationtech.udig.project.ui.internal.tool.impl.ToolContextImpl#getNavigationFactory Navigation Factory}
  • *
  • {@link org.locationtech.udig.project.ui.internal.tool.impl.ToolContextImpl#getSelectionFactory Selection Factory}
  • * *

    @@ -129,15 +126,6 @@ public ICoolBarManager getCoolBarManager() { private final EditCommandFactory editFactory = EditCommandFactory .getInstance(); - /** - * The cached value of the '{@link #getNavigationFactory() Navigation Factory}' - * attribute. - * - * @see #getNavigationFactory() - */ - private final NavigationCommandFactory navigationFactory = NavigationCommandFactory - .getInstance(); - /** * The cached value of the '{@link #getSelectionFactory() Selection Factory}' * attribute. @@ -147,8 +135,6 @@ public ICoolBarManager getCoolBarManager() { private final SelectionCommandFactory selectionFactory = SelectionCommandFactory .getInstance(); - private final BasicCommandFactory basicCommandFactory=BasicCommandFactory.getInstance(); - public ToolContextImpl( ) { super(); } @@ -161,9 +147,7 @@ public DrawCommandFactory getDrawFactory() { public EditCommandFactory getEditFactory() { return editFactory; } - public NavigationCommandFactory getNavigationFactory() { - return navigationFactory; - } + public SelectionCommandFactory getSelectionFactory() { return selectionFactory; } @@ -296,9 +280,6 @@ public void updateUI( Runnable runnable ) { display.asyncExec(runnable); } - public BasicCommandFactory getBasicCommandFactory() { - return this.basicCommandFactory; - } public ToolContextImpl copy() { return new ToolContextImpl(this); diff --git a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/tool/IToolContext.java b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/tool/IToolContext.java index 30013a79e9..5d10ba4601 100644 --- a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/tool/IToolContext.java +++ b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/tool/IToolContext.java @@ -17,9 +17,7 @@ import org.locationtech.udig.project.IAbstractContext; import org.locationtech.udig.project.command.Command; import org.locationtech.udig.project.command.MapCommand; -import org.locationtech.udig.project.command.factory.BasicCommandFactory; import org.locationtech.udig.project.command.factory.EditCommandFactory; -import org.locationtech.udig.project.command.factory.NavigationCommandFactory; import org.locationtech.udig.project.command.factory.SelectionCommandFactory; import org.locationtech.udig.project.ui.commands.DrawCommandFactory; import org.locationtech.udig.project.ui.render.displayAdapter.ViewportPane; @@ -68,16 +66,6 @@ public interface IToolContext extends IAbstractContext { */ public EditCommandFactory getEditFactory(); - /** - * Returns a NavigationCommandFactory. Used to create commands that change the current view of - * the map. - * - * @return a NavigationCommandFactory - * @see NavigationCommandFactory - * @deprecated Please use navigation commands directly - */ - public NavigationCommandFactory getNavigationFactory(); - /** * Returns a SelectionCommandFactory. Used to create commands that changes the current * selection. @@ -85,12 +73,6 @@ public interface IToolContext extends IAbstractContext { * @return a SelectionCommandFactory */ public SelectionCommandFactory getSelectionFactory(); - /** - * Returns a BasicCommandFactory. - * - * @return a BasicCommandFactory - */ - public BasicCommandFactory getBasicCommandFactory(); /** * Dispatches a command. If the command is a IDrawCommand the command will diff --git a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/viewers/MapViewer.java b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/viewers/MapViewer.java index 7d49dc34f1..406bcc06de 100644 --- a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/viewers/MapViewer.java +++ b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/viewers/MapViewer.java @@ -25,8 +25,8 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartSite; import org.geotools.geometry.jts.ReferencedEnvelope; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.render.RenderManager; import org.locationtech.udig.project.internal.render.ViewportModel; import org.locationtech.udig.project.ui.internal.MapPart; diff --git a/plugins/org.locationtech.udig.project/META-INF/MANIFEST.MF b/plugins/org.locationtech.udig.project/META-INF/MANIFEST.MF index 9c9b041008..13a8252db6 100644 --- a/plugins/org.locationtech.udig.project/META-INF/MANIFEST.MF +++ b/plugins/org.locationtech.udig.project/META-INF/MANIFEST.MF @@ -17,24 +17,31 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.emf.ecore.xmi, org.locationtech.udig.ui Bundle-ActivationPolicy: lazy -Export-Package: org.locationtech.udig.project,org.locationtech.udig.pr - oject.command,org.locationtech.udig.project.command.factory,org.locat - iontech.udig.project.command.map,org.locationtech.udig.project.comman - d.provider,org.locationtech.udig.project.element,org.locationtech.udi - g.project.element.impl,org.locationtech.udig.project.element.util,org - .locationtech.udig.project.geoselection,org.locationtech.udig.project - .interceptor,org.locationtech.udig.project.internal,org.locationtech. - udig.project.internal.command.navigation,org.locationtech.udig.projec - t.internal.commands,org.locationtech.udig.project.internal.commands.e - dit,org.locationtech.udig.project.internal.commands.selection,org.loc - ationtech.udig.project.internal.impl,org.locationtech.udig.project.in - ternal.interceptor;x-friends:="org.locationtech.udig.project.tests",o - rg.locationtech.udig.project.internal.render,org.locationtech.udig.pr - oject.internal.render.impl,org.locationtech.udig.project.internal.ren - der.util,org.locationtech.udig.project.internal.util,org.locationtech - .udig.project.memento,org.locationtech.udig.project.preferences,org.l - ocationtech.udig.project.render,org.locationtech.udig.project.render. - displayAdapter +Export-Package: org.locationtech.udig.project, + org.locationtech.udig.project.command, + org.locationtech.udig.project.command.factory, + org.locationtech.udig.project.command.map, + org.locationtech.udig.project.command.navigation, + org.locationtech.udig.project.command.provider, + org.locationtech.udig.project.element, + org.locationtech.udig.project.element.impl, + org.locationtech.udig.project.element.util, + org.locationtech.udig.project.geoselection, + org.locationtech.udig.project.interceptor, + org.locationtech.udig.project.internal, + org.locationtech.udig.project.internal.commands, + org.locationtech.udig.project.internal.commands.edit, + org.locationtech.udig.project.internal.commands.selection, + org.locationtech.udig.project.internal.impl, + org.locationtech.udig.project.internal.interceptor;x-friends:="org.locationtech.udig.project.tests", + org.locationtech.udig.project.internal.render, + org.locationtech.udig.project.internal.render.impl, + org.locationtech.udig.project.internal.render.util, + org.locationtech.udig.project.internal.util, + org.locationtech.udig.project.memento, + org.locationtech.udig.project.preferences, + org.locationtech.udig.project.render, + org.locationtech.udig.project.render.displayAdapter Import-Package: javax.media.jai, javax.media.jai.iterator, javax.media.jai.operator, diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/BasicCommandFactory.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/BasicCommandFactory.java deleted file mode 100644 index 58515ce1cb..0000000000 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/BasicCommandFactory.java +++ /dev/null @@ -1,91 +0,0 @@ -/* uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2004-2012, Refractions Research Inc. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD - * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). - */ -package org.locationtech.udig.project.command; - -import org.locationtech.udig.project.ILayer; -import org.locationtech.udig.project.IMap; -import org.locationtech.udig.project.internal.Layer; -import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.commands.AddLayerCommand; -import org.locationtech.udig.project.internal.commands.ChangeCRSCommand; -import org.locationtech.udig.project.internal.commands.DeleteLayerCommand; - -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -/** - * Creates Edit commands which must be used to modify editable feature data. API internal classes - * are in the returned API - * - * @author jeichar - * @deprecated - * @since 0.3 - */ -public class BasicCommandFactory { - /** - * Creates a new EditCommandFactory object - * - * @return a new EditCommandFactory object - */ - public static BasicCommandFactory getInstance() { - return instance; - } - - private static final BasicCommandFactory instance = new BasicCommandFactory(); - protected BasicCommandFactory() { - // no op - } - - /** - * Create a delete layer command - * - * @param map the map containing the layer - * @param layer the layer to delete - * @return a new {@linkplain DeleteLayerCommand}object that deletes the layer. - * @see DeleteLayerCommand - */ - public UndoableMapCommand createDeleteLayer( ILayer layer ) { - return new DeleteLayerCommand((Layer) layer); - } - - /** - * Create an Add Layer command - * - * @param layer the layer to add to the map. - * @return a new {@linkplain AddLayerCommand}object that deletes the feature. - * @see AddLayerCommand - */ - public UndoableMapCommand createAddLayer( ILayer layer ) { - return new AddLayerCommand((Layer) layer); - } - - /** - * Create an Add Layer command - * - * @param layer the layer to add to the map. - * @param index the zorder where the layer will be added. - * @return a new {@linkplain AddLayerCommand}object that deletes the feature. - * @see AddLayerCommand - */ - public UndoableMapCommand createAddLayer( ILayer layer, int index ) { - return new AddLayerCommand((Layer) layer, index); - } - - /** - * Create a Change CRS command - * - * @param map the map for which the CRS is going to change. - * @return a new {@linkplain ChangeCRSCommand}object that changes the CRS. - * @see ChangeCRSCommand - */ - public UndoableMapCommand createChangeCRS( IMap map, CoordinateReferenceSystem crs ) { - return new ChangeCRSCommand((Map) map, crs); - } - -} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/Command.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/Command.java index d0593544ef..7a4f1c8890 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/Command.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/Command.java @@ -45,26 +45,10 @@ public interface Command { */ public void run( IProgressMonitor monitor ) throws Exception; - /** - * Instantiates a new copy of the command that will operate in the same manner as the original - * command. API isn't this cloneable? - * - * @return A copy of the current command. The new command must run the same way as the current - * object. - *

    - * If the current command has already executed it cannot be used again, but a copy may - * because a copy should contain none of the state side-effect that execution has on a - * command - *

    - * @deprecated - */ - public Command copy(); - /** * Each command has a name that is displayed with the undo/redo buttons. *

    * @return The name of the command (often translated) */ public String getName(); - } diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/CommandManager.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/CommandManager.java index f729904a0c..9dd12a38c5 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/CommandManager.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/CommandManager.java @@ -28,7 +28,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialogWithToggle; @@ -39,7 +39,7 @@ /** * A commands Manager executes commands in a seperate thread, either synchronously or a * synchronously. - * + * * @author Jesse * @since 1.0.0 */ @@ -60,7 +60,7 @@ public class CommandManager implements CommandStack, NavCommandStack { /** * Creates a new instance of CommandManager - * + * * @param handler an error handler to use to handle thrown exceptions. */ public CommandManager( String managerName, ErrorHandler handler, CommandListener commandCompletionListener ) { @@ -71,7 +71,7 @@ public CommandManager( String managerName, ErrorHandler handler, CommandListener } /** * Creates a new instance of CommandManager - * + * * @param handler an error handler to use to handle thrown exceptions. */ public CommandManager( String managerName, ErrorHandler handler ) { @@ -79,19 +79,19 @@ public CommandManager( String managerName, ErrorHandler handler ) { } /** * Creates a new instance of CommandManager - * + * * @param handler an error handler to use to handle thrown exceptions. */ public CommandManager( String managerName, ErrorHandler handler, CommandListener commandCompletionListener, long timeout2 ) { this(managerName, handler, commandCompletionListener); this.timeout = timeout2; - + } /** * Executes a command. Calls the Errorhandler if an exception is thrown. - * + * * @param command The command to execute * @param async flag indicating wether command should be executed sync vs async. * @return true if no problems were encountered while queueing command. Problems will typically @@ -102,7 +102,7 @@ public boolean execute( final Command command, boolean async ) { return doMakeRequest(command, async, type); } - + /** * @param command command to perform * @param async whether to do request synchronously @@ -113,7 +113,7 @@ private boolean doMakeRequest( final Command command, boolean async, int type ) Request request = new Request(type, command, async, Display.getCurrent() != null); synchronized (this) { if (commandExecutor == null) { - commandExecutor = new Executor(managerName); + commandExecutor = new Executor(managerName); } } commandExecutor.addRequest(request); @@ -143,7 +143,7 @@ private boolean doMakeRequest( final Command command, boolean async, int type ) } private long waitOnRequest( Request request ) throws InterruptedException { - ProjectPlugin.trace(TRACE_ID,getClass(), + ProjectPlugin.trace(TRACE_ID,getClass(), "synchronous command NOT in display thread\nTimout=" + timeout, null); //$NON-NLS-1$ long tries = 0; @@ -158,14 +158,14 @@ private long waitOnRequest( Request request ) throws InterruptedException { /** * This method is special wait command that ensures that the display does not block. It executes * the jobs waiting for display. - * + * * @param current the current display * @param request * @throws InterruptedException * @see Display#readAndDispatch() */ private long waitInDisplay( Display current, Request request ) throws InterruptedException { - ProjectPlugin.trace(TRACE_ID,getClass(), + ProjectPlugin.trace(TRACE_ID,getClass(), "synchronous command IN display thread\nTimout=" + timeout, null); //$NON-NLS-1$ long start = System.currentTimeMillis(); @@ -189,13 +189,13 @@ private long waitInDisplay( Display current, Request request ) throws Interrupte private boolean mustWait( Request request, long tries ) { ProjectPlugin .trace( - TRACE_ID, getClass(), + TRACE_ID, getClass(), "timeout :" + timeout + ", tries: " + tries + ", completed:" + request.completed, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return !request.completed && (tries < timeout || timeout == -1); } /** * Executes the last undone command, if there are any commands to undo. - * + * * @param runAsync true to run undo asynchronously */ public void redo( boolean runAsync ) { @@ -204,7 +204,7 @@ public void redo( boolean runAsync ) { /** * Undoes the last command if possible. - * + * * @param runAsync true to run undo asynchronously */ public void undo( boolean runAsync ) { @@ -213,7 +213,7 @@ public void undo( boolean runAsync ) { /** * Adds an Errorhandler to the list of error handlers - * + * * @param handler the error handler to add. * @see ErrorHandler */ @@ -223,7 +223,7 @@ public void addErrorHandler( ErrorHandler handler ) { /** * Removes an Errorhandler from the list of error handlers - * + * * @param handler the error handler to remove. * @see ErrorHandler */ @@ -234,13 +234,14 @@ public void removeErrorHandler( ErrorHandler handler ) { /** * @see org.locationtech.udig.project.command.CommandStack#canUndo() */ + @Override public boolean canUndo() { if( commandExecutor ==null ) return false; - + Command c; if (!commandExecutor.history.isEmpty()) { - c = (Command) commandExecutor.history.peek(); + c = commandExecutor.history.peek(); if (c instanceof UndoableCommand) return true; } @@ -250,6 +251,7 @@ public boolean canUndo() { /** * @see org.locationtech.udig.project.command.CommandStack#canRedo() */ + @Override public boolean canRedo() { if (commandExecutor!=null && !commandExecutor.undone.isEmpty()) { return true; @@ -260,6 +262,7 @@ public boolean canRedo() { /** * @see org.locationtech.udig.project.command.NavCommandStack#hasBackHistory() */ + @Override public boolean hasBackHistory() { return canUndo(); } @@ -267,6 +270,7 @@ public boolean hasBackHistory() { /** * @see org.locationtech.udig.project.command.NavCommandStack#hasForwardHistory() */ + @Override public boolean hasForwardHistory() { return canRedo(); } @@ -274,7 +278,7 @@ public boolean hasForwardHistory() { /** * Executes commands in a seperate thread from the requesting thread. JONES: Should support * force kill of a command. - * + * * @author Jesse * @since 1.0.0 */ @@ -287,7 +291,7 @@ public class Executor extends Job { /** * Construct Executor. - * + * * @param name the name of the job * @param type the type of the executor. (RUN, UNDO, REDO) */ @@ -300,9 +304,9 @@ public Executor( String name ) { Request currentRequest; @Override protected IStatus run( IProgressMonitor monitor ) { - monitor.beginTask(Messages.CommandManager_ProgressMonitor, IProgressMonitor.UNKNOWN); + monitor.beginTask(Messages.CommandManager_ProgressMonitor, IProgressMonitor.UNKNOWN); while( !getThread().isInterrupted() ) { - + synchronized (this) { currentRequest = commands.poll(); if( currentRequest==null ) @@ -341,7 +345,7 @@ private void run( IProgressMonitor monitor, Request request ) { /** * Adds a command to the stack of commands that needs to be executed. - * + * * @param request */ public void addRequest( Request request ) { @@ -376,7 +380,7 @@ synchronized void removeCommand( Request request ) { /** * Executes a command. Calls the Errorhandler if an exception is thrown. - * + * * @param command The command to execute */ private void execute( final Command command, IProgressMonitor monitor ) { @@ -392,13 +396,13 @@ private void execute( final Command command, IProgressMonitor monitor ) { if (command instanceof PostDeterminedEffectCommand) { PostDeterminedEffectCommand c = (PostDeterminedEffectCommand) command; - if (c.execute(new SubProgressMonitor(monitor, 1000))) { + if (c.execute(SubMonitor.convert(monitor, 1000))) { undone.clear(); addToHistory(command); } } else { - command.run(new SubProgressMonitor(monitor, 1000)); + command.run(SubMonitor.convert(monitor, 1000)); undone.clear(); addToHistory(command); @@ -426,7 +430,7 @@ private void addToHistory( final Command command ) { history.removeFirst(); history.addLast(command); } - + private boolean openWarning( final Command command ) { final boolean[] runCommand=new boolean[1]; if (!(command instanceof UndoableCommand) @@ -438,9 +442,10 @@ private boolean openWarning( final Command command ) { .getBoolean(PreferenceConstants.P_IRREVERSIBLE_COMMAND_VALUE); } PlatformGIS.syncInDisplayThread(new Runnable(){ + @Override public void run() { String string = Messages.CommandManager_warning + command.getName(); - if ( command instanceof RollbackCommand || + if ( command instanceof RollbackCommand || command instanceof CommitCommand ) string += "?"; //$NON-NLS-1$ else @@ -449,8 +454,8 @@ public void run() { .openOkCancelConfirm( PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getShell(), - Messages.CommandManager_warningTitle, string, - Messages.CommandManager_toggleMessage, false, preferenceStore, PreferenceConstants.P_WARN_IRREVERSIBLE_COMMAND); + Messages.CommandManager_warningTitle, string, + Messages.CommandManager_toggleMessage, false, preferenceStore, PreferenceConstants.P_WARN_IRREVERSIBLE_COMMAND); runCommand[0] = dialog.getReturnCode() == IDialogConstants.OK_ID; if (dialog.getToggleState()) { preferenceStore @@ -469,14 +474,14 @@ public void run() { * Notifies the owner that the command has been executed. */ private void notifyOwner( Command command ) { - + for( CommandListener listener : completionHandlers ) { if (command instanceof NavCommand) { listener.commandExecuted(MapCommandListener.NAV_COMMAND); } else { listener.commandExecuted(MapCommandListener.COMMAND); } - + } } @@ -488,13 +493,13 @@ private void redo( IProgressMonitor monitor ) { if( undone.isEmpty() ) return; Command command = undone.removeLast(); - monitor.beginTask(Messages.CommandManager_redo + command.getName(), 1000); + monitor.beginTask(Messages.CommandManager_redo + command.getName(), 1000); try { if (command instanceof PostDeterminedEffectCommand) { PostDeterminedEffectCommand post = (PostDeterminedEffectCommand) command; - post.execute(new SubProgressMonitor(monitor, 1000)); + post.execute(SubMonitor.convert(monitor, 1000)); } else { - command.run(new SubProgressMonitor(monitor, 1000)); + command.run(SubMonitor.convert(monitor, 1000)); } addToHistory(command); notifyOwner(command); @@ -533,9 +538,9 @@ private void undo( IProgressMonitor monitor ) { c = history.removeLast(); if (c instanceof UndoableCommand) { UndoableCommand command = (UndoableCommand) c; - monitor.beginTask(Messages.CommandManager_undo + command.getName(), 1000); + monitor.beginTask(Messages.CommandManager_undo + command.getName(), 1000); try { - command.rollback(new SubProgressMonitor(monitor, 1000)); + command.rollback(SubMonitor.convert(monitor, 1000)); addToUndone(command); } catch (Throwable e) { handleRollbackError(command, e); @@ -574,7 +579,7 @@ public void rerunCommands( IProgressMonitor monitor ) { Queue q = history; history = new LinkedList(); for( Iterator iter = q.iterator(); iter.hasNext(); ) { - Command command = (Command) iter.next(); + Command command = iter.next(); execute(command, monitor); } } @@ -583,7 +588,7 @@ public void rerunCommands( IProgressMonitor monitor ) { * TODO Purpose of org.locationtech.udig.project.command *

    *

    - * + * * @author Jesse * @since 1.0.0 */ @@ -609,7 +614,7 @@ public static class Request { /** * Construct Request. - * + * * @param type the type of request * @param command the command to be done/undone/redone */ @@ -623,7 +628,7 @@ public Request( int type, Command command, boolean async, boolean requestByDispl /** * Determines if the request is synchronous. - * + * * @return */ public boolean isSync() { @@ -632,7 +637,7 @@ public boolean isSync() { } /** * Execute Command syncrounously. IE wait until command is complete before returning. - * + * * @return true if no problems were encountered while queueing command. Problems will typically * occur when the command is synchronous and it times out or is interrupted. */ @@ -645,12 +650,12 @@ public int getMaxHistorySize() { /** * Execute Command asyncrounously. IE return immediately, do not wait until command is complete * before returning. - * + * * @return true if no problems were encountered while queueing command. Problems will typically * occur when the command is synchronous and it times out or is interrupted. */ public boolean aSyncExecute( Command command ) { return execute(command, true); } - + } diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavCommand.java index f41148e798..2998ddaf0f 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavCommand.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavCommand.java @@ -12,18 +12,18 @@ import org.locationtech.udig.project.internal.render.ViewportModel; /** - * All implementations of NavCommand are used to manipulate the viewport model of the map. + * All implementations of NavCommand are used to manipulate the viewport model of the map. * In addition they are send to the Navigation Command Stack rather than the normal command stack * for execution. - * + * * @author Jesse * @since 0.5 */ -public interface NavCommand extends UndoableMapCommand, MapCommand { +public interface NavCommand extends MapCommand { /** * Set the viewport model that the command operates on. - * + * * @param model * @see ViewportModel */ diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavigationCommandFactory.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavigationCommandFactory.java deleted file mode 100644 index 3772fb1832..0000000000 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavigationCommandFactory.java +++ /dev/null @@ -1,158 +0,0 @@ -/* uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2004-2012, Refractions Research Inc. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD - * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). - */ -package org.locationtech.udig.project.command; - -import java.util.Arrays; - -import org.locationtech.udig.project.internal.command.navigation.NavComposite; -import org.locationtech.udig.project.internal.command.navigation.PanCommand; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; -import org.locationtech.udig.project.internal.command.navigation.SetViewportCenterCommand; -import org.locationtech.udig.project.internal.command.navigation.SetViewportHeight; -import org.locationtech.udig.project.internal.command.navigation.SetViewportWidth; -import org.locationtech.udig.project.internal.command.navigation.ZoomCommand; -import org.locationtech.udig.project.internal.command.navigation.ZoomExtentCommand; - -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import org.locationtech.jts.geom.Coordinate; -import org.locationtech.jts.geom.Envelope; - -/** - * Factory providing default implementations of common navigation commands. - * - * @author jeichar - * @deprecated Moved to org.locationtech.udig.project.command.factory.NavigationCommandFactory - * @since TODO provide version - */ -public class NavigationCommandFactory { - /** - * Creates a new NavigationCommandFactory object - * - * @return a new NavigationCommandFactory object - */ - public static NavigationCommandFactory getInstance() { - return instance; - } - private static final NavigationCommandFactory instance = new NavigationCommandFactory(); - protected NavigationCommandFactory() { - // no op - } - - /** - * Creates a new {@linkplain NavComposite} - * - * @param commands an array of commands to execute as a simgle command. The array will be - * executed from position 0 to position length-1 in order. - * @return a new NavComposite object - * @see NavCommand - */ - public NavCommand createCompositeCommand( NavCommand[] commands ) { - return new NavComposite(Arrays.asList(commands)); - } - - /** - * Creates a new {@linkplain SetViewportBBoxCommand} - * - * @param newbbox the new bounding box to set in the viewport - * @return a new SetViewportBBoxCommand object - * @see NavCommand - * @see Envelope - */ - public NavCommand createSetViewportBBoxCommand( Envelope newbbox ) { - return new SetViewportBBoxCommand(newbbox); - } - - /** - * Creates a new {@linkplain ZoomCommand} - * - * @param zoomfactor the amount to zoom - * @return a new ZoomCommand object - * @see NavCommand - */ - public NavCommand createZoomCommand( double zoomfactor ) { - return new ZoomCommand(zoomfactor); - } - - /** - * Creates a new {@linkplain ZoomExtentCommand} - * - * @return a new ZoomExtentCommand object - * @see NavCommand - */ - public NavCommand createZoomExtentCommand() { - return new ZoomExtentCommand(); - } - - /** - * Creates a new {@linkplain SetViewportCenterCommand} - * - * @param center Sets the center of the viewport. The Coordinate must be in world coordinates. - * @return a new SetViewportCenterCommand object - * @see NavCommand - * @see Coordinate - */ - public NavCommand createSetViewportCenterCommand( Coordinate center ) { - return new SetViewportCenterCommand(center); - } - - /** - * Creates a new {@linkplain SetViewportHeight} - * - * @param height The new viewport height - * @return a new SetViewportHeight object - * @see NavCommand - */ - public NavCommand createSetViewportHeight( double height ) { - return new SetViewportHeight(height); - } - - /** - * Creates a new {@linkplain SetViewportWidth} - * - * @param width the new viewport width - * @return a new SetViewportWidth object - * @see NavCommand - */ - public NavCommand createSetViewportWidth( double width ) { - return new SetViewportWidth(width); - } - - /** - * Creates a new {@linkplain PanCommand}Pans the viewport in terms of pixels on the screen. - * Each pixel represents a distance in world coordinates, the x and y distances differ, so a pan - * of 8 pixels in the x direction will be translated to a pan of 8*xdistance in the world. - * - * @param xpixels The amount, in pixels, to pan in the x direction - * @param ypixels The amount, in pixels, to pan in the y direction - * @return a new PanCommand object - * @see NavCommand - */ - public NavCommand createPanCommandUsingScreenCoords( int xpixels, int ypixels ) { - return new PanCommand(xpixels, ypixels); - } - - /** - * Creates a new {@linkplain PanCommand} - * - * @param x The amount, in world coordinates, to pan in the x direction - * @param y The amount, in world coordinates, to pan in the y direction - * @return a new PanCommand object - * @see NavCommand - */ - public NavCommand createPanCommandUsingWorldCoords( double x, double y ) { - return new PanCommand(x, y); - } - - public NavCommand createSetViewportBBoxCommand(Envelope bounds, CoordinateReferenceSystem crs) { - return new SetViewportBBoxCommand(bounds, crs); - } - -} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/factory/BasicCommandFactory.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/factory/BasicCommandFactory.java deleted file mode 100644 index 970decc1e1..0000000000 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/factory/BasicCommandFactory.java +++ /dev/null @@ -1,173 +0,0 @@ -/* uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2004-2012, Refractions Research Inc. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD - * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). - */ -package org.locationtech.udig.project.command.factory; - -import java.util.Collection; -import java.util.List; - -import org.locationtech.udig.catalog.IGeoResource; -import org.locationtech.udig.project.ILayer; -import org.locationtech.udig.project.IMap; -import org.locationtech.udig.project.Interaction; -import org.locationtech.udig.project.command.UndoableMapCommand; -import org.locationtech.udig.project.internal.Layer; -import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.Project; -import org.locationtech.udig.project.internal.commands.AddLayerCommand; -import org.locationtech.udig.project.internal.commands.AddLayersCommand; -import org.locationtech.udig.project.internal.commands.ChangeCRSCommand; -import org.locationtech.udig.project.internal.commands.CreateMapCommand; -import org.locationtech.udig.project.internal.commands.DeleteLayerCommand; -import org.locationtech.udig.project.internal.commands.SetApplicabilityCommand; - -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -/** - * Creates Edit commands which must be used to modify editable feature data. API internal classes - * are in the returned API - * - * @author jeichar - * @since 0.3 - */ -@SuppressWarnings("deprecation") -public class BasicCommandFactory extends org.locationtech.udig.project.command.BasicCommandFactory { - /** - * Creates a new EditCommandFactory object - * - * @return a new EditCommandFactory object - */ - public static BasicCommandFactory getInstance() { - return instance; - } - - private static final BasicCommandFactory instance = new BasicCommandFactory(); - protected BasicCommandFactory() { - // no op - } - - /** - * Create a delete layer command - * - * @param map the map containing the layer - * @param layer the layer to delete - * @return a new {@linkplain DeleteLayerCommand}object that deletes the layer. - * @see DeleteLayerCommand - */ - public UndoableMapCommand createDeleteLayer( ILayer layer ) { - return new DeleteLayerCommand((Layer) layer); - } - - /** - * Create an Add Layer command - * - * @param layer the layer to add to the map. - * @return a new {@linkplain AddLayerCommand}object that deletes the feature. - * @see AddLayerCommand - */ - public UndoableMapCommand createAddLayer( ILayer layer ) { - return new AddLayerCommand((Layer) layer); - } - - /** - * Create an Add Layer command - * - * @param layer the layer to add to the map. - * @param index the zorder where the layer will be added. - * @return a new {@linkplain AddLayerCommand}object that deletes the feature. - * @see AddLayerCommand - */ - public UndoableMapCommand createAddLayer( ILayer layer, int index ) { - return new AddLayerCommand((Layer) layer, index); - } - - /** - * Create an AddLayers command that adds all the layers in the collection - * - * @param evaluationObject the layer to add to the map. - * @param index the zorder where the layer will be added. - * @return a new {@linkplain AddLayersCommand}object that deletes the feature. - * @see AddLayersCommand - */ - public UndoableMapCommand createAddManyLayers( Collection layers, int index ) { - return new AddLayersCommand(layers, index); - } - - /** - * Create an AddLayers command that adds all the layers in the collection - * - * @param evaluationObject the layer to add to the map. - * @return a new {@linkplain AddLayersCommand}object that deletes the feature. - * @see AddLayersCommand - */ - public UndoableMapCommand createAddManyLayers( Collection layers ) { - return new AddLayersCommand(layers); - } - - /** - * Create a Change CRS command - * - * @param map the map for which the CRS is going to change. - * @return a new {@linkplain ChangeCRSCommand}object that changes the CRS. - * @see ChangeCRSCommand - */ - public UndoableMapCommand createChangeCRS( IMap map, CoordinateReferenceSystem crs ) { - return new ChangeCRSCommand((Map) map, crs); - } - - /** - * Create a CreateMapCommand - * - * @param name the name of the map - * @param layerResources the IGeoResources that will make up the layers of the map. - * @param owner The project that will contain the map. - * @return - */ - public UndoableMapCommand createCreateMapCommand( String name, List layerResources, - Project owner ) { - return new CreateMapCommand(name, layerResources, owner); - } - - /** - * Create a CreateMapCommand - * - * @param layerResources the IGeoResources that will make up the layers of the map. - * @param owner The project that will contain the map. - * @return - */ - public UndoableMapCommand createCreateMapCommand( List layerResources, Project owner ) { - return new CreateMapCommand(null, layerResources, owner); - } - - /** - * Create a CreateMapCommand - * - * @param name the name of the map - * @param layerResources the IGeoResources that will make up the layers of the map. - * @return - */ - public UndoableMapCommand createCreateMapCommand( String name, List layerResources ) { - return new CreateMapCommand(name, layerResources, null); - } - - /** - * Create a CreateMapCommand - * - * @param layerResources the objects, (Layers or IGeoResources) that will make up the map. - * @return - */ - public UndoableMapCommand createCreateMapCommand( List layerResources ) { - return new CreateMapCommand(null, layerResources, null); - } - - public UndoableMapCommand createSetApplicabilityCommand( ILayer layer, Interaction applicabilityId, boolean newValue ) { - return new SetApplicabilityCommand(layer, applicabilityId, newValue); - } - -} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/factory/NavigationCommandFactory.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/factory/NavigationCommandFactory.java deleted file mode 100644 index a922113e88..0000000000 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/factory/NavigationCommandFactory.java +++ /dev/null @@ -1,171 +0,0 @@ -/* uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2004-2012, Refractions Research Inc. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD - * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). - */ -package org.locationtech.udig.project.command.factory; - -import java.util.Arrays; - -import org.locationtech.udig.project.command.NavCommand; -import org.locationtech.udig.project.internal.command.navigation.NavComposite; -import org.locationtech.udig.project.internal.command.navigation.PanCommand; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; -import org.locationtech.udig.project.internal.command.navigation.SetViewportCenterCommand; -import org.locationtech.udig.project.internal.command.navigation.SetViewportHeight; -import org.locationtech.udig.project.internal.command.navigation.SetViewportWidth; -import org.locationtech.udig.project.internal.command.navigation.ZoomCommand; -import org.locationtech.udig.project.internal.command.navigation.ZoomExtentCommand; - -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import org.locationtech.jts.geom.Coordinate; -import org.locationtech.jts.geom.Envelope; - -/** - * Factory providing default implementations of common navigation commands. - * - * @author jeichar - * @since 1.0 - * @deprecated Please use navigation commands directly - */ -@SuppressWarnings("deprecation") -public class NavigationCommandFactory /*extends org.locationtech.udig.project.command.NavigationCommandFactory */ { - /** - * Creates a new NavigationCommandFactory object - * - * @return a new NavigationCommandFactory object - */ - public static NavigationCommandFactory getInstance() { - return instance; - } - private static final NavigationCommandFactory instance = new NavigationCommandFactory(); - protected NavigationCommandFactory() { - // no op - } - - /** - * Creates a new {@linkplain NavComposite} - * - * @param commands an array of commands to execute as a simgle command. The array will be - * executed from position 0 to position length-1 in order. - * @return a new NavComposite object - * @see NavCommand - * @deprecated Please use new NavComposite(Arrays.asList(commands)) - */ - public NavCommand createCompositeCommand( NavCommand[] commands ) { - return new NavComposite(Arrays.asList(commands)); - } - - /** - * Creates a new {@linkplain SetViewportBBoxCommand} - * - * @param newbbox the new bounding box to set in the viewport - * @return a new SetViewportBBoxCommand object - * @see NavCommand - * @see Envelope - * @deprecated Please use new SetViewportBBoxCommand( newbbox ); - */ - public NavCommand createSetViewportBBoxCommand( Envelope newbbox ) { - return new SetViewportBBoxCommand(newbbox); - } - - /** - * Creates a new {@linkplain ZoomCommand} - * - * @param zoomfactor the amount to zoom - * @return a new ZoomCommand object - * @see NavCommand - * @deprecated Please use new ZoomCommand(zoomfactor) - */ - public NavCommand createZoomCommand( double zoomfactor ) { - return new ZoomCommand(zoomfactor); - } - - /** - * Creates a new {@linkplain ZoomExtentCommand} - * - * @return a new ZoomExtentCommand object - * @see NavCommand - * @deprecated Please use ZoomExtentCommand() - */ - public NavCommand createZoomExtentCommand() { - return new ZoomExtentCommand(); - } - - /** - * Creates a new {@linkplain SetViewportCenterCommand} - * - * @param center Sets the center of the viewport. The Coordinate must be in world coordinates. - * @return a new SetViewportCenterCommand object - * @see NavCommand - * @see Coordinate - * @deprecated Please use new SetViewportCenterCommand(center) - */ - public NavCommand createSetViewportCenterCommand( Coordinate center ) { - return new SetViewportCenterCommand(center); - } - - /** - * Creates a new {@linkplain SetViewportHeight} - * - * @param height The new viewport height - * @return a new SetViewportHeight object - * @see NavCommand - * @deprecated Please use new SetViewportHeight(height) - */ - public NavCommand createSetViewportHeight( double height ) { - return new SetViewportHeight(height); - } - - /** - * Creates a new {@linkplain SetViewportWidth} - * - * @param width the new viewport width - * @return a new SetViewportWidth object - * @see NavCommand - * @deprecated Please use new SetViewportWidth(width) - */ - public NavCommand createSetViewportWidth( double width ) { - return new SetViewportWidth(width); - } - - /** - * Creates a new {@linkplain PanCommand}Pans the viewport in terms of pixels on the screen. - * Each pixel represents a distance in world coordinates, the x and y distances differ, so a pan - * of 8 pixels in the x direction will be translated to a pan of 8*xdistance in the world. - * - * @param xpixels The amount, in pixels, to pan in the x direction - * @param ypixels The amount, in pixels, to pan in the y direction - * @return a new PanCommand object - * @see NavCommand - * @deprecated Please use new PanCommand(xpixels, ypixels) - */ - public NavCommand createPanCommandUsingScreenCoords( int xpixels, int ypixels ) { - return new PanCommand(xpixels, ypixels); - } - - /** - * Creates a new {@linkplain PanCommand} - * - * @param x The amount, in world coordinates, to pan in the x direction - * @param y The amount, in world coordinates, to pan in the y direction - * @return a new PanCommand object - * @see NavCommand - * @deprecated Please use new PanCommand(x, y) - */ - public NavCommand createPanCommandUsingWorldCoords( double x, double y ) { - return new PanCommand(x, y); - } - /** - * @deprecated Please use new SetViewportBBoxCommand(bounds, crs) - */ - public NavCommand createSetViewportBBoxCommand(Envelope bounds, CoordinateReferenceSystem crs) { - return new SetViewportBBoxCommand(bounds, crs); - } - -} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/AbstractNavCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/AbstractNavCommand.java new file mode 100644 index 0000000000..56dc454bca --- /dev/null +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/AbstractNavCommand.java @@ -0,0 +1,108 @@ +/* uDig - User Friendly Desktop Internet GIS client + * http://udig.refractions.net + * (C) 2004-2012, Refractions Research Inc. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD + * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). + */ +package org.locationtech.udig.project.command.navigation; + +import org.locationtech.udig.project.IMap; +import org.locationtech.udig.project.command.NavCommand; +import org.locationtech.udig.project.command.UndoableCommand; +import org.locationtech.udig.project.internal.Map; +import org.locationtech.udig.project.internal.render.ViewportModel; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.geotools.referencing.CRS; +import org.opengis.referencing.crs.CoordinateReferenceSystem; + +import org.locationtech.jts.geom.Envelope; + +/** + * TODO Purpose of org.locationtech.udig.project.internal.command.navigation + *

    + *

    + * + * @author Jesse + * @since 1.0.0 + */ +public abstract class AbstractNavCommand implements NavCommand, UndoableCommand { + + private Envelope oldbbox = null; + + protected ViewportModel model = null; + + private Map map; + + private CoordinateReferenceSystem oldCRS; + + @Override + public void rollback(IProgressMonitor monitor) throws Exception { + if (model == null) { + // what happens if this gets into the wrong stack. For example if it is part of a + // composite command. + return; + } + + boolean oldDeliver = model.eDeliver(); + try { + model.eSetDeliver(false); + if (!CRS.equalsIgnoreMetadata(model.getCRS(), oldCRS)) { + model.setCRS(oldCRS); + } + } finally { + model.eSetDeliver(oldDeliver); + } + model.zoomToBox(oldbbox); + } + + @Override + public void run(IProgressMonitor monitor) throws Exception { + if (model == null) { + // what happens if this gets into the wrong stack. For example if it is part of a + // composite command. + getMap().sendCommandASync(this); + return; + } + oldbbox = model.getBounds(); + oldCRS = model.getCRS(); + runImpl(monitor); + } + + /** + * This where the actual implementation of subclasses should go. + * + * @throws Exception + */ + protected abstract void runImpl(IProgressMonitor monitor) throws Exception; + + /** + * @see org.locationtech.udig.project.internal.command.navigation.NavCommand#setViewportModel(org.locationtech.udig.project.ViewportModelControl) + */ + @Override + public void setViewportModel(ViewportModel model) { + this.model = model; + } + + /** + * @see org.locationtech.udig.project.command.MapCommand#setMap(IMap) + * @uml.property name="map" + */ + @Override + public void setMap(IMap map) { + this.map = (Map) map; + } + + /** + * @see org.locationtech.udig.project.command.MapCommand#getMap() + * @uml.property name="map" + */ + @Override + public Map getMap() { + return map; + } + +} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/NavComposite.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/NavComposite.java similarity index 98% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/NavComposite.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/NavComposite.java index 73d00698fd..f140a52501 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/NavComposite.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/NavComposite.java @@ -7,7 +7,7 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.command.navigation; +package org.locationtech.udig.project.command.navigation; import java.util.Iterator; import java.util.List; diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/PanCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/PanCommand.java similarity index 80% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/PanCommand.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/PanCommand.java index 86a532e73b..de301cb495 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/PanCommand.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/PanCommand.java @@ -7,9 +7,8 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.command.navigation; +package org.locationtech.udig.project.command.navigation; -import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.command.NavCommand; import org.locationtech.udig.project.internal.Messages; @@ -57,8 +56,9 @@ public PanCommand( double worldx, double worldy ) { } /** - * @see org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand#runImpl() + * @see org.locationtech.udig.project.command.navigation.AbstractNavCommand#runImpl() */ + @Override protected void runImpl( IProgressMonitor monitor ) throws Exception { if (inPixel) model.panUsingScreenCoords(pixelx, pixely); @@ -66,19 +66,10 @@ protected void runImpl( IProgressMonitor monitor ) throws Exception { model.panUsingWorldCoords(worldx, worldy); } - /** - * @see org.locationtech.udig.project.internal.command.MapCommand#copy() - */ - public MapCommand copy() { - if (inPixel) - return new PanCommand(pixelx, pixely); - - return new PanCommand(worldx, worldy); - } - /** * @see org.locationtech.udig.project.command.MapCommand#getName() */ + @Override public String getName() { return Messages.PanCommand_pan; } diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetBoundsCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetBoundsCommand.java new file mode 100644 index 0000000000..f27e5d4b1f --- /dev/null +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetBoundsCommand.java @@ -0,0 +1,24 @@ +package org.locationtech.udig.project.command.navigation; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.locationtech.jts.geom.Envelope; +import org.locationtech.udig.project.internal.Messages; + +public class SetBoundsCommand extends AbstractNavCommand { + + private Envelope newBounds; + + public SetBoundsCommand(Envelope newBounds) { + this.newBounds = newBounds; + } + + @Override + protected void runImpl(IProgressMonitor monitor) throws Exception { + model.setBounds(newBounds); + } + + @Override + public String getName() { + return Messages.SetBoundsCommand_name; + } +} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/SetScaleCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetScaleCommand.java similarity index 84% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/SetScaleCommand.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetScaleCommand.java index b313a8b7ad..6794934762 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/SetScaleCommand.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetScaleCommand.java @@ -7,13 +7,14 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.commands; +package org.locationtech.udig.project.command.navigation; + +import java.text.MessageFormat; +import java.text.NumberFormat; import org.eclipse.core.runtime.IProgressMonitor; -import org.locationtech.udig.project.command.Command; import org.locationtech.udig.project.command.UndoableCommand; import org.locationtech.udig.project.internal.Messages; -import org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand; import org.locationtech.udig.project.internal.render.ViewportModel; /** @@ -47,7 +48,8 @@ public void rollback(IProgressMonitor monitor) throws Exception { @Override public String getName() { - return Messages.SetScaleCommand_name; + NumberFormat numberFormat = NumberFormat.getIntegerInstance(); + return MessageFormat.format(Messages.SetScaleCommand_name, numberFormat.format(newScale)); } @Override @@ -62,11 +64,6 @@ public void run(IProgressMonitor monitor) throws Exception { } } - @Override - public Command copy() { - return new SetScaleCommand(newScale); - } - @Override protected void runImpl(IProgressMonitor monitor) throws Exception { run(monitor); diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportBBoxCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportBBoxCommand.java new file mode 100644 index 0000000000..c8ceeb82b9 --- /dev/null +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportBBoxCommand.java @@ -0,0 +1,119 @@ +/* uDig - User Friendly Desktop Internet GIS client + * http://udig.refractions.net + * (C) 2004-2012, Refractions Research Inc. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD + * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). + */ +package org.locationtech.udig.project.command.navigation; + +import java.text.MessageFormat; + +import org.locationtech.udig.project.internal.Messages; +import org.locationtech.udig.project.internal.ProjectPlugin; +import org.locationtech.udig.project.internal.render.ViewportModel; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.geotools.geometry.jts.JTS; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.geotools.referencing.CRS; +import org.opengis.referencing.crs.CoordinateReferenceSystem; +import org.opengis.referencing.operation.MathTransform; + +import org.locationtech.jts.geom.Envelope; + +/** + * Sets the viewport's bounding box. The bbox have a positive width and height and must have a + * aspect ratio within 0.0000001 units of the value returned by + * {@linkplain ViewportModel#getViewportAspectRatio()}. + * + * @author jeichar + * @since 0.3 + */ +public class SetViewportBBoxCommand extends AbstractNavCommand { + + private Envelope newbbox = null; + + private CoordinateReferenceSystem crs; + + private boolean forceContainBBoxZoom; + + /** + * Creates a new instance of SetViewportBBoxCommand. The bbox is expected to be the same as the + * viewport model. + * + * @param bbox the new bounding box. The new bbox must have a positive width and height and must + * have a aspect ratio within 0.0000001 units of the value returned by + * {@linkplain ViewportModel#getViewportAspectRatio()}. + * @deprecated Please use a ReferencedEnvelope + */ + public SetViewportBBoxCommand(Envelope bbox) { + this.newbbox = bbox; + if (bbox instanceof ReferencedEnvelope) + crs = ((ReferencedEnvelope) bbox).getCoordinateReferenceSystem(); + } + + /** + * Creates a new instance of SetViewportBBoxCommand. The bbox is expected to be the same as the + * viewport model. + * + * @param bbox the new bounding box. The new bbox must have a positive width and height and must + * have a aspect ratio within 0.0000001 units of the value returned by + * {@linkplain ViewportModel#getViewportAspectRatio()}. + */ + public SetViewportBBoxCommand(ReferencedEnvelope bbox) { + this(bbox, false); + } + + /** + * Sets the bounds of the viewport model to the bounds. The crs parameter indications the crs of + * the provided bounds. The appropriate transformation will take place. + * + * @param bounds the bounds to apply to the viewport model + * @param crs The crs of the provided bounds. + */ + public SetViewportBBoxCommand(Envelope bounds, CoordinateReferenceSystem crs) { + this(new ReferencedEnvelope(bounds, crs)); + } + + public SetViewportBBoxCommand(ReferencedEnvelope bbox, boolean forceContainBBoxZoom) { + this.newbbox = bbox; + crs = bbox.getCoordinateReferenceSystem(); + this.forceContainBBoxZoom = forceContainBBoxZoom; + } + + /** + * @see org.locationtech.udig.project.command.navigation.AbstractNavCommand#runImpl() + */ + @Override + protected void runImpl(IProgressMonitor monitor) { + if (crs != null) { + try { + MathTransform mt = CRS.findMathTransform(crs, model.getCRS(), true); + if (!mt.isIdentity()) { + Envelope transformedBounds = JTS.transform(newbbox, null, mt, 5); + crs = model.getCRS(); + newbbox = transformedBounds; + } + } catch (Exception e) { + ProjectPlugin.log("Error transforming from " + crs.getName() + " to " //$NON-NLS-1$//$NON-NLS-2$ + + model.getCRS().getName(), e); + } + } else { + crs = model.getCRS(); + } + model.setBounds(new ReferencedEnvelope(newbbox, crs), forceContainBBoxZoom); + } + + /** + * @see org.locationtech.udig.project.command.MapCommand#getName() + */ + @Override + public String getName() { + return MessageFormat.format(Messages.SetViewportBBoxCommand_setViewArea, + new Object[] { newbbox }); + } + +} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportCenterCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportCenterCommand.java similarity index 64% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportCenterCommand.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportCenterCommand.java index e6bbcab5c0..e0859e6563 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportCenterCommand.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportCenterCommand.java @@ -7,11 +7,10 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.command.navigation; +package org.locationtech.udig.project.command.navigation; import java.text.MessageFormat; -import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.command.NavCommand; import org.locationtech.udig.project.internal.Messages; import org.locationtech.udig.project.internal.ProjectPlugin; @@ -27,60 +26,58 @@ /** * Sets the center of the viewport. The Coordinate must be in world coordinates. The * {@linkplain ViewportModel#pixelToWorld(int, int)}methods can be used to calculate the value. - * + * * @author jeichar - * @since TODO provide version + * @since 1.2.0 */ public class SetViewportCenterCommand extends AbstractNavCommand implements NavCommand { private Coordinate center; + private CoordinateReferenceSystem crs; + /** * Creates a new instance of SetViewportCenterCommand - * + * * @param center Sets the center of the viewport. The Coordinate must be in world coordinates. */ - public SetViewportCenterCommand( Coordinate center ) { + public SetViewportCenterCommand(Coordinate center) { this(center, null); } - public SetViewportCenterCommand( Coordinate coordinate, CoordinateReferenceSystem crs ) { - center=coordinate; - this.crs=crs; + public SetViewportCenterCommand(Coordinate coordinate, CoordinateReferenceSystem crs) { + center = coordinate; + this.crs = crs; } /** - * @see org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand#runImpl() + * @see org.locationtech.udig.project.command.navigation.AbstractNavCommand#runImpl() */ - protected void runImpl( IProgressMonitor monitor ) throws Exception { + @Override + protected void runImpl(IProgressMonitor monitor) throws Exception { Coordinate newCenter = center; - if( crs!=null ) - newCenter=transform(); + if (crs != null) + newCenter = transform(); model.setCenter(newCenter); } private Coordinate transform() { try { - return JTS.transform(center, new Coordinate(), CRS.findMathTransform(crs, model.getCRS(), true)); + return JTS.transform(center, new Coordinate(), + CRS.findMathTransform(crs, model.getCRS(), true)); } catch (Exception e) { ProjectPlugin.log("", e); //$NON-NLS-1$ return null; - } - } - - /** - * @see org.locationtech.udig.project.internal.command.MapCommand#copy() - */ - public MapCommand copy() { - return new SetViewportCenterCommand(center); + } } /** * @see org.locationtech.udig.project.command.MapCommand#getName() */ + @Override public String getName() { - return MessageFormat.format( - Messages.SetViewportCenterCommand_setViewCenter, new Object[]{center}); + return MessageFormat.format(Messages.SetViewportCenterCommand_setViewCenter, + new Object[] { center }); } } diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportHeight.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportHeight.java similarity index 81% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportHeight.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportHeight.java index a04606fdf5..9064e7e036 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportHeight.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportHeight.java @@ -7,14 +7,12 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.command.navigation; +package org.locationtech.udig.project.command.navigation; import java.text.MessageFormat; -import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.command.NavCommand; import org.locationtech.udig.project.internal.Messages; - import org.eclipse.core.runtime.IProgressMonitor; /** @@ -41,22 +39,17 @@ public SetViewportHeight( double height ) { } /** - * @see org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand#runImpl() + * @see org.locationtech.udig.project.command.navigation.AbstractNavCommand#runImpl() */ + @Override protected void runImpl( IProgressMonitor monitor ) throws Exception { model.setHeight(height); } - /** - * @see org.locationtech.udig.project.internal.command.MapCommand#copy() - */ - public MapCommand copy() { - return new SetViewportHeight(height); - } - /** * @see org.locationtech.udig.project.command.MapCommand#getName() */ + @Override public String getName() { return MessageFormat.format( Messages.SetViewportHeight_setViewHeight, new Object[]{height}); diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportWidth.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportWidth.java similarity index 79% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportWidth.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportWidth.java index 3ad8b4a997..b444cf6d92 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportWidth.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportWidth.java @@ -7,14 +7,12 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.command.navigation; +package org.locationtech.udig.project.command.navigation; import java.text.MessageFormat; -import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.command.NavCommand; import org.locationtech.udig.project.internal.Messages; - import org.eclipse.core.runtime.IProgressMonitor; /** @@ -39,22 +37,17 @@ public SetViewportWidth( double width ) { } /** - * @see org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand#runImpl() + * @see org.locationtech.udig.project.command.navigation.AbstractNavCommand#runImpl() */ + @Override protected void runImpl( IProgressMonitor monitor ) throws Exception { model.setWidth(width); } - /** - * @see org.locationtech.udig.project.internal.command.MapCommand#copy() - */ - public MapCommand copy() { - return new SetViewportWidth(width); - } - /** * @see org.locationtech.udig.project.command.MapCommand#getName() */ + @Override public String getName() { return MessageFormat.format( Messages.SetViewportWidth_setViewWidth, new Object[]{width}); diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/ZoomCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/ZoomCommand.java similarity index 81% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/ZoomCommand.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/ZoomCommand.java index a23b9ce3a9..57f468ec22 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/ZoomCommand.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/ZoomCommand.java @@ -7,11 +7,8 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.command.navigation; +package org.locationtech.udig.project.command.navigation; -import java.awt.Rectangle; - -import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.internal.Messages; import org.eclipse.core.runtime.IProgressMonitor; @@ -23,9 +20,9 @@ * Increases or decreases the size of the viewport(in world space) by a constant factor, zoom. The * zoom is equal in both directions. The function used is: bbox.height=bbox.height/divisor * bbox.width=bbox.width/divisor - * + * * @author jeichar - * @since TODO provide version + * @since 1.2.0 */ public class ZoomCommand extends AbstractNavCommand { @@ -35,7 +32,7 @@ public class ZoomCommand extends AbstractNavCommand { /** * Creates a new instance of ZoomCommand - * + * * @param zoomfactor the amount to zoom *
      *
    • A zoom must be greater than 1.
    • @@ -49,7 +46,7 @@ public ZoomCommand( double zoomfactor ) { /** * Creates a {@link ZoomCommand} that zooms to a given {@link Envelope}. - * + * * @param envelope the {@link Envelope} to zoom to. */ public ZoomCommand( Envelope envelope ) { @@ -57,8 +54,8 @@ public ZoomCommand( Envelope envelope ) { } /** - * @param fixedPoint the point that will remain fixed after zoom. - * If set it will be considered together with the + * @param fixedPoint the point that will remain fixed after zoom. + * If set it will be considered together with the * zoomfactor set in the constructor. */ public void setFixedPoint( Coordinate fixedPoint ) { @@ -66,15 +63,9 @@ public void setFixedPoint( Coordinate fixedPoint ) { } /** - * @see org.locationtech.udig.project.internal.command.MapCommand#copy() - */ - public MapCommand copy() { - return new ZoomCommand(zoomfactor); - } - - /** - * @see org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand#runImpl() + * @see org.locationtech.udig.project.command.navigation.AbstractNavCommand#runImpl() */ + @Override protected void runImpl( IProgressMonitor monitor ) { if (envelope!=null) { model.zoomToBox(envelope); @@ -86,8 +77,9 @@ protected void runImpl( IProgressMonitor monitor ) { /** * @see org.locationtech.udig.project.command.MapCommand#getName() */ + @Override public String getName() { - return Messages.ZoomCommand_zoom; + return Messages.ZoomCommand_zoom; } } diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/ZoomExtentCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/ZoomExtentCommand.java similarity index 71% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/ZoomExtentCommand.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/ZoomExtentCommand.java index 78eb437c33..60ccfdc08c 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/ZoomExtentCommand.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/ZoomExtentCommand.java @@ -7,9 +7,8 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.command.navigation; +package org.locationtech.udig.project.command.navigation; -import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.internal.Messages; import org.eclipse.core.runtime.IProgressMonitor; @@ -23,15 +22,9 @@ public class ZoomExtentCommand extends AbstractNavCommand { /** - * @see org.locationtech.udig.project.internal.command.MapCommand#copy() - */ - public MapCommand copy() { - return new ZoomExtentCommand(); - } - - /** - * @see org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand#runImpl() + * @see org.locationtech.udig.project.command.navigation.AbstractNavCommand#runImpl() */ + @Override protected void runImpl( IProgressMonitor monitor ) { model.zoomToExtent(); } @@ -39,6 +32,7 @@ protected void runImpl( IProgressMonitor monitor ) { /** * @see org.locationtech.udig.project.command.MapCommand#getName() */ + @Override public String getName() { return Messages.ZoomExtentCommand_name; } diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/Messages.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/Messages.java index f0c9f962b8..b75977397d 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/Messages.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/Messages.java @@ -14,131 +14,243 @@ import org.eclipse.osgi.util.NLS; public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.locationtech.udig.project.internal.messages"; //$NON-NLS-1$ + private static final String BUNDLE_NAME = "org.locationtech.udig.project.internal.messages"; //$NON-NLS-1$ + + public static String ChangeCRSCommand_undoName; + + public static String ChangeCRSCommand_name; - public static String ChangeCRSCommand_undoName; - public static String ChangeCRSCommand_name; public static String CommandManager_warning2; - public static String DeleteLayersCommand_name; + + public static String DeleteLayersCommand_name; + public static String LayerImpl_resolveAdapter; + public static String LayerImpl_unkownCRS; - public static String PlaceHolder_error; - public static String ProjectPlugin_saving_task_name; - public static String ProjectRegistryImpl_load_error; + + public static String PlaceHolder_error; + + public static String ProjectPlugin_saving_task_name; + + public static String ProjectRegistryImpl_load_error; + public static String SelectLayerCommand_name; + public static String SelectLayerCommand_selecting; + public static String SelectLayerCommand_undoing; - public static String SetScaleCommand_name; - public static String WriteFeatureChangesCommand_rollbackTask; - public static String WriteEditFeatureCommand_rollbackTask; - public static String WriteFeatureChangesCommand_commandName; - public static String WriteEditFeatureCommand_runTask; - public static String WriteFeatureChangesCommand_runTask; - public static String MapImpl_CommandStack; - public static String MapImpl_NavigationCommandStack; - public static String CopyFeaturesCommand_undo; - public static String CopyFeaturesCommand_name; - public static String CommandManager_undo; - public static String CommandManager_redo; - public static String CommandManager_0; - public static String LayerImpl_connectionFailed; - public static String RollbackCommand_name; - public static String CommitCommand_commitCommandName; - public static String CreateLayerCommand_name; - public static String CreateMapCommand_commandname; - public static String CreateMapCommand_defaultname; - public static String CreateLayerCommand_badID2; - public static String CreateLayerCommand_badID; - public static String UDIGTransaction_closeException; - public static String UDIGTransaction_rollbackException; - public static String UDIGTransaction_commitException; - public static String StopRenderCommand_0; - public static String UDIGFeatureStore_1; - public static String UDIGFeatureStore_0; - public static String NullGeoResource_0; - public static String LayerImpl_status; - public static String LayerImpl_unknown; - public static String ProjectImpl_executor; - public static String CommandManager_warning; - public static String CommandManager_toggleMessage; - public static String CommandManager_ProgressMonitor; - public static String CommandManager_warningTitle; - public static String AddFeatureCommand_name; - public static String AddLayersCommand_name; - public static String AddLayerCommand_Name; - public static String CompositeRendererExecutorImpl_0; - public static String SelectCommand_name; - public static String SelectionListener_0; - public static String SelectionListener_SelectionTimer; - public static String ProjectImpl_commandManagerName; - public static String ProjectRegistry_defaultName; - public static String Styling_name; - public static String Styling_default; - public static String Styling_pointStyle; - public static String Styling_blackLine_semitransparentYellowFill; - public static String Styling_blackLine_semitransparentBlueFill; - public static String Styling_blackLine_greenFill; - public static String Styling_blackLine_blueFill; - public static String Styling_blackLine; - public static String Styling_greenLine; - public static String Styling_blueLine; - public static String ResetEditFeatureCommand_0; - public static String RendererImpl_selectionFor; - public static String RenderExecutorImpl_message; - public static String RenderExecutorImpl_title; - public static String NoSelectCommand_cancelSelections; - public static String BBoxSelectionCommand_boxSelection; - public static String FIDSelectCommand_featureSelection; - public static String SetEditFeatureCommand_setCurrentEditFeature; - public static String CreateLayerCommand_illegalRollback2; - public static String CreateLayerCommand_illegalRollback; - public static String CreateFeatureCommand_createFeature; - public static String CreateFeatureCommand_error_message; - public static String CreateFeatureCommand_error_title; - public static String PanCommand_pan; - public static String ZoomCommand_zoom; - public static String SetAttributeCommand_setFeatureAttribute; - public static String SetViewportCenterCommand_setViewCenter; - public static String SetViewportBBoxCommand_setViewArea; - public static String SetViewportHeight_setViewHeight; - public static String SetApplicabilityCommand_name; - public static String SetViewportWidth_setViewWidth; - public static String ZoomExtentCommand_name; - public static String DeleteManyFeaturesCommand_name; - public static String DeleteLayerCommand_deleteLayer; - public static String DeleteFeatureCommand_deleteFeature; - public static String RenderExecutorImpl_1; - public static String RenderExecutorImpl_2; - public static String EditManagerImpl_rollback_message; - public static String EditManagerImpl_commit_message; - public static String ExportProjectWizard_Title; - public static String ExportProjectWizard_Destination2; - public static String ExportProjectWizard_Exporting; - public static String ExportSelectionPage_Destination; - public static String ExportSelectionPage_MissingDir; - public static String ExportSelectionPage_Project; - public static String ExportSelectionPage_SelectProject; - public static String ExportSelectionPage_ExportProject; - public static String SaveProject_Destination; - public static String SaveProject_Export; - public static String SaveProject_Overwrite; - public static String SaveProject_Success; - public static String SaveProject_Fail; - + + public static String SetScaleCommand_name; + + public static String SetBoundsCommand_name; + + public static String WriteFeatureChangesCommand_rollbackTask; + + public static String WriteEditFeatureCommand_rollbackTask; + + public static String WriteFeatureChangesCommand_commandName; + + public static String WriteEditFeatureCommand_runTask; + + public static String WriteFeatureChangesCommand_runTask; + + public static String MapImpl_CommandStack; + + public static String MapImpl_NavigationCommandStack; + + public static String CopyFeaturesCommand_undo; + + public static String CopyFeaturesCommand_name; + + public static String CommandManager_undo; + + public static String CommandManager_redo; + + public static String CommandManager_0; + + public static String LayerImpl_connectionFailed; + + public static String RollbackCommand_name; + + public static String CommitCommand_commitCommandName; + + public static String CreateLayerCommand_name; + + public static String CreateMapCommand_commandname; + + public static String CreateMapCommand_defaultname; + + public static String CreateLayerCommand_badID2; + + public static String CreateLayerCommand_badID; + + public static String UDIGTransaction_closeException; + + public static String UDIGTransaction_rollbackException; + + public static String UDIGTransaction_commitException; + + public static String StopRenderCommand_0; + + public static String UDIGFeatureStore_1; + + public static String UDIGFeatureStore_0; + + public static String NullGeoResource_0; + + public static String LayerImpl_status; + + public static String LayerImpl_unknown; + + public static String ProjectImpl_executor; + + public static String CommandManager_warning; + + public static String CommandManager_toggleMessage; + + public static String CommandManager_ProgressMonitor; + + public static String CommandManager_warningTitle; + + public static String AddFeatureCommand_name; + + public static String AddLayersCommand_name; + + public static String AddLayerCommand_Name; + + public static String CompositeRendererExecutorImpl_0; + + public static String SelectCommand_name; + + public static String SelectionListener_0; + + public static String SelectionListener_SelectionTimer; + + public static String ProjectImpl_commandManagerName; + + public static String ProjectRegistry_defaultName; + + public static String Styling_name; + + public static String Styling_default; + + public static String Styling_pointStyle; + + public static String Styling_blackLine_semitransparentYellowFill; + + public static String Styling_blackLine_semitransparentBlueFill; + + public static String Styling_blackLine_greenFill; + + public static String Styling_blackLine_blueFill; + + public static String Styling_blackLine; + + public static String Styling_greenLine; + + public static String Styling_blueLine; + + public static String ResetEditFeatureCommand_0; + + public static String RendererImpl_selectionFor; + + public static String RenderExecutorImpl_message; + + public static String RenderExecutorImpl_title; + + public static String NoSelectCommand_cancelSelections; + + public static String BBoxSelectionCommand_boxSelection; + + public static String FIDSelectCommand_featureSelection; + + public static String SetEditFeatureCommand_setCurrentEditFeature; + + public static String CreateLayerCommand_illegalRollback2; + + public static String CreateLayerCommand_illegalRollback; + + public static String CreateFeatureCommand_createFeature; + + public static String CreateFeatureCommand_error_message; + + public static String CreateFeatureCommand_error_title; + + public static String PanCommand_pan; + + public static String ZoomCommand_zoom; + + public static String SetAttributeCommand_setFeatureAttribute; + + public static String SetViewportCenterCommand_setViewCenter; + + public static String SetViewportBBoxCommand_setViewArea; + + public static String SetViewportHeight_setViewHeight; + + public static String SetApplicabilityCommand_name; + + public static String SetViewportWidth_setViewWidth; + + public static String ZoomExtentCommand_name; + + public static String DeleteManyFeaturesCommand_name; + + public static String DeleteLayerCommand_deleteLayer; + + public static String DeleteFeatureCommand_deleteFeature; + + public static String RenderExecutorImpl_1; + + public static String RenderExecutorImpl_2; + + public static String EditManagerImpl_rollback_message; + + public static String EditManagerImpl_commit_message; + + public static String ExportProjectWizard_Title; + + public static String ExportProjectWizard_Destination2; + + public static String ExportProjectWizard_Exporting; + + public static String ExportSelectionPage_Destination; + + public static String ExportSelectionPage_MissingDir; + + public static String ExportSelectionPage_Project; + + public static String ExportSelectionPage_SelectProject; + + public static String ExportSelectionPage_ExportProject; + + public static String SaveProject_Destination; + + public static String SaveProject_Export; + + public static String SaveProject_Overwrite; + + public static String SaveProject_Success; + + public static String SaveProject_Fail; + public static String AddLayerItemsCommand_name; + public static String AddLayerItemCommand_Name; + public static String AddFolderItemCommand_Name; public static String DeleteLayerItemCommand_Name; public static String DeleteLayerItemsCommand_Name; + public static String DeleteFolderItemCommand_Name; - - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - } + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } } diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/AbstractNavCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/AbstractNavCommand.java deleted file mode 100644 index f0092518ec..0000000000 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/AbstractNavCommand.java +++ /dev/null @@ -1,106 +0,0 @@ -/* uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2004-2012, Refractions Research Inc. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD - * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). - */ -package org.locationtech.udig.project.internal.command.navigation; - -import org.locationtech.udig.project.IMap; -import org.locationtech.udig.project.command.NavCommand; -import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.render.ViewportModel; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.geotools.referencing.CRS; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import org.locationtech.jts.geom.Envelope; - -/** - * TODO Purpose of org.locationtech.udig.project.internal.command.navigation - *

      - *

      - * - * @author Jesse - * @since 1.0.0 - */ -public abstract class AbstractNavCommand implements NavCommand { - - private Envelope oldbbox = null; - - protected ViewportModel model = null; - - private Map map; - - private CoordinateReferenceSystem oldCRS; - - /** - * @see org.locationtech.udig.project.internal.command.UndoableCommand#rollback() - */ - public void rollback(IProgressMonitor monitor) throws Exception { - if ( model == null ){ - // what happens if this gets into the wrong stack. For example if it is part of a composite command. - return; - } - - boolean oldDeliver = model.eDeliver(); - try { - model.eSetDeliver(false); - if (!CRS.equalsIgnoreMetadata(model.getCRS(), oldCRS)) { - model.setCRS(oldCRS); - } - } finally { - model.eSetDeliver(oldDeliver); - } - model.zoomToBox(oldbbox); - } - - /** - * @see org.locationtech.udig.project.internal.command.MapCommand#run() - */ - public void run(IProgressMonitor monitor) throws Exception { - if ( model == null ){ - // what happens if this gets into the wrong stack. For example if it is part of a composite command. - getMap().sendCommandASync(this); - return; - } - oldbbox = model.getBounds(); - oldCRS = model.getCRS(); - runImpl(monitor); - } - - /** - * This where the actual implementation of subclasses should go. - * - * @throws Exception - */ - protected abstract void runImpl(IProgressMonitor monitor) throws Exception; - - /** - * @see org.locationtech.udig.project.internal.command.navigation.NavCommand#setViewportModel(org.locationtech.udig.project.ViewportModelControl) - */ - public void setViewportModel(ViewportModel model) { - this.model = model; - } - - /** - * @see org.locationtech.udig.project.command.MapCommand#setMap(IMap) - * @uml.property name="map" - */ - public void setMap(IMap map) { - this.map = (Map) map; - } - - /** - * @see org.locationtech.udig.project.command.MapCommand#getMap() - * @uml.property name="map" - */ - public Map getMap() { - return map; - } - -} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportBBoxCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportBBoxCommand.java deleted file mode 100644 index e082089ff3..0000000000 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportBBoxCommand.java +++ /dev/null @@ -1,131 +0,0 @@ -/* uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2004-2012, Refractions Research Inc. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD - * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). - */ -package org.locationtech.udig.project.internal.command.navigation; - -import java.text.MessageFormat; - -import org.locationtech.udig.project.command.MapCommand; -import org.locationtech.udig.project.internal.Messages; -import org.locationtech.udig.project.internal.ProjectPlugin; -import org.locationtech.udig.project.internal.render.ViewportModel; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.geotools.geometry.jts.JTS; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.geotools.referencing.CRS; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; - -import org.locationtech.jts.geom.Envelope; - -/** - * Sets the viewport's bounding box. The bbox have a positive width and height - * and must have a aspect ratio within 0.0000001 units of the value returned by - * {@linkplain ViewportModel#getViewportAspectRatio()}. - * - * @author jeichar - * @since 0.3 - */ -public class SetViewportBBoxCommand extends AbstractNavCommand { - - private Envelope newbbox = null; - - private CoordinateReferenceSystem crs; - - private boolean forceContainBBoxZoom; - - /** - * Creates a new instance of SetViewportBBoxCommand. The bbox is expected to be the same as the viewport model. - * - * @param bbox - * the new bounding box. The new bbox must have a positive width - * and height and must have a aspect ratio within 0.0000001 units - * of the value returned by - * {@linkplain ViewportModel#getViewportAspectRatio()}. - * @deprecated Please use a ReferencedEnvelope - */ - public SetViewportBBoxCommand(Envelope bbox) { - this.newbbox = bbox; - if ( bbox instanceof ReferencedEnvelope ) - crs=((ReferencedEnvelope)bbox).getCoordinateReferenceSystem(); - } - - /** - * Creates a new instance of SetViewportBBoxCommand. The bbox is expected to be the same as the viewport model. - * - * @param bbox - * the new bounding box. The new bbox must have a positive width - * and height and must have a aspect ratio within 0.0000001 units - * of the value returned by - * {@linkplain ViewportModel#getViewportAspectRatio()}. - */ - public SetViewportBBoxCommand(ReferencedEnvelope bbox) { - this(bbox,false); - } - - /** - * Sets the bounds of the viewport model to the bounds. The crs parameter indications the crs of - * the provided bounds. The appropriate transformation will take place. - * - * @param bounds the bounds to apply to the viewport model - * @param crs The crs of the provided bounds. - */ - public SetViewportBBoxCommand(Envelope bounds, CoordinateReferenceSystem crs) { - this(new ReferencedEnvelope(bounds,crs)); - } - - public SetViewportBBoxCommand(ReferencedEnvelope bbox, boolean forceContainBBoxZoom) { - this.newbbox = bbox; - crs=((ReferencedEnvelope)bbox).getCoordinateReferenceSystem(); - this.forceContainBBoxZoom = forceContainBBoxZoom; - } - - /** - * @see org.locationtech.udig.project.internal.command.MapCommand#copy() - */ - public MapCommand copy() { - return new SetViewportBBoxCommand(newbbox, crs); - } - - /** - * @see org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand#runImpl() - */ - protected void runImpl(IProgressMonitor monitor) { - if (crs != null) { - try { - MathTransform mt = CRS.findMathTransform(crs, model.getCRS(), - true); - if (!mt.isIdentity()) { - Envelope transformedBounds = JTS.transform(newbbox, null, - mt, 5); - crs = model.getCRS(); - newbbox = transformedBounds; - } - } catch (Exception e) { - ProjectPlugin - .log( - "Error transforming from " + crs.getName() + " to " + model.getCRS().getName(), e); //$NON-NLS-1$//$NON-NLS-2$ - } - }else{ - crs = model.getCRS(); - } - model.setBounds(new ReferencedEnvelope(newbbox,crs), forceContainBBoxZoom); - } - - /** - * @see org.locationtech.udig.project.command.MapCommand#getName() - */ - public String getName() { - return MessageFormat - .format( - Messages.SetViewportBBoxCommand_setViewArea, new Object[] { newbbox }); - } - -} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/ChangeCRSCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/ChangeCRSCommand.java index 94d487aaf2..c4d4c522d3 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/ChangeCRSCommand.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/ChangeCRSCommand.java @@ -11,55 +11,41 @@ */ package org.locationtech.udig.project.internal.commands; -import org.locationtech.udig.project.command.Command; import org.locationtech.udig.project.command.UndoableMapCommand; -import org.locationtech.udig.project.internal.Map; +import org.locationtech.udig.project.command.navigation.AbstractNavCommand; import org.locationtech.udig.project.internal.Messages; -import org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand; - import org.eclipse.core.runtime.IProgressMonitor; import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * Change the CRS of a map. - * + * * @author Jesse * @since 1.0.0 */ -public class ChangeCRSCommand extends AbstractNavCommand implements - UndoableMapCommand { - private static final String NAME = Messages.ChangeCRSCommand_name; - private CoordinateReferenceSystem crs; - - /** - * @deprecated - */ - public ChangeCRSCommand(Map map, CoordinateReferenceSystem crs) { - this.crs = crs; - } - - public ChangeCRSCommand( CoordinateReferenceSystem crs) { - this.crs = crs; - } - - /** - * Each command has a name that is displayed with the undo/redo buttons. - * - * @see org.locationtech.udig.project.command.MapCommand#getName() - */ - public String getName() { - return NAME; - } - - @Override - protected void runImpl(IProgressMonitor monitor) throws Exception { - monitor.beginTask(NAME, 1); - model.setCRS(crs); - monitor.done(); - } - - public Command copy() { - return new ChangeCRSCommand(null,crs); - } - +public class ChangeCRSCommand extends AbstractNavCommand implements UndoableMapCommand { + private static final String NAME = Messages.ChangeCRSCommand_name; + + private CoordinateReferenceSystem crs; + + public ChangeCRSCommand(CoordinateReferenceSystem crs) { + this.crs = crs; + } + + /** + * Each command has a name that is displayed with the undo/redo buttons. + * + * @see org.locationtech.udig.project.command.MapCommand#getName() + */ + @Override + public String getName() { + return NAME; + } + + @Override + protected void runImpl(IProgressMonitor monitor) throws Exception { + monitor.beginTask(NAME, 1); + model.setCRS(crs); + monitor.done(); + } } diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/messages.properties b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/messages.properties index 001e6fc194..961608af57 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/messages.properties +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/messages.properties @@ -151,7 +151,9 @@ SetAttributeCommand_setFeatureAttribute = Set Feature Attribute: {0} SetEditFeatureCommand_setCurrentEditFeature = Set Current Edit Feature -SetScaleCommand_name = Set Scale Command +SetScaleCommand_name = Set Scale : {0} + +SetBoundsCommand_name = Set Bounds Command SetViewportBBoxCommand_setViewArea = Set View area: {0} diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/CursorPosition.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/CursorPosition.java index f33a7a9b1a..235b23c997 100644 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/CursorPosition.java +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/CursorPosition.java @@ -17,7 +17,7 @@ import java.util.Locale; import org.locationtech.udig.project.command.Command; -import org.locationtech.udig.project.internal.command.navigation.SetViewportCenterCommand; +import org.locationtech.udig.project.command.navigation.SetViewportCenterCommand; import org.locationtech.udig.project.ui.render.displayAdapter.MapMouseEvent; import org.locationtech.udig.project.ui.tool.AbstractTool; import org.locationtech.udig.project.ui.tool.IToolContext; diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/FixedScalePan.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/FixedScalePan.java deleted file mode 100644 index a1c21a3a11..0000000000 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/FixedScalePan.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2008, Refractions Research Inc. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD - * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). - * - */ -package org.locationtech.udig.tools.internal; - -import java.awt.Point; - -import org.locationtech.udig.project.IMap; -import org.locationtech.udig.project.command.Command; -import org.locationtech.udig.project.command.NavCommand; -import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand; -import org.locationtech.udig.project.internal.render.ViewportModel; -import org.locationtech.udig.project.ui.internal.commands.draw.TranslateCommand; -import org.locationtech.udig.project.ui.render.displayAdapter.MapMouseEvent; -import org.locationtech.udig.project.ui.render.displayAdapter.ViewportPane; -import org.locationtech.udig.project.ui.tool.AbstractModalTool; -import org.locationtech.udig.project.ui.tool.ModalTool; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.geotools.geometry.jts.ReferencedEnvelope; - -import org.locationtech.jts.geom.Coordinate; -import org.locationtech.jts.geom.Envelope; - - -/** - * This tool is supposed to be a fixed scale zoom tool; although - * it currently doesn't do that properly. - * - * @author Emily Gouge - * @since 1.2.0 - * @deprecated PanTool with Tool Options now covers this case - */ -public class FixedScalePan extends AbstractModalTool implements ModalTool { - private boolean dragging=false; - private Point start=null; - private ReferencedEnvelope startbounds = null; - - TranslateCommand command; - /** - * Creates an new instance of Pan - */ - public FixedScalePan() { - super(MOUSE | MOTION); - } - - /** - * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseDragged(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) - */ - public void mouseDragged(MapMouseEvent e) { - if (dragging) { - command.setTranslation(e.x- start.x, e.y - start.y); - context.getViewportPane().repaint(); - } - } - - /** - * @see org.locationtech.udig.project.ui.tool.AbstractTool#mousePressed(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) - */ - public void mousePressed(MapMouseEvent e) { - - if (validModifierButtonCombo(e)) { - ((ViewportPane)context.getMapDisplay()).enableDrawCommands(false); - dragging = true; - start = e.getPoint(); - startbounds = new ReferencedEnvelope(context.getViewportModel().getBounds()); - command=context.getDrawFactory().createTranslateCommand(0,0); - context.sendASyncCommand(command); - } - } - - /** - * Returns true if the combination of buttons and modifiers are legal to execute the pan. - *

      - * This version returns true if button 1 is down and no modifiers - *

      - * @param e - * @return - */ - protected boolean validModifierButtonCombo(MapMouseEvent e) { - return e.buttons== MapMouseEvent.BUTTON1 - && !(e.modifiersDown()); - } - - /** - * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseReleased(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) - */ - public void mouseReleased(MapMouseEvent e) { - if (dragging) { - - ((ViewportPane)context.getMapDisplay()).enableDrawCommands(true); - - //update translation - command.setTranslation(e.x- start.x, e.y - start.y); - context.getViewportPane().repaint(); - - //compute new offset - Point end=e.getPoint(); - - int deltax = (end.x - start.x); - double deltaxworld = ( getContext().getViewportModel().getWidth() / getContext().getMapDisplay().getWidth() ) * deltax; - - int deltay = end.y - start.y; - double deltayworld = ( getContext().getViewportModel().getHeight() / getContext().getMapDisplay().getHeight() ) * deltay; - - Coordinate center = startbounds.centre(); - final Coordinate newc = new Coordinate(center.x - deltaxworld, center.y + deltayworld); - - double dw = getContext().getViewportModel().getBounds().getWidth() / 2; - double dh = getContext().getViewportModel().getBounds().getHeight() / 2; - - final Envelope newbounds = new Envelope(newc.x - dw, newc.x + dw, newc.y - dh, newc.y + dh); - -// double currentscale = context.getViewportModel().getBounds().getWidth() / context.getMapDisplay().getWidth(); -// double newscale = newbounds.getWidth() / context.getMapDisplay().getWidth(); - -// if (currentscale != newscale){ -// System.out.println("scale changed; should reload." ); -// System.out.println("current scale:" + currentscale); -// System.out.println("aaaanew scale:" + newscale); -// } - - //compute new bbox for - NavCommand setFinal = new AbstractNavCommand(){ - - @Override - protected void runImpl( IProgressMonitor monitor ) throws Exception { - model.setBounds(newbounds); - } - - - public Command copy() { - return null; - } - - - public String getName() { - return "Fixed Scale Pan"; //$NON-NLS-1$ - } - }; - - ((ViewportPane) getContext().getMapDisplay()).update(); - context.sendASyncCommand(new PanAndInvalidate(setFinal, command)); - - dragging = false; -// System.out.println("pan done."); - } - } - /** - * @see org.locationtech.udig.project.ui.tool.Tool#dispose() - */ - public void dispose() { - super.dispose(); - } - - /** - * Executes the specified pan command, and only after it is executed, expires the last translate command - */ - private class PanAndInvalidate implements Command, NavCommand { - - private NavCommand command; - private TranslateCommand expire; - - PanAndInvalidate(NavCommand command, TranslateCommand expire) { - this.command = command; - this.expire = expire; - } - - public Command copy() { - return new PanAndInvalidate(command, expire); - } - - public String getName() { - return "PanAndDiscard"; //$NON-NLS-1$ - } - - public void run( IProgressMonitor monitor ) throws Exception { - //first we need to expire the current translation - expire.setValid(false); - - //then we can draw - command.run(monitor); - } - - public void setViewportModel( ViewportModel model ) { - command.setViewportModel(model); - } - - public Map getMap() { - return command.getMap(); - } - - public void setMap( IMap map ) { - command.setMap(map); - } - - public void rollback( IProgressMonitor monitor ) throws Exception { - command.rollback(monitor); - } - - } -} diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/InvalidateCommand.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/InvalidateCommand.java deleted file mode 100644 index 731faf0825..0000000000 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/InvalidateCommand.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2012, Refractions Research Inc. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD - * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). - */ -package org.locationtech.udig.tools.internal; - -import java.awt.Rectangle; - -import org.locationtech.udig.project.command.MapCommand; -import org.locationtech.udig.project.ui.commands.AbstractDrawCommand; -import org.locationtech.udig.project.ui.commands.IDrawCommand; -import org.locationtech.udig.project.ui.commands.TransformDrawCommand; - -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * @author jesse - */ -public class InvalidateCommand extends AbstractDrawCommand implements MapCommand, IDrawCommand { - - private TransformDrawCommand m_toInvalidate; - - public InvalidateCommand(TransformDrawCommand command) { - m_toInvalidate = command; - } - - public void run(IProgressMonitor monitor) throws Exception { - m_toInvalidate.setValid(false); - } - - public Rectangle getValidArea() { - return null; - } - -} diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/NavigationUpdateThread.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/NavigationUpdateThread.java index b476f32112..637767a838 100644 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/NavigationUpdateThread.java +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/NavigationUpdateThread.java @@ -13,9 +13,9 @@ import java.util.ArrayList; import org.locationtech.udig.project.command.NavCommand; -import org.locationtech.udig.project.internal.command.navigation.NavComposite; -import org.locationtech.udig.project.internal.command.navigation.PanCommand; -import org.locationtech.udig.project.internal.command.navigation.ZoomCommand; +import org.locationtech.udig.project.command.navigation.NavComposite; +import org.locationtech.udig.project.command.navigation.PanCommand; +import org.locationtech.udig.project.command.navigation.ZoomCommand; import org.locationtech.udig.project.ui.commands.TransformDrawCommand; import org.locationtech.udig.project.ui.tool.IToolContext; diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Pan.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Pan.java index e392ad8445..9549e897e3 100644 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Pan.java +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Pan.java @@ -13,19 +13,14 @@ import java.awt.Point; -import org.locationtech.udig.project.IMap; -import org.locationtech.udig.project.command.Command; import org.locationtech.udig.project.command.NavCommand; -import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.command.navigation.PanCommand; -import org.locationtech.udig.project.internal.render.ViewportModel; +import org.locationtech.udig.project.command.navigation.PanCommand; import org.locationtech.udig.project.ui.internal.commands.draw.TranslateCommand; import org.locationtech.udig.project.ui.render.displayAdapter.MapMouseEvent; import org.locationtech.udig.project.ui.render.displayAdapter.ViewportPane; import org.locationtech.udig.project.ui.tool.AbstractModalTool; import org.locationtech.udig.project.ui.tool.ModalTool; - -import org.eclipse.core.runtime.IProgressMonitor; +import org.locationtech.udig.tools.internal.commands.PanAndInvalidate; /** @@ -50,6 +45,7 @@ public Pan() { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseDragged(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseDragged(MapMouseEvent e) { if (dragging) { command.setTranslation(e.x- start.x, e.y - start.y); @@ -60,6 +56,7 @@ public void mouseDragged(MapMouseEvent e) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mousePressed(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mousePressed(MapMouseEvent e) { if (validModifierButtonCombo(e)) { @@ -87,6 +84,7 @@ protected boolean validModifierButtonCombo(MapMouseEvent e) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseReleased(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseReleased(MapMouseEvent e) { if (dragging) { ((ViewportPane)context.getMapDisplay()).enableDrawCommands(true); @@ -106,56 +104,8 @@ public void mouseReleased(MapMouseEvent e) { /** * @see org.locationtech.udig.project.ui.tool.Tool#dispose() */ + @Override public void dispose() { super.dispose(); } - - /** - * Executes the specified pan command, and only after it is executed, expires the last translate command - */ - private class PanAndInvalidate implements Command, NavCommand { - - private NavCommand command; - private TranslateCommand expire; - - PanAndInvalidate(NavCommand command, TranslateCommand expire) { - this.command = command; - this.expire = expire; - } - - public Command copy() { - return new PanAndInvalidate(command, expire); - } - - public String getName() { - return "PanAndDiscard"; - } - - public void run( IProgressMonitor monitor ) throws Exception { - //we need to expire the translate command first otherwise - //the image gets drawn in the wrong spot the first time - // and we see weird affects - expire.setValid(false); - - command.run(monitor); - - } - - public void setViewportModel( ViewportModel model ) { - command.setViewportModel(model); - } - - public Map getMap() { - return command.getMap(); - } - - public void setMap( IMap map ) { - command.setMap(map); - } - - public void rollback( IProgressMonitor monitor ) throws Exception { - command.rollback(monitor); - } - - } } diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/PanTool.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/PanTool.java index aabf83b334..a640bb8d73 100644 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/PanTool.java +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/PanTool.java @@ -13,12 +13,9 @@ import java.awt.Point; -import org.locationtech.udig.project.IMap; -import org.locationtech.udig.project.command.Command; import org.locationtech.udig.project.command.NavCommand; -import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand; -import org.locationtech.udig.project.internal.command.navigation.PanCommand; +import org.locationtech.udig.project.command.navigation.PanCommand; +import org.locationtech.udig.project.command.navigation.SetBoundsCommand; import org.locationtech.udig.project.internal.render.ViewportModel; import org.locationtech.udig.project.internal.render.impl.ViewportModelImpl; import org.locationtech.udig.project.ui.internal.commands.draw.TranslateCommand; @@ -27,8 +24,7 @@ import org.locationtech.udig.project.ui.tool.AbstractModalTool; import org.locationtech.udig.project.ui.tool.ModalTool; import org.locationtech.udig.project.ui.tool.options.ToolOptionContributionItem; - -import org.eclipse.core.runtime.IProgressMonitor; +import org.locationtech.udig.tools.internal.commands.PanAndInvalidate; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; @@ -47,24 +43,25 @@ * preferences. *

      * There are three strateies avaialble {@link Pan}, {@link Scroll}, {@link FixedScale}. - * + * * @author Jesse Eichar * @version $Revision: 1.9 $ */ public class PanTool extends AbstractModalTool implements ModalTool { public static class OptionContribtionItem extends ToolOptionContributionItem { + @Override public IPreferenceStore fillFields( Composite parent ) { Button check = new Button(parent, SWT.CHECK ); check.setText("Scale"); addField( NavigationToolPreferencePage.SCALE, check ); - + Button tiled = new Button(parent, SWT.CHECK ); tiled.setText("Tiled"); addField( NavigationToolPreferencePage.TILED, tiled ); - + return ToolsPlugin.getDefault().getPreferenceStore(); } - }; + } /** * Delegate used to control how the PanTool functions; configured using Preference. * @author Jody Garnett (LISAsoft) @@ -79,9 +76,10 @@ public void mouseReleased( MapMouseEvent e ) { } public void dispose() { } - }; + } private ScrollStrategy strategy; IPropertyChangeListener prefListener = new IPropertyChangeListener(){ + @Override public void propertyChange( PropertyChangeEvent event ) { String property = event.getProperty(); if( NavigationToolPreferencePage.SCALE.equals( property ) || @@ -112,14 +110,14 @@ else if (tiled){ else { strategy = new Pan(); } - + } /** * Used to recognise a mouse event and pan accodingly. *

      * This functionality is overridden by PanMiddleMouse in order to allow the middle mouse button * to provide the Pan functionality for any ModalTool. - * + * * @param e */ protected boolean validModifierButtonCombo( MapMouseEvent e ) { @@ -128,6 +126,7 @@ protected boolean validModifierButtonCombo( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseDragged(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseDragged( MapMouseEvent e ) { strategy.mouseDragged(e); } @@ -135,6 +134,7 @@ public void mouseDragged( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mousePressed(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mousePressed( MapMouseEvent e ) { strategy.mousePressed(e); } @@ -142,12 +142,14 @@ public void mousePressed( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseReleased(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseReleased( MapMouseEvent e ) { strategy.mouseReleased(e); } /** * @see org.locationtech.udig.project.ui.tool.Tool#dispose() */ + @Override public void dispose() { if (strategy != null) { strategy.dispose(); @@ -156,57 +158,12 @@ public void dispose() { super.dispose(); } - /** - * Executes the specified pan command, and only after it is executed, expires the last translate - * command - */ - private class PanAndInvalidate implements Command, NavCommand { - private NavCommand command; - private TranslateCommand expire; - PanAndInvalidate( NavCommand command, TranslateCommand expire ) { - this.command = command; - this.expire = expire; - } - - public Command copy() { - return new PanAndInvalidate(command, expire); - } - - public String getName() { - return "PanAndDiscard"; - } - - public void run( IProgressMonitor monitor ) throws Exception { - // we need to expire the translate command first otherwise - // the image gets drawn in the wrong spot the first time - // and we see weird affects - expire.setValid(false); - - command.run(monitor); - } - - public void setViewportModel( ViewportModel model ) { - command.setViewportModel(model); - } - - public Map getMap() { - return command.getMap(); - } - - public void setMap( IMap map ) { - command.setMap(map); - } - - public void rollback( IProgressMonitor monitor ) throws Exception { - command.rollback(monitor); - } - } - /** Basic Pan Functionality for MapViewport */ public class Pan extends ScrollStrategy { private boolean dragging = false; private Point start = null; private TranslateCommand command; + @Override public void mouseDragged( MapMouseEvent e ) { if (dragging) { command.setTranslation(e.x - start.x, e.y - start.y); @@ -217,6 +174,7 @@ public void mouseDragged( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mousePressed(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mousePressed( MapMouseEvent e ) { if (validModifierButtonCombo(e)) { ((ViewportPane) context.getMapDisplay()).enableDrawCommands(false); @@ -230,6 +188,7 @@ public void mousePressed( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseReleased(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseReleased( MapMouseEvent e ) { if (dragging) { ((ViewportPane) context.getMapDisplay()).enableDrawCommands(true); @@ -270,6 +229,7 @@ class Scroll extends ScrollStrategy { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseDragged(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseDragged( MapMouseEvent e ) { if (dragging) { org.eclipse.swt.graphics.Point p = Display.getCurrent().map( @@ -297,6 +257,7 @@ public void mouseDragged( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mousePressed(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mousePressed( MapMouseEvent e ) { if (validModifierButtonCombo(e)) { ((ViewportPane) context.getMapDisplay()).enableDrawCommands(false); @@ -306,6 +267,7 @@ public void mousePressed( MapMouseEvent e ) { .map((Canvas) context.getViewportPane(), null, e.x, e.y); } } + @Override public void mouseReleased( MapMouseEvent e ) { if (dragging) { @@ -337,6 +299,7 @@ public void mouseReleased( MapMouseEvent e ) { ((ViewportModelImpl) context.getViewportModel()).setBounds(newbounds); } } + @Override public void dispose() { super.dispose(); } @@ -351,7 +314,7 @@ public void dispose() { * change resolution as the MapViewport tries to maintain the current scale (as you move north * and south). Emily reports that the strategy does not actually do this properly. *

      - * + * * @author Emily Gouge * @since 1.2.0 */ @@ -365,6 +328,7 @@ class FixedScale extends ScrollStrategy { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseDragged(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseDragged( MapMouseEvent e ) { if (dragging) { command.setTranslation(e.x - start.x, e.y - start.y); @@ -375,6 +339,7 @@ public void mouseDragged( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mousePressed(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mousePressed( MapMouseEvent e ) { if (validModifierButtonCombo(e)) { @@ -389,6 +354,7 @@ public void mousePressed( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseReleased(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseReleased( MapMouseEvent e ) { if (dragging) { @@ -430,24 +396,9 @@ public void mouseReleased( MapMouseEvent e ) { // } // compute new bbox for - NavCommand setFinal = new AbstractNavCommand(){ - - @Override - protected void runImpl( IProgressMonitor monitor ) throws Exception { - model.setBounds(newbounds); - } - - public Command copy() { - return null; - } - - public String getName() { - return "Fixed Scale Pan"; //$NON-NLS-1$ - } - }; - ((ViewportPane) getContext().getMapDisplay()).update(); - context.sendASyncCommand(new PanAndInvalidate(setFinal, command)); + context.sendASyncCommand( + new PanAndInvalidate(new SetBoundsCommand(newbounds), command)); dragging = false; // System.out.println("pan done."); @@ -456,6 +407,7 @@ public String getName() { /** * @see org.locationtech.udig.project.ui.tool.Tool#dispose() */ + @Override public void dispose() { super.dispose(); } diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Zoom.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Zoom.java index 51beb7e8b3..45ea827480 100644 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Zoom.java +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Zoom.java @@ -14,7 +14,7 @@ import java.awt.Point; import java.awt.Rectangle; -import org.locationtech.udig.project.internal.command.navigation.ZoomCommand; +import org.locationtech.udig.project.command.navigation.ZoomCommand; import org.locationtech.udig.project.render.IViewportModel; import org.locationtech.udig.project.ui.commands.DrawCommandFactory; import org.locationtech.udig.project.ui.commands.SelectionBoxCommand; diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/ZoomExtent.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/ZoomExtent.java index b4d3c1659a..2416d5ba05 100644 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/ZoomExtent.java +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/ZoomExtent.java @@ -11,7 +11,7 @@ */ package org.locationtech.udig.tools.internal; -import org.locationtech.udig.project.internal.command.navigation.ZoomExtentCommand; +import org.locationtech.udig.project.command.navigation.ZoomExtentCommand; import org.locationtech.udig.project.ui.tool.AbstractActionTool; import org.locationtech.udig.project.ui.tool.AbstractTool; diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/commands/PanAndInvalidate.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/commands/PanAndInvalidate.java new file mode 100644 index 0000000000..88a5a052a1 --- /dev/null +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/commands/PanAndInvalidate.java @@ -0,0 +1,53 @@ +package org.locationtech.udig.tools.internal.commands; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.locationtech.udig.project.IMap; +import org.locationtech.udig.project.command.Command; +import org.locationtech.udig.project.command.NavCommand; +import org.locationtech.udig.project.internal.Map; +import org.locationtech.udig.project.internal.render.ViewportModel; +import org.locationtech.udig.project.ui.internal.commands.draw.TranslateCommand; + +/** + * Executes the specified pan command, and only after it is executed, expires the last translate command + */ +public class PanAndInvalidate implements Command, NavCommand { + + private NavCommand command; + private TranslateCommand expire; + + public PanAndInvalidate(NavCommand command, TranslateCommand expire) { + this.command = command; + this.expire = expire; + } + + @Override + public String getName() { + return "PanAndDiscard"; //$NON-NLS-1$ + } + + @Override + public void run( IProgressMonitor monitor ) throws Exception { + //first we need to expire the current translation + expire.setValid(false); + + //then we can draw + command.run(monitor); + } + + @Override + public void setViewportModel( ViewportModel model ) { + command.setViewportModel(model); + } + + @Override + public Map getMap() { + return command.getMap(); + } + + @Override + public void setMap(IMap map) { + command.setMap(map); + } + +} \ No newline at end of file diff --git a/plugins/org.locationtech.udig.tool.edit/src/org/locationtech/udig/tools/edit/enablement/ValidToolDetectionActivator.java b/plugins/org.locationtech.udig.tool.edit/src/org/locationtech/udig/tools/edit/enablement/ValidToolDetectionActivator.java index ea600027b6..7852f9a24d 100644 --- a/plugins/org.locationtech.udig.tool.edit/src/org/locationtech/udig/tools/edit/enablement/ValidToolDetectionActivator.java +++ b/plugins/org.locationtech.udig.tool.edit/src/org/locationtech/udig/tools/edit/enablement/ValidToolDetectionActivator.java @@ -14,6 +14,7 @@ import org.locationtech.udig.project.Interaction; import org.locationtech.udig.project.command.UndoableMapCommand; import org.locationtech.udig.project.internal.EditManager; +import org.locationtech.udig.project.internal.commands.SetApplicabilityCommand; import org.locationtech.udig.project.ui.render.displayAdapter.MapMouseEvent; import org.locationtech.udig.tool.edit.internal.Messages; import org.locationtech.udig.tools.edit.EditPlugin; @@ -85,8 +86,7 @@ public void run() { Messages.ValidToolDetectionActivator_questionTitle, string); if (decision) { - UndoableMapCommand command = handler.getContext().getBasicCommandFactory() - .createSetApplicabilityCommand(layer, Interaction.EDIT, true); + UndoableMapCommand command = new SetApplicabilityCommand(layer, Interaction.EDIT, true); handler.getContext().sendASyncCommand(command); } else { warning[0]=Messages.ValidToolDetectionActivator_warning2; diff --git a/plugins/org.locationtech.udig.tool.select/src/org/locationtech/udig/tool/select/internal/ZoomSelection.java b/plugins/org.locationtech.udig.tool.select/src/org/locationtech/udig/tool/select/internal/ZoomSelection.java index 977d6d5b2b..eb98c7a1c5 100644 --- a/plugins/org.locationtech.udig.tool.select/src/org/locationtech/udig/tool/select/internal/ZoomSelection.java +++ b/plugins/org.locationtech.udig.tool.select/src/org/locationtech/udig/tool/select/internal/ZoomSelection.java @@ -12,7 +12,7 @@ import java.io.IOException; import org.locationtech.udig.project.ILayer; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.render.impl.ScaleUtils; import org.locationtech.udig.project.ui.tool.AbstractActionTool; import org.locationtech.udig.tool.select.SelectPlugin; diff --git a/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/featuremovieview/FeatureMovieView.java b/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/featuremovieview/FeatureMovieView.java index c283f546ff..91bcb1092b 100644 --- a/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/featuremovieview/FeatureMovieView.java +++ b/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/featuremovieview/FeatureMovieView.java @@ -17,7 +17,7 @@ import org.locationtech.udig.project.IMap; import org.locationtech.udig.project.command.UndoableMapCommand; import org.locationtech.udig.project.command.factory.SelectionCommandFactory; -import org.locationtech.udig.project.internal.command.navigation.ZoomCommand; +import org.locationtech.udig.project.command.navigation.ZoomCommand; import org.locationtech.udig.project.internal.commands.selection.SelectCommand; import org.locationtech.udig.project.ui.ApplicationGIS; diff --git a/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/navigationview/NavigationView.java b/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/navigationview/NavigationView.java index 80bc379713..8b47e3cdfb 100644 --- a/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/navigationview/NavigationView.java +++ b/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/navigationview/NavigationView.java @@ -1,6 +1,6 @@ /* * uDig - User Friendly Desktop Internet GIS client - * (C) HydroloGIS - www.hydrologis.com + * (C) HydroloGIS - www.hydrologis.com * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -81,7 +81,7 @@ import org.locationtech.udig.project.IMapListener; import org.locationtech.udig.project.MapCompositionEvent; import org.locationtech.udig.project.MapEvent; -import org.locationtech.udig.project.command.factory.NavigationCommandFactory; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.render.ViewportModel; import org.locationtech.udig.project.ui.ApplicationGIS; import org.locationtech.udig.tools.jgrass.JGrassToolsPlugin; @@ -96,7 +96,7 @@ /** * A navigation view. - * + * * @author Andrea Antonello (www.hydrologis.com) * */ @@ -143,6 +143,7 @@ public NavigationView() { } + @Override public void createPartControl( Composite theparent ) { ScrolledComposite scrolledComposite = new ScrolledComposite(theparent, SWT.H_SCROLL | SWT.V_SCROLL); @@ -235,10 +236,11 @@ public void createPartControl( Composite theparent ) { canvas.setLayoutData(gd2); canvas.addPaintListener(new PaintListener(){ + @Override public void paintControl( PaintEvent e ) { Rectangle canvasBounds = canvas.getBounds(); Rectangle imageBounds = worldImage.getBounds(); - int h = (int) ((float) canvasBounds.width * (float) imageBounds.height / (float) imageBounds.width); + int h = (int) ((float) canvasBounds.width * (float) imageBounds.height / imageBounds.width); e.gc.drawImage(worldImage, 0, 0, imageBounds.width, imageBounds.height, 0, 0, canvasBounds.width, h); IMap activeMap = ApplicationGIS.getActiveMap(); @@ -292,12 +294,12 @@ public void paintControl( PaintEvent e ) { height = 1; } - int x = (int) ((double) canvasBounds.width * west / 360.0); - int y = (int) ((double) h * north / 180.0); - int fw = (int) ((double) canvasBounds.width * width / 360.0); + int x = (int) (canvasBounds.width * west / 360.0); + int y = (int) (h * north / 180.0); + int fw = (int) (canvasBounds.width * width / 360.0); if (fw <= 1) fw = 2; - int fh = (int) ((double) h * height / 180.0); + int fh = (int) (h * height / 180.0); if (fh <= 1) fh = 2; int newy = h - y; @@ -346,12 +348,14 @@ public void paintControl( PaintEvent e ) { countriesCombo.setItems(namesArray); countriesCombo.select(0); countriesCombo.addSelectionListener(new SelectionAdapter(){ + @Override public void widgetSelected( SelectionEvent e ) { int selectionIndex = countriesCombo.getSelectionIndex(); String item = countriesCombo.getItem(selectionIndex); final String file = folderFile.getAbsolutePath() + File.separator + item + ".txt"; IRunnableWithProgress operation = new IRunnableWithProgress(){ + @Override public void run( IProgressMonitor pm ) throws InvocationTargetException, InterruptedException { try { populatePlacesMap(placesMap, file); @@ -371,6 +375,7 @@ public void run( IProgressMonitor pm ) throws InvocationTargetException, Interru addNewButton.setText("+"); addNewButton.setToolTipText("Add a new geonames file (get it at http://download.geonames.org/export/dump/)"); addNewButton.addSelectionListener(new SelectionAdapter(){ + @Override public void widgetSelected( SelectionEvent e ) { FileDialog fileDialog = new FileDialog(countriesCombo.getShell(), SWT.OPEN); fileDialog.setFilterExtensions(new String[]{"*.txt"}); @@ -403,6 +408,7 @@ public void widgetSelected( SelectionEvent e ) { removeButton.setText("-"); removeButton.setToolTipText("Remove a geonames file"); removeButton.addSelectionListener(new SelectionAdapter(){ + @Override public void widgetSelected( SelectionEvent e ) { int selectionIndex = countriesCombo.getSelectionIndex(); String item = countriesCombo.getItem(selectionIndex); @@ -446,6 +452,7 @@ public void widgetSelected( SelectionEvent e ) { searchButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); searchButton.setText("search"); searchButton.addSelectionListener(new SelectionAdapter(){ + @Override public void widgetSelected( SelectionEvent e ) { String text = placesText.getText(); if (text.length() < 3) { @@ -461,7 +468,7 @@ public void widgetSelected( SelectionEvent e ) { matchedList.add(name); } } - String[] matchedArray = (String[]) matchedList.toArray(new String[matchedList.size()]); + String[] matchedArray = matchedList.toArray(new String[matchedList.size()]); Arrays.sort(matchedArray); placesCombo.setItems(matchedArray); placesCombo.select(0); @@ -476,6 +483,7 @@ public void widgetSelected( SelectionEvent e ) { goButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); goButton.setText("go"); goButton.addSelectionListener(new SelectionAdapter(){ + @Override public void widgetSelected( SelectionEvent e ) { IMap map = ApplicationGIS.getActiveMap(); if (map.getMapLayers().size() < 1) { @@ -506,7 +514,7 @@ public void widgetSelected( SelectionEvent e ) { } catch (Exception e1) { e1.printStackTrace(); } - map.sendCommandASync(NavigationCommandFactory.getInstance().createSetViewportBBoxCommand(bounds)); + map.sendCommandASync(new SetViewportBBoxCommand(bounds)); } }); @@ -516,10 +524,12 @@ public void widgetSelected( SelectionEvent e ) { loadShapeButton.setLayoutData(gridData); loadShapeButton.setText("Load all places as feature layer"); loadShapeButton.addSelectionListener(new SelectionAdapter(){ + @Override public void widgetSelected( SelectionEvent e ) { IRunnableWithProgress operation = new IRunnableWithProgress(){ + @Override public void run( IProgressMonitor pm ) throws InvocationTargetException, InterruptedException { try { @@ -595,12 +605,13 @@ private String[] loadGeonamesFiles() { } names.add(name.replaceFirst(".txt", "")); } - String[] namesArray = (String[]) names.toArray(new String[names.size()]); + String[] namesArray = names.toArray(new String[names.size()]); return namesArray; } private void updateData() { Display.getDefault().asyncExec(new Runnable(){ + @Override public void run() { IMap activeMap = ApplicationGIS.getActiveMap(); ViewportModel viewportModel = (ViewportModel) activeMap.getViewportModel(); @@ -623,7 +634,7 @@ public void run() { canvas.redraw(); SortedSet preferredScaleDenominators = viewportModel.getPreferredScaleDenominators(); - Double[] scalesArray = (Double[]) preferredScaleDenominators.toArray(new Double[preferredScaleDenominators.size()]); + Double[] scalesArray = preferredScaleDenominators.toArray(new Double[preferredScaleDenominators.size()]); String[] scales = new String[scalesArray.length]; for( int i = 0; i < scales.length; i++ ) { scales[i] = "1:" + String.valueOf(scalesArray[i]); @@ -680,6 +691,7 @@ public void run() { }); } + @Override public void widgetSelected( SelectionEvent e ) { ViewportModel viewportModel = (ViewportModel) ApplicationGIS.getActiveMap().getViewportModel(); @@ -776,18 +788,22 @@ public void widgetSelected( SelectionEvent e ) { updateData(); } + @Override public void changed( MapEvent event ) { updateData(); } + @Override public void changed( MapCompositionEvent event ) { updateData(); } + @Override public void setFocus() { updateData(); } + @Override public void widgetDefaultSelected( SelectionEvent e ) { } diff --git a/plugins/org.locationtech.udig.tools/src/org/locationtech/udig/tools/merge/internal/view/MergeFeaturesCommand.java b/plugins/org.locationtech.udig.tools/src/org/locationtech/udig/tools/merge/internal/view/MergeFeaturesCommand.java index 70a605e5cd..ba252d75f0 100644 --- a/plugins/org.locationtech.udig.tools/src/org/locationtech/udig/tools/merge/internal/view/MergeFeaturesCommand.java +++ b/plugins/org.locationtech.udig.tools/src/org/locationtech/udig/tools/merge/internal/view/MergeFeaturesCommand.java @@ -102,10 +102,6 @@ public void rollback(IProgressMonitor monitor) throws Exception { this.compositeCmd.rollback(monitor); } - public MapCommand copy() { - return this.compositeCmd.copy(); - } - public String getName() { return "Merge Features Command"; //$NON-NLS-1$ } diff --git a/plugins/org.locationtech.udig.tutorials.preferredzoomlevels/src/org/locationtech/udig/tutorials/preferredzoomlevels/ZoomToFeatures.java b/plugins/org.locationtech.udig.tutorials.preferredzoomlevels/src/org/locationtech/udig/tutorials/preferredzoomlevels/ZoomToFeatures.java index 0c8ba22b6e..6cdb436712 100644 --- a/plugins/org.locationtech.udig.tutorials.preferredzoomlevels/src/org/locationtech/udig/tutorials/preferredzoomlevels/ZoomToFeatures.java +++ b/plugins/org.locationtech.udig.tutorials.preferredzoomlevels/src/org/locationtech/udig/tutorials/preferredzoomlevels/ZoomToFeatures.java @@ -12,7 +12,7 @@ import java.io.IOException; import org.locationtech.udig.project.ILayer; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.ui.tool.AbstractActionTool; import org.locationtech.udig.ui.ProgressManager; diff --git a/plugins/org.locationtech.udig.tutorials.rcp/src/org/locationtech/udig/tutorials/rcp/MapView.java b/plugins/org.locationtech.udig.tutorials.rcp/src/org/locationtech/udig/tutorials/rcp/MapView.java index 53d978a06e..132a0ed7ef 100644 --- a/plugins/org.locationtech.udig.tutorials.rcp/src/org/locationtech/udig/tutorials/rcp/MapView.java +++ b/plugins/org.locationtech.udig.tutorials.rcp/src/org/locationtech/udig/tutorials/rcp/MapView.java @@ -19,18 +19,17 @@ import org.locationtech.udig.catalog.ICatalog; import org.locationtech.udig.catalog.IGeoResource; import org.locationtech.udig.catalog.IService; -import org.locationtech.udig.catalog.IServiceFactory; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.Layer; import org.locationtech.udig.project.internal.Map; import org.locationtech.udig.project.internal.ProjectFactory; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.commands.AddLayersCommand; import org.locationtech.udig.project.ui.internal.MapPart; import org.locationtech.udig.project.ui.internal.wizard.MapImport; import org.locationtech.udig.project.ui.tool.IMapEditorSelectionProvider; import org.locationtech.udig.project.ui.tool.ModalTool; import org.locationtech.udig.project.ui.viewers.MapViewer; -import org.locationtech.udig.tools.internal.FixedScalePan; +import org.locationtech.udig.tools.internal.PanTool; import org.locationtech.udig.tools.internal.Zoom; import org.locationtech.udig.tutorials.tracking.glasspane.SeagullGlassPaneOp; @@ -52,7 +51,7 @@ /** * A map view. - * + * * @author Emily Gouge, Graham Davis (Refractions Research, Inc.) * @since 1.1.0 * @version 1.3.0 @@ -80,8 +79,8 @@ public void createPartControl( Composite parent ) { // create a new empty map // if you are going to add layers do so now // prior to adding to the mapviewer - // - map = (Map) ProjectFactory.eINSTANCE.createMap(); + // + map = ProjectFactory.eINSTANCE.createMap(); mapviewer.setMap(map); IMenuManager viewMenu = getViewSite().getActionBars().getMenuManager(); @@ -121,7 +120,7 @@ public void createPartControl( Composite parent ) { // } // } // } - // + // // class SetPrintTilesVPToolAction extends Action { // public SetPrintTilesVPToolAction() { // super("Print VP Tiles"); //$NON-NLS-1$ @@ -149,6 +148,7 @@ class SetPrintMapLayersToolAction extends Action { public SetPrintMapLayersToolAction() { super("Print Map Layers"); //$NON-NLS-1$ } + @Override public void run() { if (map != null) { for( Layer layer : map.getLayersInternal() ) { @@ -163,7 +163,8 @@ public SetPanToolAction() { super("Pan"); //$NON-NLS-1$ } - private FixedScalePan tool = new FixedScalePan(); + private PanTool tool = new PanTool(); + @Override public void run() { setActive(tool); } @@ -174,6 +175,7 @@ class SetZoomExtentToolAction extends Action { public SetZoomExtentToolAction() { super("Zoom"); //$NON-NLS-1$ } + @Override public void run() { setActive(tool); } @@ -183,6 +185,7 @@ class SetZoomToMapToolAction extends Action { public SetZoomToMapToolAction() { super("Zoom to Map"); //$NON-NLS-1$ } + @Override public void run() { ReferencedEnvelope bounds = map.getBounds(new NullProgressMonitor()); map.sendCommandASync(new SetViewportBBoxCommand(bounds)); @@ -193,6 +196,7 @@ class SetRefreshToolAction extends Action { public SetRefreshToolAction() { super("Refresh Map"); //$NON-NLS-1$ } + @Override public void run() { mapviewer.getRenderManager().refresh(null); } @@ -202,11 +206,13 @@ class SetBackgroundFileAction extends Action { public SetBackgroundFileAction() { super("Add Background layer from file..."); //$NON-NLS-1$ } + @Override @SuppressWarnings("unchecked") public void run() { Display display = Display.getCurrent(); final ArrayList files = new ArrayList(); display.syncExec(new Runnable(){ + @Override public void run() { FileDialog openDialog = new FileDialog(getSite().getShell(), SWT.OPEN | SWT.MULTI); @@ -222,7 +228,7 @@ public void run() { return; List dataHandles = new ArrayList(); ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog(); - + for( File file : files ) { try { URL url = file.toURI().toURL(); @@ -252,6 +258,7 @@ class SetGlassSeagullsAction extends Action { public SetGlassSeagullsAction() { super("Add Glass Seagulls layer"); //$NON-NLS-1$ } + @Override public void run() { Display display = Display.getCurrent(); if (seagullOp == null) { @@ -271,10 +278,12 @@ class SetBackgroundWMSCAction extends Action { public SetBackgroundWMSCAction() { super("Add Background layer..."); //$NON-NLS-1$ } + @Override public void run() { Display display = Display.getCurrent(); // final ArrayList files = new ArrayList(); display.syncExec(new Runnable(){ + @Override public void run() { MapImport mapImport = new MapImport(); mapImport.getDialog().open(); @@ -291,6 +300,7 @@ public void setFocus() { public void setModalTool( ModalTool tool ) { tool.setActive(true); } + @Override public Map getMap() { return mapviewer.getMap(); } @@ -302,14 +312,17 @@ public void dispose() { } } + @Override public void openContextMenu() { mapviewer.openContextMenu(); } + @Override public void setFont( Control control ) { mapviewer.setFont(control); } + @Override public void setSelectionProvider( IMapEditorSelectionProvider selectionProvider ) { mapviewer.setSelectionProvider(selectionProvider); } diff --git a/plugins/org.locationtech.udig.tutorials.rcp/src/org/locationtech/udig/tutorials/rcp/OverviewMapView.java b/plugins/org.locationtech.udig.tutorials.rcp/src/org/locationtech/udig/tutorials/rcp/OverviewMapView.java index c071b0c676..8311fa649a 100644 --- a/plugins/org.locationtech.udig.tutorials.rcp/src/org/locationtech/udig/tutorials/rcp/OverviewMapView.java +++ b/plugins/org.locationtech.udig.tutorials.rcp/src/org/locationtech/udig/tutorials/rcp/OverviewMapView.java @@ -10,9 +10,9 @@ */ package org.locationtech.udig.tutorials.rcp; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.Map; import org.locationtech.udig.project.internal.ProjectFactory; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.ui.ApplicationGIS; import org.locationtech.udig.project.ui.internal.MapPart; import org.locationtech.udig.project.ui.internal.tool.display.ToolManager; diff --git a/plugins/org.locationtech.udig.tutorials.tracking/src/org/locationtech/udig/tutorials/tracking/glasspane/TrackSeagullOp.java b/plugins/org.locationtech.udig.tutorials.tracking/src/org/locationtech/udig/tutorials/tracking/glasspane/TrackSeagullOp.java index a1ec9a133b..47188e4c92 100644 --- a/plugins/org.locationtech.udig.tutorials.tracking/src/org/locationtech/udig/tutorials/tracking/glasspane/TrackSeagullOp.java +++ b/plugins/org.locationtech.udig.tutorials.tracking/src/org/locationtech/udig/tutorials/tracking/glasspane/TrackSeagullOp.java @@ -30,8 +30,8 @@ import org.locationtech.jts.geom.Envelope; import org.locationtech.udig.project.IMap; +import org.locationtech.udig.project.command.navigation.SetViewportCenterCommand; import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.command.navigation.SetViewportCenterCommand; import org.locationtech.udig.project.internal.render.ViewportModel; import org.locationtech.udig.project.internal.render.impl.ViewportModelImpl; import org.locationtech.udig.project.ui.internal.render.displayAdapter.impl.ViewportPaneTiledSWT;