From 4b7e368aff5a44079fa8bf35a44cc6f44baec06c Mon Sep 17 00:00:00 2001
From: Frank Gasdorf
- * 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 ) {
* }
- *
+ *
* }
*
*
diff --git a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/display/ToolManager.java b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/display/ToolManager.java index 1631cbb286..e15ef678cd 100644 --- a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/display/ToolManager.java +++ b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/display/ToolManager.java @@ -1010,7 +1010,7 @@ public void run() { forwardAction.setActionDefinitionId("org.eclipse.ui.navigate.forward"); //$NON-NLS-1$ } if (activeMap != ApplicationGIS.NO_MAP) - forwardAction.setEnabled(activeMap.getCommandStack().canRedo()); + forwardAction.setEnabled(activeMap.getNavCommandStack().hasForwardHistory()); else forwardAction.setEnabled(false); return forwardAction; @@ -1099,7 +1099,7 @@ public void run() { backwardAction.setActionDefinitionId("org.eclipse.ui.navigate.back"); //$NON-NLS-1$ } if (activeMap != ApplicationGIS.NO_MAP) - backwardAction.setEnabled(activeMap.getCommandStack().canUndo()); + backwardAction.setEnabled(activeMap.getNavCommandStack().hasBackHistory()); else backwardAction.setEnabled(false); }finally{ diff --git a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/impl/ToolContextImpl.java b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/impl/ToolContextImpl.java index 6b0b9195c7..bd3cdbb3da 100644 --- a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/impl/ToolContextImpl.java +++ b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/internal/tool/impl/ToolContextImpl.java @@ -32,9 +32,7 @@ import org.locationtech.udig.project.command.EditCommand; import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.command.NavCommand; -import org.locationtech.udig.project.command.factory.BasicCommandFactory; import org.locationtech.udig.project.command.factory.EditCommandFactory; -import org.locationtech.udig.project.command.factory.NavigationCommandFactory; import org.locationtech.udig.project.command.factory.SelectionCommandFactory; import org.locationtech.udig.project.internal.impl.AbstractContextImpl; import org.locationtech.udig.project.internal.render.RenderManager; @@ -61,7 +59,6 @@ *
- * If the current command has already executed it cannot be used again, but a copy may - * because a copy should contain none of the state side-effect that execution has on a - * command - *
- * @deprecated - */ - public Command copy(); - /** * Each command has a name that is displayed with the undo/redo buttons. * * @return The name of the command (often translated) */ public String getName(); - } diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/CommandManager.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/CommandManager.java index f729904a0c..9dd12a38c5 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/CommandManager.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/CommandManager.java @@ -28,7 +28,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialogWithToggle; @@ -39,7 +39,7 @@ /** * A commands Manager executes commands in a seperate thread, either synchronously or a * synchronously. - * + * * @author Jesse * @since 1.0.0 */ @@ -60,7 +60,7 @@ public class CommandManager implements CommandStack, NavCommandStack { /** * Creates a new instance of CommandManager - * + * * @param handler an error handler to use to handle thrown exceptions. */ public CommandManager( String managerName, ErrorHandler handler, CommandListener commandCompletionListener ) { @@ -71,7 +71,7 @@ public CommandManager( String managerName, ErrorHandler handler, CommandListener } /** * Creates a new instance of CommandManager - * + * * @param handler an error handler to use to handle thrown exceptions. */ public CommandManager( String managerName, ErrorHandler handler ) { @@ -79,19 +79,19 @@ public CommandManager( String managerName, ErrorHandler handler ) { } /** * Creates a new instance of CommandManager - * + * * @param handler an error handler to use to handle thrown exceptions. */ public CommandManager( String managerName, ErrorHandler handler, CommandListener commandCompletionListener, long timeout2 ) { this(managerName, handler, commandCompletionListener); this.timeout = timeout2; - + } /** * Executes a command. Calls the Errorhandler if an exception is thrown. - * + * * @param command The command to execute * @param async flag indicating wether command should be executed sync vs async. * @return true if no problems were encountered while queueing command. Problems will typically @@ -102,7 +102,7 @@ public boolean execute( final Command command, boolean async ) { return doMakeRequest(command, async, type); } - + /** * @param command command to perform * @param async whether to do request synchronously @@ -113,7 +113,7 @@ private boolean doMakeRequest( final Command command, boolean async, int type ) Request request = new Request(type, command, async, Display.getCurrent() != null); synchronized (this) { if (commandExecutor == null) { - commandExecutor = new Executor(managerName); + commandExecutor = new Executor(managerName); } } commandExecutor.addRequest(request); @@ -143,7 +143,7 @@ private boolean doMakeRequest( final Command command, boolean async, int type ) } private long waitOnRequest( Request request ) throws InterruptedException { - ProjectPlugin.trace(TRACE_ID,getClass(), + ProjectPlugin.trace(TRACE_ID,getClass(), "synchronous command NOT in display thread\nTimout=" + timeout, null); //$NON-NLS-1$ long tries = 0; @@ -158,14 +158,14 @@ private long waitOnRequest( Request request ) throws InterruptedException { /** * This method is special wait command that ensures that the display does not block. It executes * the jobs waiting for display. - * + * * @param current the current display * @param request * @throws InterruptedException * @see Display#readAndDispatch() */ private long waitInDisplay( Display current, Request request ) throws InterruptedException { - ProjectPlugin.trace(TRACE_ID,getClass(), + ProjectPlugin.trace(TRACE_ID,getClass(), "synchronous command IN display thread\nTimout=" + timeout, null); //$NON-NLS-1$ long start = System.currentTimeMillis(); @@ -189,13 +189,13 @@ private long waitInDisplay( Display current, Request request ) throws Interrupte private boolean mustWait( Request request, long tries ) { ProjectPlugin .trace( - TRACE_ID, getClass(), + TRACE_ID, getClass(), "timeout :" + timeout + ", tries: " + tries + ", completed:" + request.completed, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return !request.completed && (tries < timeout || timeout == -1); } /** * Executes the last undone command, if there are any commands to undo. - * + * * @param runAsync true to run undo asynchronously */ public void redo( boolean runAsync ) { @@ -204,7 +204,7 @@ public void redo( boolean runAsync ) { /** * Undoes the last command if possible. - * + * * @param runAsync true to run undo asynchronously */ public void undo( boolean runAsync ) { @@ -213,7 +213,7 @@ public void undo( boolean runAsync ) { /** * Adds an Errorhandler to the list of error handlers - * + * * @param handler the error handler to add. * @see ErrorHandler */ @@ -223,7 +223,7 @@ public void addErrorHandler( ErrorHandler handler ) { /** * Removes an Errorhandler from the list of error handlers - * + * * @param handler the error handler to remove. * @see ErrorHandler */ @@ -234,13 +234,14 @@ public void removeErrorHandler( ErrorHandler handler ) { /** * @see org.locationtech.udig.project.command.CommandStack#canUndo() */ + @Override public boolean canUndo() { if( commandExecutor ==null ) return false; - + Command c; if (!commandExecutor.history.isEmpty()) { - c = (Command) commandExecutor.history.peek(); + c = commandExecutor.history.peek(); if (c instanceof UndoableCommand) return true; } @@ -250,6 +251,7 @@ public boolean canUndo() { /** * @see org.locationtech.udig.project.command.CommandStack#canRedo() */ + @Override public boolean canRedo() { if (commandExecutor!=null && !commandExecutor.undone.isEmpty()) { return true; @@ -260,6 +262,7 @@ public boolean canRedo() { /** * @see org.locationtech.udig.project.command.NavCommandStack#hasBackHistory() */ + @Override public boolean hasBackHistory() { return canUndo(); } @@ -267,6 +270,7 @@ public boolean hasBackHistory() { /** * @see org.locationtech.udig.project.command.NavCommandStack#hasForwardHistory() */ + @Override public boolean hasForwardHistory() { return canRedo(); } @@ -274,7 +278,7 @@ public boolean hasForwardHistory() { /** * Executes commands in a seperate thread from the requesting thread. JONES: Should support * force kill of a command. - * + * * @author Jesse * @since 1.0.0 */ @@ -287,7 +291,7 @@ public class Executor extends Job { /** * ConstructExecutor
.
- *
+ *
* @param name the name of the job
* @param type the type of the executor. (RUN, UNDO, REDO)
*/
@@ -300,9 +304,9 @@ public Executor( String name ) {
Request currentRequest;
@Override
protected IStatus run( IProgressMonitor monitor ) {
- monitor.beginTask(Messages.CommandManager_ProgressMonitor, IProgressMonitor.UNKNOWN);
+ monitor.beginTask(Messages.CommandManager_ProgressMonitor, IProgressMonitor.UNKNOWN);
while( !getThread().isInterrupted() ) {
-
+
synchronized (this) {
currentRequest = commands.poll();
if( currentRequest==null )
@@ -341,7 +345,7 @@ private void run( IProgressMonitor monitor, Request request ) {
/**
* Adds a command to the stack of commands that needs to be executed.
- *
+ *
* @param request
*/
public void addRequest( Request request ) {
@@ -376,7 +380,7 @@ synchronized void removeCommand( Request request ) {
/**
* Executes a command. Calls the Errorhandler if an exception is thrown.
- *
+ *
* @param command The command to execute
*/
private void execute( final Command command, IProgressMonitor monitor ) {
@@ -392,13 +396,13 @@ private void execute( final Command command, IProgressMonitor monitor ) {
if (command instanceof PostDeterminedEffectCommand) {
PostDeterminedEffectCommand c = (PostDeterminedEffectCommand) command;
- if (c.execute(new SubProgressMonitor(monitor, 1000))) {
+ if (c.execute(SubMonitor.convert(monitor, 1000))) {
undone.clear();
addToHistory(command);
}
} else {
- command.run(new SubProgressMonitor(monitor, 1000));
+ command.run(SubMonitor.convert(monitor, 1000));
undone.clear();
addToHistory(command);
@@ -426,7 +430,7 @@ private void addToHistory( final Command command ) {
history.removeFirst();
history.addLast(command);
}
-
+
private boolean openWarning( final Command command ) {
final boolean[] runCommand=new boolean[1];
if (!(command instanceof UndoableCommand)
@@ -438,9 +442,10 @@ private boolean openWarning( final Command command ) {
.getBoolean(PreferenceConstants.P_IRREVERSIBLE_COMMAND_VALUE);
}
PlatformGIS.syncInDisplayThread(new Runnable(){
+ @Override
public void run() {
String string = Messages.CommandManager_warning + command.getName();
- if ( command instanceof RollbackCommand ||
+ if ( command instanceof RollbackCommand ||
command instanceof CommitCommand )
string += "?"; //$NON-NLS-1$
else
@@ -449,8 +454,8 @@ public void run() {
.openOkCancelConfirm(
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell(),
- Messages.CommandManager_warningTitle, string,
- Messages.CommandManager_toggleMessage, false, preferenceStore, PreferenceConstants.P_WARN_IRREVERSIBLE_COMMAND);
+ Messages.CommandManager_warningTitle, string,
+ Messages.CommandManager_toggleMessage, false, preferenceStore, PreferenceConstants.P_WARN_IRREVERSIBLE_COMMAND);
runCommand[0] = dialog.getReturnCode() == IDialogConstants.OK_ID;
if (dialog.getToggleState()) {
preferenceStore
@@ -469,14 +474,14 @@ public void run() {
* Notifies the owner that the command has been executed.
*/
private void notifyOwner( Command command ) {
-
+
for( CommandListener listener : completionHandlers ) {
if (command instanceof NavCommand) {
listener.commandExecuted(MapCommandListener.NAV_COMMAND);
} else {
listener.commandExecuted(MapCommandListener.COMMAND);
}
-
+
}
}
@@ -488,13 +493,13 @@ private void redo( IProgressMonitor monitor ) {
if( undone.isEmpty() )
return;
Command command = undone.removeLast();
- monitor.beginTask(Messages.CommandManager_redo + command.getName(), 1000);
+ monitor.beginTask(Messages.CommandManager_redo + command.getName(), 1000);
try {
if (command instanceof PostDeterminedEffectCommand) {
PostDeterminedEffectCommand post = (PostDeterminedEffectCommand) command;
- post.execute(new SubProgressMonitor(monitor, 1000));
+ post.execute(SubMonitor.convert(monitor, 1000));
} else {
- command.run(new SubProgressMonitor(monitor, 1000));
+ command.run(SubMonitor.convert(monitor, 1000));
}
addToHistory(command);
notifyOwner(command);
@@ -533,9 +538,9 @@ private void undo( IProgressMonitor monitor ) {
c = history.removeLast();
if (c instanceof UndoableCommand) {
UndoableCommand command = (UndoableCommand) c;
- monitor.beginTask(Messages.CommandManager_undo + command.getName(), 1000);
+ monitor.beginTask(Messages.CommandManager_undo + command.getName(), 1000);
try {
- command.rollback(new SubProgressMonitor(monitor, 1000));
+ command.rollback(SubMonitor.convert(monitor, 1000));
addToUndone(command);
} catch (Throwable e) {
handleRollbackError(command, e);
@@ -574,7 +579,7 @@ public void rerunCommands( IProgressMonitor monitor ) {
Queue*
- * + * * @author Jesse * @since 1.0.0 */ @@ -609,7 +614,7 @@ public static class Request { /** * ConstructRequest
.
- *
+ *
* @param type the type of request
* @param command the command to be done/undone/redone
*/
@@ -623,7 +628,7 @@ public Request( int type, Command command, boolean async, boolean requestByDispl
/**
* Determines if the request is synchronous.
- *
+ *
* @return
*/
public boolean isSync() {
@@ -632,7 +637,7 @@ public boolean isSync() {
}
/**
* Execute Command syncrounously. IE wait until command is complete before returning.
- *
+ *
* @return true if no problems were encountered while queueing command. Problems will typically
* occur when the command is synchronous and it times out or is interrupted.
*/
@@ -645,12 +650,12 @@ public int getMaxHistorySize() {
/**
* Execute Command asyncrounously. IE return immediately, do not wait until command is complete
* before returning.
- *
+ *
* @return true if no problems were encountered while queueing command. Problems will typically
* occur when the command is synchronous and it times out or is interrupted.
*/
public boolean aSyncExecute( Command command ) {
return execute(command, true);
}
-
+
}
diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavCommand.java
index f41148e798..2998ddaf0f 100644
--- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavCommand.java
+++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavCommand.java
@@ -12,18 +12,18 @@
import org.locationtech.udig.project.internal.render.ViewportModel;
/**
- * All implementations of NavCommand are used to manipulate the viewport model of the map.
+ * All implementations of NavCommand are used to manipulate the viewport model of the map.
* In addition they are send to the Navigation Command Stack rather than the normal command stack
* for execution.
- *
+ *
* @author Jesse
* @since 0.5
*/
-public interface NavCommand extends UndoableMapCommand, MapCommand {
+public interface NavCommand extends MapCommand {
/**
* Set the viewport model that the command operates on.
- *
+ *
* @param model
* @see ViewportModel
*/
diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavigationCommandFactory.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavigationCommandFactory.java
deleted file mode 100644
index 3772fb1832..0000000000
--- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/NavigationCommandFactory.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/* uDig - User Friendly Desktop Internet GIS client
- * http://udig.refractions.net
- * (C) 2004-2012, Refractions Research Inc.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD
- * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html).
- */
-package org.locationtech.udig.project.command;
-
-import java.util.Arrays;
-
-import org.locationtech.udig.project.internal.command.navigation.NavComposite;
-import org.locationtech.udig.project.internal.command.navigation.PanCommand;
-import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand;
-import org.locationtech.udig.project.internal.command.navigation.SetViewportCenterCommand;
-import org.locationtech.udig.project.internal.command.navigation.SetViewportHeight;
-import org.locationtech.udig.project.internal.command.navigation.SetViewportWidth;
-import org.locationtech.udig.project.internal.command.navigation.ZoomCommand;
-import org.locationtech.udig.project.internal.command.navigation.ZoomExtentCommand;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.Envelope;
-
-/**
- * Factory providing default implementations of common navigation commands.
- *
- * @author jeichar
- * @deprecated Moved to org.locationtech.udig.project.command.factory.NavigationCommandFactory
- * @since TODO provide version
- */
-public class NavigationCommandFactory {
- /**
- * Creates a new NavigationCommandFactory object
- *
- * @return a new NavigationCommandFactory object
- */
- public static NavigationCommandFactory getInstance() {
- return instance;
- }
- private static final NavigationCommandFactory instance = new NavigationCommandFactory();
- protected NavigationCommandFactory() {
- // no op
- }
-
- /**
- * Creates a new {@linkplain NavComposite}
- *
- * @param commands an array of commands to execute as a simgle command. The array will be
- * executed from position 0 to position length-1 in order.
- * @return a new NavComposite object
- * @see NavCommand
- */
- public NavCommand createCompositeCommand( NavCommand[] commands ) {
- return new NavComposite(Arrays.asList(commands));
- }
-
- /**
- * Creates a new {@linkplain SetViewportBBoxCommand}
- *
- * @param newbbox the new bounding box to set in the viewport
- * @return a new SetViewportBBoxCommand object
- * @see NavCommand
- * @see Envelope
- */
- public NavCommand createSetViewportBBoxCommand( Envelope newbbox ) {
- return new SetViewportBBoxCommand(newbbox);
- }
-
- /**
- * Creates a new {@linkplain ZoomCommand}
- *
- * @param zoomfactor the amount to zoom
- * @return a new ZoomCommand object
- * @see NavCommand
- */
- public NavCommand createZoomCommand( double zoomfactor ) {
- return new ZoomCommand(zoomfactor);
- }
-
- /**
- * Creates a new {@linkplain ZoomExtentCommand}
- *
- * @return a new ZoomExtentCommand object
- * @see NavCommand
- */
- public NavCommand createZoomExtentCommand() {
- return new ZoomExtentCommand();
- }
-
- /**
- * Creates a new {@linkplain SetViewportCenterCommand}
- *
- * @param center Sets the center of the viewport. The Coordinate must be in world coordinates.
- * @return a new SetViewportCenterCommand object
- * @see NavCommand
- * @see Coordinate
- */
- public NavCommand createSetViewportCenterCommand( Coordinate center ) {
- return new SetViewportCenterCommand(center);
- }
-
- /**
- * Creates a new {@linkplain SetViewportHeight}
- *
- * @param height The new viewport height
- * @return a new SetViewportHeight object
- * @see NavCommand
- */
- public NavCommand createSetViewportHeight( double height ) {
- return new SetViewportHeight(height);
- }
-
- /**
- * Creates a new {@linkplain SetViewportWidth}
- *
- * @param width the new viewport width
- * @return a new SetViewportWidth object
- * @see NavCommand
- */
- public NavCommand createSetViewportWidth( double width ) {
- return new SetViewportWidth(width);
- }
-
- /**
- * Creates a new {@linkplain PanCommand}Pans the viewport in terms of pixels on the screen.
- * Each pixel represents a distance in world coordinates, the x and y distances differ, so a pan
- * of 8 pixels in the x direction will be translated to a pan of 8*xdistance in the world.
- *
- * @param xpixels The amount, in pixels, to pan in the x direction
- * @param ypixels The amount, in pixels, to pan in the y direction
- * @return a new PanCommand object
- * @see NavCommand
- */
- public NavCommand createPanCommandUsingScreenCoords( int xpixels, int ypixels ) {
- return new PanCommand(xpixels, ypixels);
- }
-
- /**
- * Creates a new {@linkplain PanCommand}
- *
- * @param x The amount, in world coordinates, to pan in the x direction
- * @param y The amount, in world coordinates, to pan in the y direction
- * @return a new PanCommand object
- * @see NavCommand
- */
- public NavCommand createPanCommandUsingWorldCoords( double x, double y ) {
- return new PanCommand(x, y);
- }
-
- public NavCommand createSetViewportBBoxCommand(Envelope bounds, CoordinateReferenceSystem crs) {
- return new SetViewportBBoxCommand(bounds, crs);
- }
-
-}
diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/factory/BasicCommandFactory.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/factory/BasicCommandFactory.java
deleted file mode 100644
index 970decc1e1..0000000000
--- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/factory/BasicCommandFactory.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/* uDig - User Friendly Desktop Internet GIS client
- * http://udig.refractions.net
- * (C) 2004-2012, Refractions Research Inc.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD
- * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html).
- */
-package org.locationtech.udig.project.command.factory;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.locationtech.udig.catalog.IGeoResource;
-import org.locationtech.udig.project.ILayer;
-import org.locationtech.udig.project.IMap;
-import org.locationtech.udig.project.Interaction;
-import org.locationtech.udig.project.command.UndoableMapCommand;
-import org.locationtech.udig.project.internal.Layer;
-import org.locationtech.udig.project.internal.Map;
-import org.locationtech.udig.project.internal.Project;
-import org.locationtech.udig.project.internal.commands.AddLayerCommand;
-import org.locationtech.udig.project.internal.commands.AddLayersCommand;
-import org.locationtech.udig.project.internal.commands.ChangeCRSCommand;
-import org.locationtech.udig.project.internal.commands.CreateMapCommand;
-import org.locationtech.udig.project.internal.commands.DeleteLayerCommand;
-import org.locationtech.udig.project.internal.commands.SetApplicabilityCommand;
-
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-
-/**
- * Creates Edit commands which must be used to modify editable feature data. API internal classes
- * are in the returned API
- *
- * @author jeichar
- * @since 0.3
- */
-@SuppressWarnings("deprecation")
-public class BasicCommandFactory extends org.locationtech.udig.project.command.BasicCommandFactory {
- /**
- * Creates a new EditCommandFactory object
- *
- * @return a new EditCommandFactory object
- */
- public static BasicCommandFactory getInstance() {
- return instance;
- }
-
- private static final BasicCommandFactory instance = new BasicCommandFactory();
- protected BasicCommandFactory() {
- // no op
- }
-
- /**
- * Create a delete layer command
- *
- * @param map the map containing the layer
- * @param layer the layer to delete
- * @return a new {@linkplain DeleteLayerCommand}object that deletes the layer.
- * @see DeleteLayerCommand
- */
- public UndoableMapCommand createDeleteLayer( ILayer layer ) {
- return new DeleteLayerCommand((Layer) layer);
- }
-
- /**
- * Create an Add Layer command
- *
- * @param layer the layer to add to the map.
- * @return a new {@linkplain AddLayerCommand}object that deletes the feature.
- * @see AddLayerCommand
- */
- public UndoableMapCommand createAddLayer( ILayer layer ) {
- return new AddLayerCommand((Layer) layer);
- }
-
- /**
- * Create an Add Layer command
- *
- * @param layer the layer to add to the map.
- * @param index the zorder where the layer will be added.
- * @return a new {@linkplain AddLayerCommand}object that deletes the feature.
- * @see AddLayerCommand
- */
- public UndoableMapCommand createAddLayer( ILayer layer, int index ) {
- return new AddLayerCommand((Layer) layer, index);
- }
-
- /**
- * Create an AddLayers command that adds all the layers in the collection
- *
- * @param evaluationObject the layer to add to the map.
- * @param index the zorder where the layer will be added.
- * @return a new {@linkplain AddLayersCommand}object that deletes the feature.
- * @see AddLayersCommand
- */
- public UndoableMapCommand createAddManyLayers( Collection layers, int index ) {
- return new AddLayersCommand(layers, index);
- }
-
- /**
- * Create an AddLayers command that adds all the layers in the collection
- *
- * @param evaluationObject the layer to add to the map.
- * @return a new {@linkplain AddLayersCommand}object that deletes the feature.
- * @see AddLayersCommand
- */
- public UndoableMapCommand createAddManyLayers( Collection layers ) {
- return new AddLayersCommand(layers);
- }
-
- /**
- * Create a Change CRS command
- *
- * @param map the map for which the CRS is going to change.
- * @return a new {@linkplain ChangeCRSCommand}object that changes the CRS.
- * @see ChangeCRSCommand
- */
- public UndoableMapCommand createChangeCRS( IMap map, CoordinateReferenceSystem crs ) {
- return new ChangeCRSCommand((Map) map, crs);
- }
-
- /**
- * Create a CreateMapCommand
- *
- * @param name the name of the map
- * @param layerResources the IGeoResources that will make up the layers of the map.
- * @param owner The project that will contain the map.
- * @return
- */
- public UndoableMapCommand createCreateMapCommand( String name, List+ *
+ * + * @author Jesse + * @since 1.0.0 + */ +public abstract class AbstractNavCommand implements NavCommand, UndoableCommand { + + private Envelope oldbbox = null; + + protected ViewportModel model = null; + + private Map map; + + private CoordinateReferenceSystem oldCRS; + + @Override + public void rollback(IProgressMonitor monitor) throws Exception { + if (model == null) { + // what happens if this gets into the wrong stack. For example if it is part of a + // composite command. + return; + } + + boolean oldDeliver = model.eDeliver(); + try { + model.eSetDeliver(false); + if (!CRS.equalsIgnoreMetadata(model.getCRS(), oldCRS)) { + model.setCRS(oldCRS); + } + } finally { + model.eSetDeliver(oldDeliver); + } + model.zoomToBox(oldbbox); + } + + @Override + public void run(IProgressMonitor monitor) throws Exception { + if (model == null) { + // what happens if this gets into the wrong stack. For example if it is part of a + // composite command. + getMap().sendCommandASync(this); + return; + } + oldbbox = model.getBounds(); + oldCRS = model.getCRS(); + runImpl(monitor); + } + + /** + * This where the actual implementation of subclasses should go. + * + * @throws Exception + */ + protected abstract void runImpl(IProgressMonitor monitor) throws Exception; + + /** + * @see org.locationtech.udig.project.internal.command.navigation.NavCommand#setViewportModel(org.locationtech.udig.project.ViewportModelControl) + */ + @Override + public void setViewportModel(ViewportModel model) { + this.model = model; + } + + /** + * @see org.locationtech.udig.project.command.MapCommand#setMap(IMap) + * @uml.property name="map" + */ + @Override + public void setMap(IMap map) { + this.map = (Map) map; + } + + /** + * @see org.locationtech.udig.project.command.MapCommand#getMap() + * @uml.property name="map" + */ + @Override + public Map getMap() { + return map; + } + +} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/NavComposite.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/NavComposite.java similarity index 98% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/NavComposite.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/NavComposite.java index 73d00698fd..f140a52501 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/NavComposite.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/NavComposite.java @@ -7,7 +7,7 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.command.navigation; +package org.locationtech.udig.project.command.navigation; import java.util.Iterator; import java.util.List; diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/PanCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/PanCommand.java similarity index 80% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/PanCommand.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/PanCommand.java index 86a532e73b..de301cb495 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/PanCommand.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/PanCommand.java @@ -7,9 +7,8 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.command.navigation; +package org.locationtech.udig.project.command.navigation; -import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.command.NavCommand; import org.locationtech.udig.project.internal.Messages; @@ -57,8 +56,9 @@ public PanCommand( double worldx, double worldy ) { } /** - * @see org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand#runImpl() + * @see org.locationtech.udig.project.command.navigation.AbstractNavCommand#runImpl() */ + @Override protected void runImpl( IProgressMonitor monitor ) throws Exception { if (inPixel) model.panUsingScreenCoords(pixelx, pixely); @@ -66,19 +66,10 @@ protected void runImpl( IProgressMonitor monitor ) throws Exception { model.panUsingWorldCoords(worldx, worldy); } - /** - * @see org.locationtech.udig.project.internal.command.MapCommand#copy() - */ - public MapCommand copy() { - if (inPixel) - return new PanCommand(pixelx, pixely); - - return new PanCommand(worldx, worldy); - } - /** * @see org.locationtech.udig.project.command.MapCommand#getName() */ + @Override public String getName() { return Messages.PanCommand_pan; } diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetBoundsCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetBoundsCommand.java new file mode 100644 index 0000000000..f27e5d4b1f --- /dev/null +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetBoundsCommand.java @@ -0,0 +1,24 @@ +package org.locationtech.udig.project.command.navigation; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.locationtech.jts.geom.Envelope; +import org.locationtech.udig.project.internal.Messages; + +public class SetBoundsCommand extends AbstractNavCommand { + + private Envelope newBounds; + + public SetBoundsCommand(Envelope newBounds) { + this.newBounds = newBounds; + } + + @Override + protected void runImpl(IProgressMonitor monitor) throws Exception { + model.setBounds(newBounds); + } + + @Override + public String getName() { + return Messages.SetBoundsCommand_name; + } +} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/SetScaleCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetScaleCommand.java similarity index 84% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/SetScaleCommand.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetScaleCommand.java index b313a8b7ad..6794934762 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/SetScaleCommand.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetScaleCommand.java @@ -7,13 +7,14 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.commands; +package org.locationtech.udig.project.command.navigation; + +import java.text.MessageFormat; +import java.text.NumberFormat; import org.eclipse.core.runtime.IProgressMonitor; -import org.locationtech.udig.project.command.Command; import org.locationtech.udig.project.command.UndoableCommand; import org.locationtech.udig.project.internal.Messages; -import org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand; import org.locationtech.udig.project.internal.render.ViewportModel; /** @@ -47,7 +48,8 @@ public void rollback(IProgressMonitor monitor) throws Exception { @Override public String getName() { - return Messages.SetScaleCommand_name; + NumberFormat numberFormat = NumberFormat.getIntegerInstance(); + return MessageFormat.format(Messages.SetScaleCommand_name, numberFormat.format(newScale)); } @Override @@ -62,11 +64,6 @@ public void run(IProgressMonitor monitor) throws Exception { } } - @Override - public Command copy() { - return new SetScaleCommand(newScale); - } - @Override protected void runImpl(IProgressMonitor monitor) throws Exception { run(monitor); diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportBBoxCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportBBoxCommand.java new file mode 100644 index 0000000000..c8ceeb82b9 --- /dev/null +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportBBoxCommand.java @@ -0,0 +1,119 @@ +/* uDig - User Friendly Desktop Internet GIS client + * http://udig.refractions.net + * (C) 2004-2012, Refractions Research Inc. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD + * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). + */ +package org.locationtech.udig.project.command.navigation; + +import java.text.MessageFormat; + +import org.locationtech.udig.project.internal.Messages; +import org.locationtech.udig.project.internal.ProjectPlugin; +import org.locationtech.udig.project.internal.render.ViewportModel; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.geotools.geometry.jts.JTS; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.geotools.referencing.CRS; +import org.opengis.referencing.crs.CoordinateReferenceSystem; +import org.opengis.referencing.operation.MathTransform; + +import org.locationtech.jts.geom.Envelope; + +/** + * Sets the viewport's bounding box. The bbox have a positive width and height and must have a + * aspect ratio within 0.0000001 units of the value returned by + * {@linkplain ViewportModel#getViewportAspectRatio()}. + * + * @author jeichar + * @since 0.3 + */ +public class SetViewportBBoxCommand extends AbstractNavCommand { + + private Envelope newbbox = null; + + private CoordinateReferenceSystem crs; + + private boolean forceContainBBoxZoom; + + /** + * Creates a new instance of SetViewportBBoxCommand. The bbox is expected to be the same as the + * viewport model. + * + * @param bbox the new bounding box. The new bbox must have a positive width and height and must + * have a aspect ratio within 0.0000001 units of the value returned by + * {@linkplain ViewportModel#getViewportAspectRatio()}. + * @deprecated Please use a ReferencedEnvelope + */ + public SetViewportBBoxCommand(Envelope bbox) { + this.newbbox = bbox; + if (bbox instanceof ReferencedEnvelope) + crs = ((ReferencedEnvelope) bbox).getCoordinateReferenceSystem(); + } + + /** + * Creates a new instance of SetViewportBBoxCommand. The bbox is expected to be the same as the + * viewport model. + * + * @param bbox the new bounding box. The new bbox must have a positive width and height and must + * have a aspect ratio within 0.0000001 units of the value returned by + * {@linkplain ViewportModel#getViewportAspectRatio()}. + */ + public SetViewportBBoxCommand(ReferencedEnvelope bbox) { + this(bbox, false); + } + + /** + * Sets the bounds of the viewport model to the bounds. The crs parameter indications the crs of + * the provided bounds. The appropriate transformation will take place. + * + * @param bounds the bounds to apply to the viewport model + * @param crs The crs of the provided bounds. + */ + public SetViewportBBoxCommand(Envelope bounds, CoordinateReferenceSystem crs) { + this(new ReferencedEnvelope(bounds, crs)); + } + + public SetViewportBBoxCommand(ReferencedEnvelope bbox, boolean forceContainBBoxZoom) { + this.newbbox = bbox; + crs = bbox.getCoordinateReferenceSystem(); + this.forceContainBBoxZoom = forceContainBBoxZoom; + } + + /** + * @see org.locationtech.udig.project.command.navigation.AbstractNavCommand#runImpl() + */ + @Override + protected void runImpl(IProgressMonitor monitor) { + if (crs != null) { + try { + MathTransform mt = CRS.findMathTransform(crs, model.getCRS(), true); + if (!mt.isIdentity()) { + Envelope transformedBounds = JTS.transform(newbbox, null, mt, 5); + crs = model.getCRS(); + newbbox = transformedBounds; + } + } catch (Exception e) { + ProjectPlugin.log("Error transforming from " + crs.getName() + " to " //$NON-NLS-1$//$NON-NLS-2$ + + model.getCRS().getName(), e); + } + } else { + crs = model.getCRS(); + } + model.setBounds(new ReferencedEnvelope(newbbox, crs), forceContainBBoxZoom); + } + + /** + * @see org.locationtech.udig.project.command.MapCommand#getName() + */ + @Override + public String getName() { + return MessageFormat.format(Messages.SetViewportBBoxCommand_setViewArea, + new Object[] { newbbox }); + } + +} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportCenterCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportCenterCommand.java similarity index 64% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportCenterCommand.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportCenterCommand.java index e6bbcab5c0..e0859e6563 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportCenterCommand.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportCenterCommand.java @@ -7,11 +7,10 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.command.navigation; +package org.locationtech.udig.project.command.navigation; import java.text.MessageFormat; -import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.command.NavCommand; import org.locationtech.udig.project.internal.Messages; import org.locationtech.udig.project.internal.ProjectPlugin; @@ -27,60 +26,58 @@ /** * Sets the center of the viewport. The Coordinate must be in world coordinates. The * {@linkplain ViewportModel#pixelToWorld(int, int)}methods can be used to calculate the value. - * + * * @author jeichar - * @since TODO provide version + * @since 1.2.0 */ public class SetViewportCenterCommand extends AbstractNavCommand implements NavCommand { private Coordinate center; + private CoordinateReferenceSystem crs; + /** * Creates a new instance of SetViewportCenterCommand - * + * * @param center Sets the center of the viewport. The Coordinate must be in world coordinates. */ - public SetViewportCenterCommand( Coordinate center ) { + public SetViewportCenterCommand(Coordinate center) { this(center, null); } - public SetViewportCenterCommand( Coordinate coordinate, CoordinateReferenceSystem crs ) { - center=coordinate; - this.crs=crs; + public SetViewportCenterCommand(Coordinate coordinate, CoordinateReferenceSystem crs) { + center = coordinate; + this.crs = crs; } /** - * @see org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand#runImpl() + * @see org.locationtech.udig.project.command.navigation.AbstractNavCommand#runImpl() */ - protected void runImpl( IProgressMonitor monitor ) throws Exception { + @Override + protected void runImpl(IProgressMonitor monitor) throws Exception { Coordinate newCenter = center; - if( crs!=null ) - newCenter=transform(); + if (crs != null) + newCenter = transform(); model.setCenter(newCenter); } private Coordinate transform() { try { - return JTS.transform(center, new Coordinate(), CRS.findMathTransform(crs, model.getCRS(), true)); + return JTS.transform(center, new Coordinate(), + CRS.findMathTransform(crs, model.getCRS(), true)); } catch (Exception e) { ProjectPlugin.log("", e); //$NON-NLS-1$ return null; - } - } - - /** - * @see org.locationtech.udig.project.internal.command.MapCommand#copy() - */ - public MapCommand copy() { - return new SetViewportCenterCommand(center); + } } /** * @see org.locationtech.udig.project.command.MapCommand#getName() */ + @Override public String getName() { - return MessageFormat.format( - Messages.SetViewportCenterCommand_setViewCenter, new Object[]{center}); + return MessageFormat.format(Messages.SetViewportCenterCommand_setViewCenter, + new Object[] { center }); } } diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportHeight.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportHeight.java similarity index 81% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportHeight.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportHeight.java index a04606fdf5..9064e7e036 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportHeight.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportHeight.java @@ -7,14 +7,12 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.command.navigation; +package org.locationtech.udig.project.command.navigation; import java.text.MessageFormat; -import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.command.NavCommand; import org.locationtech.udig.project.internal.Messages; - import org.eclipse.core.runtime.IProgressMonitor; /** @@ -41,22 +39,17 @@ public SetViewportHeight( double height ) { } /** - * @see org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand#runImpl() + * @see org.locationtech.udig.project.command.navigation.AbstractNavCommand#runImpl() */ + @Override protected void runImpl( IProgressMonitor monitor ) throws Exception { model.setHeight(height); } - /** - * @see org.locationtech.udig.project.internal.command.MapCommand#copy() - */ - public MapCommand copy() { - return new SetViewportHeight(height); - } - /** * @see org.locationtech.udig.project.command.MapCommand#getName() */ + @Override public String getName() { return MessageFormat.format( Messages.SetViewportHeight_setViewHeight, new Object[]{height}); diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportWidth.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportWidth.java similarity index 79% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportWidth.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportWidth.java index 3ad8b4a997..b444cf6d92 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportWidth.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/SetViewportWidth.java @@ -7,14 +7,12 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.command.navigation; +package org.locationtech.udig.project.command.navigation; import java.text.MessageFormat; -import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.command.NavCommand; import org.locationtech.udig.project.internal.Messages; - import org.eclipse.core.runtime.IProgressMonitor; /** @@ -39,22 +37,17 @@ public SetViewportWidth( double width ) { } /** - * @see org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand#runImpl() + * @see org.locationtech.udig.project.command.navigation.AbstractNavCommand#runImpl() */ + @Override protected void runImpl( IProgressMonitor monitor ) throws Exception { model.setWidth(width); } - /** - * @see org.locationtech.udig.project.internal.command.MapCommand#copy() - */ - public MapCommand copy() { - return new SetViewportWidth(width); - } - /** * @see org.locationtech.udig.project.command.MapCommand#getName() */ + @Override public String getName() { return MessageFormat.format( Messages.SetViewportWidth_setViewWidth, new Object[]{width}); diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/ZoomCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/ZoomCommand.java similarity index 81% rename from plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/ZoomCommand.java rename to plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/ZoomCommand.java index a23b9ce3a9..57f468ec22 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/ZoomCommand.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/command/navigation/ZoomCommand.java @@ -7,11 +7,8 @@ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). */ -package org.locationtech.udig.project.internal.command.navigation; +package org.locationtech.udig.project.command.navigation; -import java.awt.Rectangle; - -import org.locationtech.udig.project.command.MapCommand; import org.locationtech.udig.project.internal.Messages; import org.eclipse.core.runtime.IProgressMonitor; @@ -23,9 +20,9 @@ * Increases or decreases the size of the viewport(in world space) by a constant factor, zoom. The * zoom is equal in both directions. The function used is: bbox.height=bbox.height/divisor * bbox.width=bbox.width/divisor - * + * * @author jeichar - * @since TODO provide version + * @since 1.2.0 */ public class ZoomCommand extends AbstractNavCommand { @@ -35,7 +32,7 @@ public class ZoomCommand extends AbstractNavCommand { /** * Creates a new instance of ZoomCommand - * + * * @param zoomfactor the amount to zoom *- *
- * - * @author Jesse - * @since 1.0.0 - */ -public abstract class AbstractNavCommand implements NavCommand { - - private Envelope oldbbox = null; - - protected ViewportModel model = null; - - private Map map; - - private CoordinateReferenceSystem oldCRS; - - /** - * @see org.locationtech.udig.project.internal.command.UndoableCommand#rollback() - */ - public void rollback(IProgressMonitor monitor) throws Exception { - if ( model == null ){ - // what happens if this gets into the wrong stack. For example if it is part of a composite command. - return; - } - - boolean oldDeliver = model.eDeliver(); - try { - model.eSetDeliver(false); - if (!CRS.equalsIgnoreMetadata(model.getCRS(), oldCRS)) { - model.setCRS(oldCRS); - } - } finally { - model.eSetDeliver(oldDeliver); - } - model.zoomToBox(oldbbox); - } - - /** - * @see org.locationtech.udig.project.internal.command.MapCommand#run() - */ - public void run(IProgressMonitor monitor) throws Exception { - if ( model == null ){ - // what happens if this gets into the wrong stack. For example if it is part of a composite command. - getMap().sendCommandASync(this); - return; - } - oldbbox = model.getBounds(); - oldCRS = model.getCRS(); - runImpl(monitor); - } - - /** - * This where the actual implementation of subclasses should go. - * - * @throws Exception - */ - protected abstract void runImpl(IProgressMonitor monitor) throws Exception; - - /** - * @see org.locationtech.udig.project.internal.command.navigation.NavCommand#setViewportModel(org.locationtech.udig.project.ViewportModelControl) - */ - public void setViewportModel(ViewportModel model) { - this.model = model; - } - - /** - * @see org.locationtech.udig.project.command.MapCommand#setMap(IMap) - * @uml.property name="map" - */ - public void setMap(IMap map) { - this.map = (Map) map; - } - - /** - * @see org.locationtech.udig.project.command.MapCommand#getMap() - * @uml.property name="map" - */ - public Map getMap() { - return map; - } - -} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportBBoxCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportBBoxCommand.java deleted file mode 100644 index e082089ff3..0000000000 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/command/navigation/SetViewportBBoxCommand.java +++ /dev/null @@ -1,131 +0,0 @@ -/* uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2004-2012, Refractions Research Inc. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD - * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). - */ -package org.locationtech.udig.project.internal.command.navigation; - -import java.text.MessageFormat; - -import org.locationtech.udig.project.command.MapCommand; -import org.locationtech.udig.project.internal.Messages; -import org.locationtech.udig.project.internal.ProjectPlugin; -import org.locationtech.udig.project.internal.render.ViewportModel; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.geotools.geometry.jts.JTS; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.geotools.referencing.CRS; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; - -import org.locationtech.jts.geom.Envelope; - -/** - * Sets the viewport's bounding box. The bbox have a positive width and height - * and must have a aspect ratio within 0.0000001 units of the value returned by - * {@linkplain ViewportModel#getViewportAspectRatio()}. - * - * @author jeichar - * @since 0.3 - */ -public class SetViewportBBoxCommand extends AbstractNavCommand { - - private Envelope newbbox = null; - - private CoordinateReferenceSystem crs; - - private boolean forceContainBBoxZoom; - - /** - * Creates a new instance of SetViewportBBoxCommand. The bbox is expected to be the same as the viewport model. - * - * @param bbox - * the new bounding box. The new bbox must have a positive width - * and height and must have a aspect ratio within 0.0000001 units - * of the value returned by - * {@linkplain ViewportModel#getViewportAspectRatio()}. - * @deprecated Please use a ReferencedEnvelope - */ - public SetViewportBBoxCommand(Envelope bbox) { - this.newbbox = bbox; - if ( bbox instanceof ReferencedEnvelope ) - crs=((ReferencedEnvelope)bbox).getCoordinateReferenceSystem(); - } - - /** - * Creates a new instance of SetViewportBBoxCommand. The bbox is expected to be the same as the viewport model. - * - * @param bbox - * the new bounding box. The new bbox must have a positive width - * and height and must have a aspect ratio within 0.0000001 units - * of the value returned by - * {@linkplain ViewportModel#getViewportAspectRatio()}. - */ - public SetViewportBBoxCommand(ReferencedEnvelope bbox) { - this(bbox,false); - } - - /** - * Sets the bounds of the viewport model to the bounds. The crs parameter indications the crs of - * the provided bounds. The appropriate transformation will take place. - * - * @param bounds the bounds to apply to the viewport model - * @param crs The crs of the provided bounds. - */ - public SetViewportBBoxCommand(Envelope bounds, CoordinateReferenceSystem crs) { - this(new ReferencedEnvelope(bounds,crs)); - } - - public SetViewportBBoxCommand(ReferencedEnvelope bbox, boolean forceContainBBoxZoom) { - this.newbbox = bbox; - crs=((ReferencedEnvelope)bbox).getCoordinateReferenceSystem(); - this.forceContainBBoxZoom = forceContainBBoxZoom; - } - - /** - * @see org.locationtech.udig.project.internal.command.MapCommand#copy() - */ - public MapCommand copy() { - return new SetViewportBBoxCommand(newbbox, crs); - } - - /** - * @see org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand#runImpl() - */ - protected void runImpl(IProgressMonitor monitor) { - if (crs != null) { - try { - MathTransform mt = CRS.findMathTransform(crs, model.getCRS(), - true); - if (!mt.isIdentity()) { - Envelope transformedBounds = JTS.transform(newbbox, null, - mt, 5); - crs = model.getCRS(); - newbbox = transformedBounds; - } - } catch (Exception e) { - ProjectPlugin - .log( - "Error transforming from " + crs.getName() + " to " + model.getCRS().getName(), e); //$NON-NLS-1$//$NON-NLS-2$ - } - }else{ - crs = model.getCRS(); - } - model.setBounds(new ReferencedEnvelope(newbbox,crs), forceContainBBoxZoom); - } - - /** - * @see org.locationtech.udig.project.command.MapCommand#getName() - */ - public String getName() { - return MessageFormat - .format( - Messages.SetViewportBBoxCommand_setViewArea, new Object[] { newbbox }); - } - -} diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/ChangeCRSCommand.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/ChangeCRSCommand.java index 94d487aaf2..c4d4c522d3 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/ChangeCRSCommand.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/commands/ChangeCRSCommand.java @@ -11,55 +11,41 @@ */ package org.locationtech.udig.project.internal.commands; -import org.locationtech.udig.project.command.Command; import org.locationtech.udig.project.command.UndoableMapCommand; -import org.locationtech.udig.project.internal.Map; +import org.locationtech.udig.project.command.navigation.AbstractNavCommand; import org.locationtech.udig.project.internal.Messages; -import org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand; - import org.eclipse.core.runtime.IProgressMonitor; import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * Change the CRS of a map. - * + * * @author Jesse * @since 1.0.0 */ -public class ChangeCRSCommand extends AbstractNavCommand implements - UndoableMapCommand { - private static final String NAME = Messages.ChangeCRSCommand_name; - private CoordinateReferenceSystem crs; - - /** - * @deprecated - */ - public ChangeCRSCommand(Map map, CoordinateReferenceSystem crs) { - this.crs = crs; - } - - public ChangeCRSCommand( CoordinateReferenceSystem crs) { - this.crs = crs; - } - - /** - * Each command has a name that is displayed with the undo/redo buttons. - * - * @see org.locationtech.udig.project.command.MapCommand#getName() - */ - public String getName() { - return NAME; - } - - @Override - protected void runImpl(IProgressMonitor monitor) throws Exception { - monitor.beginTask(NAME, 1); - model.setCRS(crs); - monitor.done(); - } - - public Command copy() { - return new ChangeCRSCommand(null,crs); - } - +public class ChangeCRSCommand extends AbstractNavCommand implements UndoableMapCommand { + private static final String NAME = Messages.ChangeCRSCommand_name; + + private CoordinateReferenceSystem crs; + + public ChangeCRSCommand(CoordinateReferenceSystem crs) { + this.crs = crs; + } + + /** + * Each command has a name that is displayed with the undo/redo buttons. + * + * @see org.locationtech.udig.project.command.MapCommand#getName() + */ + @Override + public String getName() { + return NAME; + } + + @Override + protected void runImpl(IProgressMonitor monitor) throws Exception { + monitor.beginTask(NAME, 1); + model.setCRS(crs); + monitor.done(); + } } diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/messages.properties b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/messages.properties index 001e6fc194..961608af57 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/messages.properties +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/messages.properties @@ -151,7 +151,9 @@ SetAttributeCommand_setFeatureAttribute = Set Feature Attribute: {0} SetEditFeatureCommand_setCurrentEditFeature = Set Current Edit Feature -SetScaleCommand_name = Set Scale Command +SetScaleCommand_name = Set Scale : {0} + +SetBoundsCommand_name = Set Bounds Command SetViewportBBoxCommand_setViewArea = Set View area: {0} diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/CursorPosition.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/CursorPosition.java index f33a7a9b1a..235b23c997 100644 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/CursorPosition.java +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/CursorPosition.java @@ -17,7 +17,7 @@ import java.util.Locale; import org.locationtech.udig.project.command.Command; -import org.locationtech.udig.project.internal.command.navigation.SetViewportCenterCommand; +import org.locationtech.udig.project.command.navigation.SetViewportCenterCommand; import org.locationtech.udig.project.ui.render.displayAdapter.MapMouseEvent; import org.locationtech.udig.project.ui.tool.AbstractTool; import org.locationtech.udig.project.ui.tool.IToolContext; diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/FixedScalePan.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/FixedScalePan.java deleted file mode 100644 index a1c21a3a11..0000000000 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/FixedScalePan.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2008, Refractions Research Inc. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD - * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). - * - */ -package org.locationtech.udig.tools.internal; - -import java.awt.Point; - -import org.locationtech.udig.project.IMap; -import org.locationtech.udig.project.command.Command; -import org.locationtech.udig.project.command.NavCommand; -import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand; -import org.locationtech.udig.project.internal.render.ViewportModel; -import org.locationtech.udig.project.ui.internal.commands.draw.TranslateCommand; -import org.locationtech.udig.project.ui.render.displayAdapter.MapMouseEvent; -import org.locationtech.udig.project.ui.render.displayAdapter.ViewportPane; -import org.locationtech.udig.project.ui.tool.AbstractModalTool; -import org.locationtech.udig.project.ui.tool.ModalTool; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.geotools.geometry.jts.ReferencedEnvelope; - -import org.locationtech.jts.geom.Coordinate; -import org.locationtech.jts.geom.Envelope; - - -/** - * This tool is supposed to be a fixed scale zoom tool; although - * it currently doesn't do that properly. - * - * @author Emily Gouge - * @since 1.2.0 - * @deprecated PanTool with Tool Options now covers this case - */ -public class FixedScalePan extends AbstractModalTool implements ModalTool { - private boolean dragging=false; - private Point start=null; - private ReferencedEnvelope startbounds = null; - - TranslateCommand command; - /** - * Creates an new instance of Pan - */ - public FixedScalePan() { - super(MOUSE | MOTION); - } - - /** - * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseDragged(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) - */ - public void mouseDragged(MapMouseEvent e) { - if (dragging) { - command.setTranslation(e.x- start.x, e.y - start.y); - context.getViewportPane().repaint(); - } - } - - /** - * @see org.locationtech.udig.project.ui.tool.AbstractTool#mousePressed(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) - */ - public void mousePressed(MapMouseEvent e) { - - if (validModifierButtonCombo(e)) { - ((ViewportPane)context.getMapDisplay()).enableDrawCommands(false); - dragging = true; - start = e.getPoint(); - startbounds = new ReferencedEnvelope(context.getViewportModel().getBounds()); - command=context.getDrawFactory().createTranslateCommand(0,0); - context.sendASyncCommand(command); - } - } - - /** - * Returns true if the combination of buttons and modifiers are legal to execute the pan. - *- * This version returns true if button 1 is down and no modifiers - *
- * @param e - * @return - */ - protected boolean validModifierButtonCombo(MapMouseEvent e) { - return e.buttons== MapMouseEvent.BUTTON1 - && !(e.modifiersDown()); - } - - /** - * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseReleased(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) - */ - public void mouseReleased(MapMouseEvent e) { - if (dragging) { - - ((ViewportPane)context.getMapDisplay()).enableDrawCommands(true); - - //update translation - command.setTranslation(e.x- start.x, e.y - start.y); - context.getViewportPane().repaint(); - - //compute new offset - Point end=e.getPoint(); - - int deltax = (end.x - start.x); - double deltaxworld = ( getContext().getViewportModel().getWidth() / getContext().getMapDisplay().getWidth() ) * deltax; - - int deltay = end.y - start.y; - double deltayworld = ( getContext().getViewportModel().getHeight() / getContext().getMapDisplay().getHeight() ) * deltay; - - Coordinate center = startbounds.centre(); - final Coordinate newc = new Coordinate(center.x - deltaxworld, center.y + deltayworld); - - double dw = getContext().getViewportModel().getBounds().getWidth() / 2; - double dh = getContext().getViewportModel().getBounds().getHeight() / 2; - - final Envelope newbounds = new Envelope(newc.x - dw, newc.x + dw, newc.y - dh, newc.y + dh); - -// double currentscale = context.getViewportModel().getBounds().getWidth() / context.getMapDisplay().getWidth(); -// double newscale = newbounds.getWidth() / context.getMapDisplay().getWidth(); - -// if (currentscale != newscale){ -// System.out.println("scale changed; should reload." ); -// System.out.println("current scale:" + currentscale); -// System.out.println("aaaanew scale:" + newscale); -// } - - //compute new bbox for - NavCommand setFinal = new AbstractNavCommand(){ - - @Override - protected void runImpl( IProgressMonitor monitor ) throws Exception { - model.setBounds(newbounds); - } - - - public Command copy() { - return null; - } - - - public String getName() { - return "Fixed Scale Pan"; //$NON-NLS-1$ - } - }; - - ((ViewportPane) getContext().getMapDisplay()).update(); - context.sendASyncCommand(new PanAndInvalidate(setFinal, command)); - - dragging = false; -// System.out.println("pan done."); - } - } - /** - * @see org.locationtech.udig.project.ui.tool.Tool#dispose() - */ - public void dispose() { - super.dispose(); - } - - /** - * Executes the specified pan command, and only after it is executed, expires the last translate command - */ - private class PanAndInvalidate implements Command, NavCommand { - - private NavCommand command; - private TranslateCommand expire; - - PanAndInvalidate(NavCommand command, TranslateCommand expire) { - this.command = command; - this.expire = expire; - } - - public Command copy() { - return new PanAndInvalidate(command, expire); - } - - public String getName() { - return "PanAndDiscard"; //$NON-NLS-1$ - } - - public void run( IProgressMonitor monitor ) throws Exception { - //first we need to expire the current translation - expire.setValid(false); - - //then we can draw - command.run(monitor); - } - - public void setViewportModel( ViewportModel model ) { - command.setViewportModel(model); - } - - public Map getMap() { - return command.getMap(); - } - - public void setMap( IMap map ) { - command.setMap(map); - } - - public void rollback( IProgressMonitor monitor ) throws Exception { - command.rollback(monitor); - } - - } -} diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/InvalidateCommand.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/InvalidateCommand.java deleted file mode 100644 index 731faf0825..0000000000 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/InvalidateCommand.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2012, Refractions Research Inc. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD - * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). - */ -package org.locationtech.udig.tools.internal; - -import java.awt.Rectangle; - -import org.locationtech.udig.project.command.MapCommand; -import org.locationtech.udig.project.ui.commands.AbstractDrawCommand; -import org.locationtech.udig.project.ui.commands.IDrawCommand; -import org.locationtech.udig.project.ui.commands.TransformDrawCommand; - -import org.eclipse.core.runtime.IProgressMonitor; - -/** - * @author jesse - */ -public class InvalidateCommand extends AbstractDrawCommand implements MapCommand, IDrawCommand { - - private TransformDrawCommand m_toInvalidate; - - public InvalidateCommand(TransformDrawCommand command) { - m_toInvalidate = command; - } - - public void run(IProgressMonitor monitor) throws Exception { - m_toInvalidate.setValid(false); - } - - public Rectangle getValidArea() { - return null; - } - -} diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/NavigationUpdateThread.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/NavigationUpdateThread.java index b476f32112..637767a838 100644 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/NavigationUpdateThread.java +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/NavigationUpdateThread.java @@ -13,9 +13,9 @@ import java.util.ArrayList; import org.locationtech.udig.project.command.NavCommand; -import org.locationtech.udig.project.internal.command.navigation.NavComposite; -import org.locationtech.udig.project.internal.command.navigation.PanCommand; -import org.locationtech.udig.project.internal.command.navigation.ZoomCommand; +import org.locationtech.udig.project.command.navigation.NavComposite; +import org.locationtech.udig.project.command.navigation.PanCommand; +import org.locationtech.udig.project.command.navigation.ZoomCommand; import org.locationtech.udig.project.ui.commands.TransformDrawCommand; import org.locationtech.udig.project.ui.tool.IToolContext; diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Pan.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Pan.java index e392ad8445..9549e897e3 100644 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Pan.java +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Pan.java @@ -13,19 +13,14 @@ import java.awt.Point; -import org.locationtech.udig.project.IMap; -import org.locationtech.udig.project.command.Command; import org.locationtech.udig.project.command.NavCommand; -import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.command.navigation.PanCommand; -import org.locationtech.udig.project.internal.render.ViewportModel; +import org.locationtech.udig.project.command.navigation.PanCommand; import org.locationtech.udig.project.ui.internal.commands.draw.TranslateCommand; import org.locationtech.udig.project.ui.render.displayAdapter.MapMouseEvent; import org.locationtech.udig.project.ui.render.displayAdapter.ViewportPane; import org.locationtech.udig.project.ui.tool.AbstractModalTool; import org.locationtech.udig.project.ui.tool.ModalTool; - -import org.eclipse.core.runtime.IProgressMonitor; +import org.locationtech.udig.tools.internal.commands.PanAndInvalidate; /** @@ -50,6 +45,7 @@ public Pan() { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseDragged(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseDragged(MapMouseEvent e) { if (dragging) { command.setTranslation(e.x- start.x, e.y - start.y); @@ -60,6 +56,7 @@ public void mouseDragged(MapMouseEvent e) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mousePressed(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mousePressed(MapMouseEvent e) { if (validModifierButtonCombo(e)) { @@ -87,6 +84,7 @@ protected boolean validModifierButtonCombo(MapMouseEvent e) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseReleased(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseReleased(MapMouseEvent e) { if (dragging) { ((ViewportPane)context.getMapDisplay()).enableDrawCommands(true); @@ -106,56 +104,8 @@ public void mouseReleased(MapMouseEvent e) { /** * @see org.locationtech.udig.project.ui.tool.Tool#dispose() */ + @Override public void dispose() { super.dispose(); } - - /** - * Executes the specified pan command, and only after it is executed, expires the last translate command - */ - private class PanAndInvalidate implements Command, NavCommand { - - private NavCommand command; - private TranslateCommand expire; - - PanAndInvalidate(NavCommand command, TranslateCommand expire) { - this.command = command; - this.expire = expire; - } - - public Command copy() { - return new PanAndInvalidate(command, expire); - } - - public String getName() { - return "PanAndDiscard"; - } - - public void run( IProgressMonitor monitor ) throws Exception { - //we need to expire the translate command first otherwise - //the image gets drawn in the wrong spot the first time - // and we see weird affects - expire.setValid(false); - - command.run(monitor); - - } - - public void setViewportModel( ViewportModel model ) { - command.setViewportModel(model); - } - - public Map getMap() { - return command.getMap(); - } - - public void setMap( IMap map ) { - command.setMap(map); - } - - public void rollback( IProgressMonitor monitor ) throws Exception { - command.rollback(monitor); - } - - } } diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/PanTool.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/PanTool.java index aabf83b334..a640bb8d73 100644 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/PanTool.java +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/PanTool.java @@ -13,12 +13,9 @@ import java.awt.Point; -import org.locationtech.udig.project.IMap; -import org.locationtech.udig.project.command.Command; import org.locationtech.udig.project.command.NavCommand; -import org.locationtech.udig.project.internal.Map; -import org.locationtech.udig.project.internal.command.navigation.AbstractNavCommand; -import org.locationtech.udig.project.internal.command.navigation.PanCommand; +import org.locationtech.udig.project.command.navigation.PanCommand; +import org.locationtech.udig.project.command.navigation.SetBoundsCommand; import org.locationtech.udig.project.internal.render.ViewportModel; import org.locationtech.udig.project.internal.render.impl.ViewportModelImpl; import org.locationtech.udig.project.ui.internal.commands.draw.TranslateCommand; @@ -27,8 +24,7 @@ import org.locationtech.udig.project.ui.tool.AbstractModalTool; import org.locationtech.udig.project.ui.tool.ModalTool; import org.locationtech.udig.project.ui.tool.options.ToolOptionContributionItem; - -import org.eclipse.core.runtime.IProgressMonitor; +import org.locationtech.udig.tools.internal.commands.PanAndInvalidate; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; @@ -47,24 +43,25 @@ * preferences. ** There are three strateies avaialble {@link Pan}, {@link Scroll}, {@link FixedScale}. - * + * * @author Jesse Eichar * @version $Revision: 1.9 $ */ public class PanTool extends AbstractModalTool implements ModalTool { public static class OptionContribtionItem extends ToolOptionContributionItem { + @Override public IPreferenceStore fillFields( Composite parent ) { Button check = new Button(parent, SWT.CHECK ); check.setText("Scale"); addField( NavigationToolPreferencePage.SCALE, check ); - + Button tiled = new Button(parent, SWT.CHECK ); tiled.setText("Tiled"); addField( NavigationToolPreferencePage.TILED, tiled ); - + return ToolsPlugin.getDefault().getPreferenceStore(); } - }; + } /** * Delegate used to control how the PanTool functions; configured using Preference. * @author Jody Garnett (LISAsoft) @@ -79,9 +76,10 @@ public void mouseReleased( MapMouseEvent e ) { } public void dispose() { } - }; + } private ScrollStrategy strategy; IPropertyChangeListener prefListener = new IPropertyChangeListener(){ + @Override public void propertyChange( PropertyChangeEvent event ) { String property = event.getProperty(); if( NavigationToolPreferencePage.SCALE.equals( property ) || @@ -112,14 +110,14 @@ else if (tiled){ else { strategy = new Pan(); } - + } /** * Used to recognise a mouse event and pan accodingly. *
* This functionality is overridden by PanMiddleMouse in order to allow the middle mouse button * to provide the Pan functionality for any ModalTool. - * + * * @param e */ protected boolean validModifierButtonCombo( MapMouseEvent e ) { @@ -128,6 +126,7 @@ protected boolean validModifierButtonCombo( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseDragged(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseDragged( MapMouseEvent e ) { strategy.mouseDragged(e); } @@ -135,6 +134,7 @@ public void mouseDragged( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mousePressed(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mousePressed( MapMouseEvent e ) { strategy.mousePressed(e); } @@ -142,12 +142,14 @@ public void mousePressed( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseReleased(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseReleased( MapMouseEvent e ) { strategy.mouseReleased(e); } /** * @see org.locationtech.udig.project.ui.tool.Tool#dispose() */ + @Override public void dispose() { if (strategy != null) { strategy.dispose(); @@ -156,57 +158,12 @@ public void dispose() { super.dispose(); } - /** - * Executes the specified pan command, and only after it is executed, expires the last translate - * command - */ - private class PanAndInvalidate implements Command, NavCommand { - private NavCommand command; - private TranslateCommand expire; - PanAndInvalidate( NavCommand command, TranslateCommand expire ) { - this.command = command; - this.expire = expire; - } - - public Command copy() { - return new PanAndInvalidate(command, expire); - } - - public String getName() { - return "PanAndDiscard"; - } - - public void run( IProgressMonitor monitor ) throws Exception { - // we need to expire the translate command first otherwise - // the image gets drawn in the wrong spot the first time - // and we see weird affects - expire.setValid(false); - - command.run(monitor); - } - - public void setViewportModel( ViewportModel model ) { - command.setViewportModel(model); - } - - public Map getMap() { - return command.getMap(); - } - - public void setMap( IMap map ) { - command.setMap(map); - } - - public void rollback( IProgressMonitor monitor ) throws Exception { - command.rollback(monitor); - } - } - /** Basic Pan Functionality for MapViewport */ public class Pan extends ScrollStrategy { private boolean dragging = false; private Point start = null; private TranslateCommand command; + @Override public void mouseDragged( MapMouseEvent e ) { if (dragging) { command.setTranslation(e.x - start.x, e.y - start.y); @@ -217,6 +174,7 @@ public void mouseDragged( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mousePressed(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mousePressed( MapMouseEvent e ) { if (validModifierButtonCombo(e)) { ((ViewportPane) context.getMapDisplay()).enableDrawCommands(false); @@ -230,6 +188,7 @@ public void mousePressed( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseReleased(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseReleased( MapMouseEvent e ) { if (dragging) { ((ViewportPane) context.getMapDisplay()).enableDrawCommands(true); @@ -270,6 +229,7 @@ class Scroll extends ScrollStrategy { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseDragged(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseDragged( MapMouseEvent e ) { if (dragging) { org.eclipse.swt.graphics.Point p = Display.getCurrent().map( @@ -297,6 +257,7 @@ public void mouseDragged( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mousePressed(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mousePressed( MapMouseEvent e ) { if (validModifierButtonCombo(e)) { ((ViewportPane) context.getMapDisplay()).enableDrawCommands(false); @@ -306,6 +267,7 @@ public void mousePressed( MapMouseEvent e ) { .map((Canvas) context.getViewportPane(), null, e.x, e.y); } } + @Override public void mouseReleased( MapMouseEvent e ) { if (dragging) { @@ -337,6 +299,7 @@ public void mouseReleased( MapMouseEvent e ) { ((ViewportModelImpl) context.getViewportModel()).setBounds(newbounds); } } + @Override public void dispose() { super.dispose(); } @@ -351,7 +314,7 @@ public void dispose() { * change resolution as the MapViewport tries to maintain the current scale (as you move north * and south). Emily reports that the strategy does not actually do this properly. *
- * + * * @author Emily Gouge * @since 1.2.0 */ @@ -365,6 +328,7 @@ class FixedScale extends ScrollStrategy { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseDragged(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseDragged( MapMouseEvent e ) { if (dragging) { command.setTranslation(e.x - start.x, e.y - start.y); @@ -375,6 +339,7 @@ public void mouseDragged( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mousePressed(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mousePressed( MapMouseEvent e ) { if (validModifierButtonCombo(e)) { @@ -389,6 +354,7 @@ public void mousePressed( MapMouseEvent e ) { /** * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseReleased(org.locationtech.udig.project.render.displayAdapter.MapMouseEvent) */ + @Override public void mouseReleased( MapMouseEvent e ) { if (dragging) { @@ -430,24 +396,9 @@ public void mouseReleased( MapMouseEvent e ) { // } // compute new bbox for - NavCommand setFinal = new AbstractNavCommand(){ - - @Override - protected void runImpl( IProgressMonitor monitor ) throws Exception { - model.setBounds(newbounds); - } - - public Command copy() { - return null; - } - - public String getName() { - return "Fixed Scale Pan"; //$NON-NLS-1$ - } - }; - ((ViewportPane) getContext().getMapDisplay()).update(); - context.sendASyncCommand(new PanAndInvalidate(setFinal, command)); + context.sendASyncCommand( + new PanAndInvalidate(new SetBoundsCommand(newbounds), command)); dragging = false; // System.out.println("pan done."); @@ -456,6 +407,7 @@ public String getName() { /** * @see org.locationtech.udig.project.ui.tool.Tool#dispose() */ + @Override public void dispose() { super.dispose(); } diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Zoom.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Zoom.java index 51beb7e8b3..45ea827480 100644 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Zoom.java +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/Zoom.java @@ -14,7 +14,7 @@ import java.awt.Point; import java.awt.Rectangle; -import org.locationtech.udig.project.internal.command.navigation.ZoomCommand; +import org.locationtech.udig.project.command.navigation.ZoomCommand; import org.locationtech.udig.project.render.IViewportModel; import org.locationtech.udig.project.ui.commands.DrawCommandFactory; import org.locationtech.udig.project.ui.commands.SelectionBoxCommand; diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/ZoomExtent.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/ZoomExtent.java index b4d3c1659a..2416d5ba05 100644 --- a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/ZoomExtent.java +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/ZoomExtent.java @@ -11,7 +11,7 @@ */ package org.locationtech.udig.tools.internal; -import org.locationtech.udig.project.internal.command.navigation.ZoomExtentCommand; +import org.locationtech.udig.project.command.navigation.ZoomExtentCommand; import org.locationtech.udig.project.ui.tool.AbstractActionTool; import org.locationtech.udig.project.ui.tool.AbstractTool; diff --git a/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/commands/PanAndInvalidate.java b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/commands/PanAndInvalidate.java new file mode 100644 index 0000000000..88a5a052a1 --- /dev/null +++ b/plugins/org.locationtech.udig.tool.default/src/org/locationtech/udig/tools/internal/commands/PanAndInvalidate.java @@ -0,0 +1,53 @@ +package org.locationtech.udig.tools.internal.commands; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.locationtech.udig.project.IMap; +import org.locationtech.udig.project.command.Command; +import org.locationtech.udig.project.command.NavCommand; +import org.locationtech.udig.project.internal.Map; +import org.locationtech.udig.project.internal.render.ViewportModel; +import org.locationtech.udig.project.ui.internal.commands.draw.TranslateCommand; + +/** + * Executes the specified pan command, and only after it is executed, expires the last translate command + */ +public class PanAndInvalidate implements Command, NavCommand { + + private NavCommand command; + private TranslateCommand expire; + + public PanAndInvalidate(NavCommand command, TranslateCommand expire) { + this.command = command; + this.expire = expire; + } + + @Override + public String getName() { + return "PanAndDiscard"; //$NON-NLS-1$ + } + + @Override + public void run( IProgressMonitor monitor ) throws Exception { + //first we need to expire the current translation + expire.setValid(false); + + //then we can draw + command.run(monitor); + } + + @Override + public void setViewportModel( ViewportModel model ) { + command.setViewportModel(model); + } + + @Override + public Map getMap() { + return command.getMap(); + } + + @Override + public void setMap(IMap map) { + command.setMap(map); + } + +} \ No newline at end of file diff --git a/plugins/org.locationtech.udig.tool.edit/src/org/locationtech/udig/tools/edit/enablement/ValidToolDetectionActivator.java b/plugins/org.locationtech.udig.tool.edit/src/org/locationtech/udig/tools/edit/enablement/ValidToolDetectionActivator.java index ea600027b6..7852f9a24d 100644 --- a/plugins/org.locationtech.udig.tool.edit/src/org/locationtech/udig/tools/edit/enablement/ValidToolDetectionActivator.java +++ b/plugins/org.locationtech.udig.tool.edit/src/org/locationtech/udig/tools/edit/enablement/ValidToolDetectionActivator.java @@ -14,6 +14,7 @@ import org.locationtech.udig.project.Interaction; import org.locationtech.udig.project.command.UndoableMapCommand; import org.locationtech.udig.project.internal.EditManager; +import org.locationtech.udig.project.internal.commands.SetApplicabilityCommand; import org.locationtech.udig.project.ui.render.displayAdapter.MapMouseEvent; import org.locationtech.udig.tool.edit.internal.Messages; import org.locationtech.udig.tools.edit.EditPlugin; @@ -85,8 +86,7 @@ public void run() { Messages.ValidToolDetectionActivator_questionTitle, string); if (decision) { - UndoableMapCommand command = handler.getContext().getBasicCommandFactory() - .createSetApplicabilityCommand(layer, Interaction.EDIT, true); + UndoableMapCommand command = new SetApplicabilityCommand(layer, Interaction.EDIT, true); handler.getContext().sendASyncCommand(command); } else { warning[0]=Messages.ValidToolDetectionActivator_warning2; diff --git a/plugins/org.locationtech.udig.tool.select/src/org/locationtech/udig/tool/select/internal/ZoomSelection.java b/plugins/org.locationtech.udig.tool.select/src/org/locationtech/udig/tool/select/internal/ZoomSelection.java index 977d6d5b2b..eb98c7a1c5 100644 --- a/plugins/org.locationtech.udig.tool.select/src/org/locationtech/udig/tool/select/internal/ZoomSelection.java +++ b/plugins/org.locationtech.udig.tool.select/src/org/locationtech/udig/tool/select/internal/ZoomSelection.java @@ -12,7 +12,7 @@ import java.io.IOException; import org.locationtech.udig.project.ILayer; -import org.locationtech.udig.project.internal.command.navigation.SetViewportBBoxCommand; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.render.impl.ScaleUtils; import org.locationtech.udig.project.ui.tool.AbstractActionTool; import org.locationtech.udig.tool.select.SelectPlugin; diff --git a/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/featuremovieview/FeatureMovieView.java b/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/featuremovieview/FeatureMovieView.java index c283f546ff..91bcb1092b 100644 --- a/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/featuremovieview/FeatureMovieView.java +++ b/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/featuremovieview/FeatureMovieView.java @@ -17,7 +17,7 @@ import org.locationtech.udig.project.IMap; import org.locationtech.udig.project.command.UndoableMapCommand; import org.locationtech.udig.project.command.factory.SelectionCommandFactory; -import org.locationtech.udig.project.internal.command.navigation.ZoomCommand; +import org.locationtech.udig.project.command.navigation.ZoomCommand; import org.locationtech.udig.project.internal.commands.selection.SelectCommand; import org.locationtech.udig.project.ui.ApplicationGIS; diff --git a/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/navigationview/NavigationView.java b/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/navigationview/NavigationView.java index 80bc379713..8b47e3cdfb 100644 --- a/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/navigationview/NavigationView.java +++ b/plugins/org.locationtech.udig.tools.jgrass/src/org/locationtech/udig/tools/jgrass/navigationview/NavigationView.java @@ -1,6 +1,6 @@ /* * uDig - User Friendly Desktop Internet GIS client - * (C) HydroloGIS - www.hydrologis.com + * (C) HydroloGIS - www.hydrologis.com * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -81,7 +81,7 @@ import org.locationtech.udig.project.IMapListener; import org.locationtech.udig.project.MapCompositionEvent; import org.locationtech.udig.project.MapEvent; -import org.locationtech.udig.project.command.factory.NavigationCommandFactory; +import org.locationtech.udig.project.command.navigation.SetViewportBBoxCommand; import org.locationtech.udig.project.internal.render.ViewportModel; import org.locationtech.udig.project.ui.ApplicationGIS; import org.locationtech.udig.tools.jgrass.JGrassToolsPlugin; @@ -96,7 +96,7 @@ /** * A navigation view. - * + * * @author Andrea Antonello (www.hydrologis.com) * */ @@ -143,6 +143,7 @@ public NavigationView() { } + @Override public void createPartControl( Composite theparent ) { ScrolledComposite scrolledComposite = new ScrolledComposite(theparent, SWT.H_SCROLL | SWT.V_SCROLL); @@ -235,10 +236,11 @@ public void createPartControl( Composite theparent ) { canvas.setLayoutData(gd2); canvas.addPaintListener(new PaintListener(){ + @Override public void paintControl( PaintEvent e ) { Rectangle canvasBounds = canvas.getBounds(); Rectangle imageBounds = worldImage.getBounds(); - int h = (int) ((float) canvasBounds.width * (float) imageBounds.height / (float) imageBounds.width); + int h = (int) ((float) canvasBounds.width * (float) imageBounds.height / imageBounds.width); e.gc.drawImage(worldImage, 0, 0, imageBounds.width, imageBounds.height, 0, 0, canvasBounds.width, h); IMap activeMap = ApplicationGIS.getActiveMap(); @@ -292,12 +294,12 @@ public void paintControl( PaintEvent e ) { height = 1; } - int x = (int) ((double) canvasBounds.width * west / 360.0); - int y = (int) ((double) h * north / 180.0); - int fw = (int) ((double) canvasBounds.width * width / 360.0); + int x = (int) (canvasBounds.width * west / 360.0); + int y = (int) (h * north / 180.0); + int fw = (int) (canvasBounds.width * width / 360.0); if (fw <= 1) fw = 2; - int fh = (int) ((double) h * height / 180.0); + int fh = (int) (h * height / 180.0); if (fh <= 1) fh = 2; int newy = h - y; @@ -346,12 +348,14 @@ public void paintControl( PaintEvent e ) { countriesCombo.setItems(namesArray); countriesCombo.select(0); countriesCombo.addSelectionListener(new SelectionAdapter(){ + @Override public void widgetSelected( SelectionEvent e ) { int selectionIndex = countriesCombo.getSelectionIndex(); String item = countriesCombo.getItem(selectionIndex); final String file = folderFile.getAbsolutePath() + File.separator + item + ".txt"; IRunnableWithProgress operation = new IRunnableWithProgress(){ + @Override public void run( IProgressMonitor pm ) throws InvocationTargetException, InterruptedException { try { populatePlacesMap(placesMap, file); @@ -371,6 +375,7 @@ public void run( IProgressMonitor pm ) throws InvocationTargetException, Interru addNewButton.setText("+"); addNewButton.setToolTipText("Add a new geonames file (get it at http://download.geonames.org/export/dump/)"); addNewButton.addSelectionListener(new SelectionAdapter(){ + @Override public void widgetSelected( SelectionEvent e ) { FileDialog fileDialog = new FileDialog(countriesCombo.getShell(), SWT.OPEN); fileDialog.setFilterExtensions(new String[]{"*.txt"}); @@ -403,6 +408,7 @@ public void widgetSelected( SelectionEvent e ) { removeButton.setText("-"); removeButton.setToolTipText("Remove a geonames file"); removeButton.addSelectionListener(new SelectionAdapter(){ + @Override public void widgetSelected( SelectionEvent e ) { int selectionIndex = countriesCombo.getSelectionIndex(); String item = countriesCombo.getItem(selectionIndex); @@ -446,6 +452,7 @@ public void widgetSelected( SelectionEvent e ) { searchButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); searchButton.setText("search"); searchButton.addSelectionListener(new SelectionAdapter(){ + @Override public void widgetSelected( SelectionEvent e ) { String text = placesText.getText(); if (text.length() < 3) { @@ -461,7 +468,7 @@ public void widgetSelected( SelectionEvent e ) { matchedList.add(name); } } - String[] matchedArray = (String[]) matchedList.toArray(new String[matchedList.size()]); + String[] matchedArray = matchedList.toArray(new String[matchedList.size()]); Arrays.sort(matchedArray); placesCombo.setItems(matchedArray); placesCombo.select(0); @@ -476,6 +483,7 @@ public void widgetSelected( SelectionEvent e ) { goButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); goButton.setText("go"); goButton.addSelectionListener(new SelectionAdapter(){ + @Override public void widgetSelected( SelectionEvent e ) { IMap map = ApplicationGIS.getActiveMap(); if (map.getMapLayers().size() < 1) { @@ -506,7 +514,7 @@ public void widgetSelected( SelectionEvent e ) { } catch (Exception e1) { e1.printStackTrace(); } - map.sendCommandASync(NavigationCommandFactory.getInstance().createSetViewportBBoxCommand(bounds)); + map.sendCommandASync(new SetViewportBBoxCommand(bounds)); } }); @@ -516,10 +524,12 @@ public void widgetSelected( SelectionEvent e ) { loadShapeButton.setLayoutData(gridData); loadShapeButton.setText("Load all places as feature layer"); loadShapeButton.addSelectionListener(new SelectionAdapter(){ + @Override public void widgetSelected( SelectionEvent e ) { IRunnableWithProgress operation = new IRunnableWithProgress(){ + @Override public void run( IProgressMonitor pm ) throws InvocationTargetException, InterruptedException { try { @@ -595,12 +605,13 @@ private String[] loadGeonamesFiles() { } names.add(name.replaceFirst(".txt", "")); } - String[] namesArray = (String[]) names.toArray(new String[names.size()]); + String[] namesArray = names.toArray(new String[names.size()]); return namesArray; } private void updateData() { Display.getDefault().asyncExec(new Runnable(){ + @Override public void run() { IMap activeMap = ApplicationGIS.getActiveMap(); ViewportModel viewportModel = (ViewportModel) activeMap.getViewportModel(); @@ -623,7 +634,7 @@ public void run() { canvas.redraw(); SortedSet