From a9410d3bd729b3cec8d5ac4d8b96a2e1ca704099 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 | 9 +- .../wmt/ui/view/WMTZoomLevelSwitcher.java | 2 +- .../udig/issues/FeatureIssue.java | 1 - .../AbstractToggleMapGraphicAction.java | 13 +- .../printing/model/impl/MapBoxPrinter.java | 2 +- .../udig/printing/ui/pdf/ExportPDFWizard.java | 2 +- .../project/command/CommandManagerTest.java | 50 --- .../commands/SetScaleCommandTest.java | 70 ++-- .../TestDrawCoordinateCommandHandler.java | 2 +- .../project/ui/controls/ScaleRatioLabel.java | 2 +- .../project/ui/internal/CRSPropertyPage.java | 2 +- .../ui/internal/actions/ZoomToLayer.java | 2 +- .../GeometryPropertyDescriptor.java | 9 +- .../internal/tool/impl/ToolContextImpl.java | 24 +- .../udig/project/ui/tool/IToolContext.java | 7 - .../udig/project/ui/viewers/MapViewer.java | 2 +- .../META-INF/MANIFEST.MF | 5 +- .../project/command/BasicCommandFactory.java | 91 ----- .../udig/project/command/Command.java | 16 - .../udig/project/command/CommandManager.java | 9 +- .../udig/project/command/NavCommand.java | 8 +- .../command/factory/BasicCommandFactory.java | 173 --------- .../navigation/AbstractNavCommand.java | 108 ++++++ .../command/navigation/NavComposite.java | 2 +- .../command/navigation/PanCommand.java | 17 +- .../command/navigation/SetBoundsCommand.java | 24 ++ .../navigation}/SetScaleCommand.java | 16 +- .../navigation/SetViewportBBoxCommand.java | 41 +-- .../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 ------ .../internal/commands/ChangeCRSCommand.java | 68 ++-- .../udig/project/internal/messages.properties | 4 +- .../tools/internal/InvalidateCommand.java | 41 --- .../internal/NavigationUpdateThread.java | 12 +- .../locationtech/udig/tools/internal/Pan.java | 62 +--- .../udig/tools/internal/PanTool.java | 94 +---- .../udig/tools/internal/Zoom.java | 1 - .../udig/tools/internal/ZoomExtent.java | 2 +- .../internal/commands/PanAndInvalidate.java | 53 +++ .../ValidToolDetectionActivator.java | 4 +- .../tool/select/internal/ZoomSelection.java | 2 +- .../internal/view/MergeFeaturesCommand.java | 4 - .../preferredzoomlevels/ZoomToFeatures.java | 2 +- .../udig/tutorials/rcp/MapView.java | 1 - .../udig/tutorials/rcp/OverviewMapView.java | 1 + .../tracking/glasspane/TrackSeagullOp.java | 2 +- 51 files changed, 610 insertions(+), 1013 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/factory/BasicCommandFactory.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%) rename plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/{internal => }/command/navigation/SetViewportBBoxCommand.java (81%) 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.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 250e6872ab..0704586a09 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 @@ -18,9 +18,8 @@ import org.locationtech.jts.geom.Envelope; import org.locationtech.udig.bookmarks.Bookmark; 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; import org.opengis.referencing.crs.CoordinateReferenceSystem; @@ -73,13 +72,9 @@ protected void runImpl(IProgressMonitor monitor) throws Exception { } @Override - 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 0c252c13c1..34823c2933 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,7 +34,6 @@ 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.internal.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; 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/command/CommandManagerTest.java b/plugins/org.locationtech.udig.project.tests/src/org/locationtech/udig/project/command/CommandManagerTest.java index f66fc1459f..e760743032 100644 --- a/plugins/org.locationtech.udig.project.tests/src/org/locationtech/udig/project/command/CommandManagerTest.java +++ b/plugins/org.locationtech.udig.project.tests/src/org/locationtech/udig/project/command/CommandManagerTest.java @@ -46,11 +46,6 @@ public void run(IProgressMonitor monitor) throws Exception { result.ran = true; } - @Override - public Command copy() { - return null; - } - @Override public String getName() { return null; @@ -80,11 +75,6 @@ public void run(IProgressMonitor monitor) throws Exception { result.ran = true; } - @Override - public Command copy() { - return null; - } - @Override public String getName() { return null; @@ -115,11 +105,6 @@ public void run(IProgressMonitor monitor) throws Exception { resultInner.ran = true; } - @Override - public Command copy() { - return null; - } - @Override public String getName() { return null; @@ -129,11 +114,6 @@ public String getName() { result.ran = true; } - @Override - public Command copy() { - return null; - } - @Override public String getName() { return null; @@ -173,11 +153,6 @@ public void run() { }); } - @Override - public Command copy() { - return null; - } - @Override public String getName() { return null; @@ -190,11 +165,6 @@ public String getName() { result.ran = true; } - @Override - public Command copy() { - return null; - } - @Override public String getName() { return null; @@ -220,11 +190,6 @@ public void run(IProgressMonitor monitor) throws Exception { result.ran = true; } - @Override - public Command copy() { - return null; - } - @Override public String getName() { return null; @@ -250,11 +215,6 @@ public void run(IProgressMonitor monitor) throws Exception { result.ran = true; } - @Override - public Command copy() { - return null; - } - @Override public String getName() { return null; @@ -284,11 +244,6 @@ public void run(IProgressMonitor monitor) throws Exception { fail(); } - @Override - public Command copy() { - return null; - } - @Override public String getName() { return null; @@ -341,11 +296,6 @@ public void run(IProgressMonitor monitor) throws Exception { fail(); } - @Override - public Command copy() { - return null; - } - @Override public String getName() { return null; 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 7122d8c014..8994e23bba 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 @@ -11,7 +11,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -19,6 +18,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.junit.Test; import org.junit.runner.RunWith; +import org.locationtech.udig.project.command.navigation.SetScaleCommand; import org.locationtech.udig.project.internal.render.ViewportModel; import org.mockito.ArgumentCaptor; import org.mockito.Captor; @@ -28,54 +28,48 @@ @RunWith(MockitoJUnitRunner.class) public class SetScaleCommandTest { - private static final double SCALE_TO_SET = 0.5; + private static final double SCALE_TO_SET = 0.5; - private static final double PREVIOUS_SCALE = 0.3; + private static final double PREVIOUS_SCALE = 0.3; - @Mock - private ViewportModel mockedViewportModel; + @Mock + private ViewportModel mockedViewportModel; - @Mock - private IProgressMonitor monitor; + @Mock + private IProgressMonitor monitor; - @Captor - private ArgumentCaptor scaleDenominatorCaptor; + @Captor + private ArgumentCaptor scaleDenominatorCaptor; - @Test - public void testCopy() throws Exception { - SetScaleCommand setScaleCommand = new SetScaleCommand(SCALE_TO_SET); - assertNotSame(setScaleCommand, setScaleCommand.copy()); - } + @Test + public void ifModelIsSetSetScaleIsCalled() throws Exception { + when(mockedViewportModel.getScaleDenominator()).thenReturn(PREVIOUS_SCALE); - @Test - public void ifModelIsSetSetScaleIsCalled() throws Exception { - when(mockedViewportModel.getScaleDenominator()).thenReturn(PREVIOUS_SCALE); + SetScaleCommand setScaleCommand = new SetScaleCommand(SCALE_TO_SET); + setScaleCommand.setViewportModel(mockedViewportModel); + setScaleCommand.run(monitor); - SetScaleCommand setScaleCommand = new SetScaleCommand(SCALE_TO_SET); - setScaleCommand.setViewportModel(mockedViewportModel); - setScaleCommand.run(monitor); + verify(mockedViewportModel).setScale(SCALE_TO_SET); + } - verify(mockedViewportModel).setScale(SCALE_TO_SET); - } + @Test + public void rollbackSetsPreviousScaleFromModel() throws Exception { + when(mockedViewportModel.getScaleDenominator()).thenReturn(PREVIOUS_SCALE); - @Test - public void rollbackSetsPreviousScaleFromModel() throws Exception { - when(mockedViewportModel.getScaleDenominator()).thenReturn(PREVIOUS_SCALE); + SetScaleCommand setScaleCommand = new SetScaleCommand(SCALE_TO_SET); + setScaleCommand.setViewportModel(mockedViewportModel); - SetScaleCommand setScaleCommand = new SetScaleCommand(SCALE_TO_SET); - setScaleCommand.setViewportModel(mockedViewportModel); + setScaleCommand.run(monitor); + setScaleCommand.rollback(monitor); - setScaleCommand.run(monitor); - setScaleCommand.rollback(monitor); + verify(mockedViewportModel, times(2)).setScale(scaleDenominatorCaptor.capture()); - verify(mockedViewportModel, times(2)).setScale(scaleDenominatorCaptor.capture()); + assertEquals(SCALE_TO_SET, scaleDenominatorCaptor.getAllValues().get(0), 0); + assertEquals(PREVIOUS_SCALE, scaleDenominatorCaptor.getAllValues().get(1), 0); + } - assertEquals(SCALE_TO_SET, scaleDenominatorCaptor.getAllValues().get(0), 0); - assertEquals(PREVIOUS_SCALE, scaleDenominatorCaptor.getAllValues().get(1), 0); - } - - @Test - public void commandNameNotNull() throws Exception { - assertNotNull("Command name expected", new SetScaleCommand(SCALE_TO_SET).getName()); - } + @Test + public void commandNameNotNull() throws Exception { + assertNotNull("Command name expected", new SetScaleCommand(SCALE_TO_SET).getName()); + } } 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 a8cbc00cd1..6cb8eb1a66 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 8c52a3572d..f82132f8f0 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,7 +30,7 @@ import org.locationtech.jts.geom.Envelope; import org.locationtech.jts.geom.Geometry; import org.locationtech.udig.project.IMap; -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.project.ui.internal.Messages; import org.locationtech.udig.project.ui.internal.ProjectUIPlugin; @@ -90,12 +90,13 @@ public void handleEvent(Event event) { } Envelope env = geometry.getEnvelopeInternal(); try { - env = JTS.transform(env, map.getEditManager().getEditLayer() - .layerToMapTransform()); + env = JTS.transform(env, + map.getEditManager().getEditLayer().layerToMapTransform()); } catch (Exception e1) { ProjectUIPlugin.log(null, e1); } - map.sendCommandASync(new SetViewportBBoxCommand(env, map.getViewportModel().getCRS())); + map.sendCommandASync( + new SetViewportBBoxCommand(env, map.getViewportModel().getCRS())); } }); 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 e175aadf0b..050b6f1209 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 @@ -31,7 +31,6 @@ 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.SelectionCommandFactory; import org.locationtech.udig.project.internal.impl.AbstractContextImpl; @@ -60,21 +59,7 @@ *
  • {@link org.locationtech.udig.project.ui.internal.tool.impl.ToolContextImpl#getRenderManager * Render Manager}
  • *
  • {@link org.locationtech.udig.project.ui.internal.tool.impl.ToolContextImpl#getMapDisplay - * Map Display}
  • - *
  • {@link org.locationtech.udig.project.ui.internal.tool.impl.ToolContextImpl#getMap - * Map}
  • - *
  • {@link org.locationtech.udig.project.ui.internal.tool.impl.ToolContextImpl#getProject - * Project}
  • - *
  • {@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}
  • + *
  • {@link org.locationtech.udig.project.ui.internal.tool.impl.ToolContextImpl#getSelectionFactory Selection Factory}
  • * *

    * @@ -94,8 +79,6 @@ public class ToolContextImpl extends AbstractContextImpl implements ToolContext * @see #getEditFactory() */ private final EditCommandFactory editFactory = EditCommandFactory.getInstance(); - - /** * The cached value of the '{@link #getSelectionFactory() Selection Factory}' * attribute. * @@ -103,8 +86,6 @@ public class ToolContextImpl extends AbstractContextImpl implements ToolContext */ private final SelectionCommandFactory selectionFactory = SelectionCommandFactory.getInstance(); - private final BasicCommandFactory basicCommandFactory = BasicCommandFactory.getInstance(); - public ToolContextImpl() { super(); } @@ -270,9 +251,6 @@ public void updateUI(Runnable runnable) { } @Override - public BasicCommandFactory getBasicCommandFactory() { - return this.basicCommandFactory; - } @Override public ToolContextImpl copy() { 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 b5025e2600..d0850bebc6 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 @@ -16,7 +16,6 @@ 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.SelectionCommandFactory; import org.locationtech.udig.project.ui.commands.DrawCommandFactory; @@ -74,12 +73,6 @@ public interface IToolContext extends IAbstractContext { */ public SelectionCommandFactory getSelectionFactory(); - /** - * Returns a BasicCommandFactory. - * - * @return a BasicCommandFactory - */ - public BasicCommandFactory getBasicCommandFactory(); /** * Dispatches a command. If the command is a IDrawCommand the command will be added to the 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 88022d54c4..7063ab4e18 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 @@ -26,8 +26,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 0b019c0b47..9e57c967a6 100644 --- a/plugins/org.locationtech.udig.project/META-INF/MANIFEST.MF +++ b/plugins/org.locationtech.udig.project/META-INF/MANIFEST.MF @@ -24,6 +24,7 @@ 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, @@ -31,13 +32,11 @@ Export-Package: org.locationtech.udig.project, 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.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.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, 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 1ea209ab0c..eb9d11148a 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 @@ -458,7 +458,8 @@ private boolean openWarning(final Command command) { @Override public void run() { String string = Messages.CommandManager_warning + command.getName(); - if (command instanceof RollbackCommand || command instanceof CommitCommand) + if ( command instanceof RollbackCommand || + command instanceof CommitCommand ) string += "?"; //$NON-NLS-1$ else string += Messages.CommandManager_warning2; @@ -467,9 +468,7 @@ public void run() { PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getShell(), Messages.CommandManager_warningTitle, string, - Messages.CommandManager_toggleMessage, false, - preferenceStore, - PreferenceConstants.P_WARN_IRREVERSIBLE_COMMAND); + Messages.CommandManager_toggleMessage, false, preferenceStore, PreferenceConstants.P_WARN_IRREVERSIBLE_COMMAND); runCommand[0] = dialog.getReturnCode() == IDialogConstants.OK_ID; if (dialog.getToggleState()) { preferenceStore.setValue( @@ -488,8 +487,10 @@ public void run() { * Notifies the owner that the command has been executed. */ private void notifyOwner(Command command) { + for (CommandListener listener : completionHandlers) { listener.commandExecuted(command); + } } 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/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/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 cacabff566..8268700871 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 @@ -8,7 +8,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..63f43c22ca 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,13 +64,9 @@ 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/internal/command/navigation/SetViewportBBoxCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportBBoxCommand.java similarity index 81% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportBBoxCommand.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportBBoxCommand.java index a31f59aa4d..c8ceeb82b9 100644 --- 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/command/navigation/SetViewportBBoxCommand.java @@ -1,5 +1,4 @@ -/** - * uDig - User Friendly Desktop Internet GIS client +/* uDig - User Friendly Desktop Internet GIS client * http://udig.refractions.net * (C) 2004-2012, Refractions Research Inc. * @@ -8,24 +7,25 @@ * (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.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.locationtech.jts.geom.Envelope; -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.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 + * 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()}. * @@ -41,15 +41,14 @@ public class SetViewportBBoxCommand extends AbstractNavCommand { private boolean forceContainBBoxZoom; /** - * Creates a new instance of SetViewportBBoxCommand. The BBox is expected to be the same as the + * 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 + * @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 */ - @Deprecated public SetViewportBBoxCommand(Envelope bbox) { this.newbbox = bbox; if (bbox instanceof ReferencedEnvelope) @@ -57,10 +56,10 @@ public SetViewportBBoxCommand(Envelope bbox) { } /** - * Creates a new instance of SetViewportBBoxCommand. The BBox is expected to be the same as the + * 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 + * @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()}. */ @@ -69,11 +68,11 @@ public SetViewportBBoxCommand(ReferencedEnvelope bbox) { } /** - * Sets the bounds of the viewport model to the bounds. The CRS parameter indications the CRS of + * 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. + * @param crs The crs of the provided bounds. */ public SetViewportBBoxCommand(Envelope bounds, CoordinateReferenceSystem crs) { this(new ReferencedEnvelope(bounds, crs)); @@ -86,15 +85,7 @@ public SetViewportBBoxCommand(ReferencedEnvelope bbox, boolean forceContainBBoxZ } /** - * @see org.locationtech.udig.project.internal.command.MapCommand#copy() - */ - @Override - public MapCommand copy() { - return new SetViewportBBoxCommand(newbbox, crs); - } - - /** - * @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) { 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/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/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..8591e58793 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 @@ -12,15 +12,14 @@ import java.awt.Point; import java.util.ArrayList; +import org.locationtech.jts.geom.Coordinate; 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; -import org.locationtech.jts.geom.Coordinate; - /** * Waits 1 second after the most recent request before running operation. * @@ -181,7 +180,7 @@ public void zoomWithFixedPoint( int change, IToolContext context, int updateDela requestStart(); } - protected synchronized void performChange() { + protected synchronized void performChange() { double zoom = Math.abs(Math.pow(FACTOR, previousZoom)); ArrayList commands=new ArrayList(); if( horizontal!=0 || vertical!=0 ){ @@ -189,6 +188,7 @@ protected synchronized void performChange() { new PanCommand((horizontal*-PAN_AMOUNT), (vertical*-PAN_AMOUNT))); } if( zoom>0.00000001 ){ + // TODO targetZoom is never used .. double targetZoom = context.calculateZoomLevel(1,previousZoom, fixedPoint, false, zoomAmount != 0); ZoomCommand zoomCommand = new ZoomCommand(previousZoom); zoomCommand.setFixedPoint(fixedPoint); 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 934c7d9dc6..70f5e437e4 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 @@ -25,12 +25,9 @@ import org.geotools.geometry.jts.ReferencedEnvelope; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Envelope; -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; @@ -39,7 +36,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.locationtech.udig.tools.internal.commands.PanAndInvalidate; /** * Provides Pan functionality for MapViewport; the technique used for panning is controlled via * preferences. @@ -63,7 +60,7 @@ public IPreferenceStore fillFields(Composite parent) { return ToolsPlugin.getDefault().getPreferenceStore(); } - }; + } /** * Delegate used to control how the PanTool functions; configured using Preference. @@ -87,7 +84,7 @@ public void mouseReleased(MapMouseEvent e) { public void dispose() { } - }; + } private ScrollStrategy strategy; @@ -139,21 +136,25 @@ protected boolean validModifierButtonCombo(MapMouseEvent e) { return e.buttons == MapMouseEvent.BUTTON1 && !(e.modifiersDown()); } + @Override @Override public void mouseDragged(MapMouseEvent e) { strategy.mouseDragged(e); } + @Override @Override public void mousePressed(MapMouseEvent e) { strategy.mousePressed(e); } + @Override @Override public void mouseReleased(MapMouseEvent e) { strategy.mouseReleased(e); } + @Override @Override public void dispose() { if (strategy != null) { @@ -163,60 +164,7 @@ 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; - } - - @Override - public Command copy() { - return new PanAndInvalidate(command, expire); - } - - @Override - public String getName() { - return "PanAndDiscard"; - } - - @Override - 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); - } - - @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); - } - - @Override - public void rollback(IProgressMonitor monitor) throws Exception { - command.rollback(monitor); - } - } /** Basic Pan Functionality for MapViewport */ public class Pan extends ScrollStrategy { @@ -245,6 +193,7 @@ public void mousePressed(MapMouseEvent e) { } } + @Override @Override public void mouseReleased(MapMouseEvent e) { if (dragging) { @@ -286,6 +235,7 @@ class Scroll extends ScrollStrategy { private org.eclipse.swt.graphics.Point start = null; + @Override @Override public void mouseDragged(MapMouseEvent e) { if (dragging) { @@ -438,32 +388,16 @@ public void mouseReleased(MapMouseEvent e) { final Envelope newbounds = new Envelope(newc.x - dw, newc.x + dw, newc.y - dh, newc.y + dh); - // compute new BBox for - NavCommand setFinal = new AbstractNavCommand() { - - @Override - protected void runImpl(IProgressMonitor monitor) throws Exception { - model.setBounds(newbounds); - } - - @Override - public Command copy() { - return null; - } - - @Override - 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; } } + @Override @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 46604ad0b6..030d1bce07 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 @@ -16,7 +16,6 @@ import org.geotools.geometry.jts.ReferencedEnvelope; import org.locationtech.jts.geom.Coordinate; -import org.locationtech.udig.project.internal.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/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 a8b681b9e4..d9340ed96f 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 09a6f7a1a5..0b9ed2ad4f 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 @@ -39,7 +39,6 @@ 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.MapSite; 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 813df0f9aa..004d7b5a2e 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,6 +10,7 @@ */ package org.locationtech.udig.tutorials.rcp; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuManager; 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;