Index: applications/editors/josm/plugins/wmsplugin/build.xml
===================================================================
--- applications/editors/josm/plugins/wmsplugin/build.xml	(revision 16862)
+++ applications/editors/josm/plugins/wmsplugin/build.xml	(revision 16872)
@@ -1,2 +1,28 @@
+<!--
+** This is a template build file for a JOSM  plugin.
+**
+** Maintaining versions
+** ====================
+** see README.template
+**
+** Usage
+** =====
+** To build it run
+**
+**    > ant  dist
+**
+** To install the generated plugin locally (in your default plugin directory) run
+**
+**    > ant  install
+**
+** To build against the core in ../../core, create a correct manifest and deploy to
+** SVN, run
+**    - set the property commit.message 
+**    - set the property josm.reference.release to lowest JOSM release number this
+**      plugin build is compatible with
+**    > ant  deploy
+**
+**
+-->
 <project name="wmsplugin" default="dist" basedir=".">
     <property name="josm"                   location="../../core/dist/josm-custom.jar"/>
@@ -5,4 +31,7 @@
     <property name="plugin.jar"             value="${plugin.dist.dir}/${ant.project.name}.jar"/>
     <property name="ant.build.javac.target" value="1.5"/>
+	<property name="commit.message"         value="fixing JOSM issue #3186" />
+	<property name="josm.reference.release" value="1914" />
+	
     <target name="init">
         <mkdir dir="${plugin.build.dir}"/>
@@ -16,4 +45,5 @@
     </target>
     <target name="dist" depends="compile,revision">
+    	<echo message="building ${plugin.jar} with version ${version.entry.commit.revision} for JOSM version ${josm.reference.release} "/>
         <copy todir="${plugin.build.dir}/images">
             <fileset dir="images"/>
@@ -26,5 +56,5 @@
                 <attribute name="Plugin-Description" value="Display georeferenced images as background in JOSM (WMS servers, Yahoo, ...)."/>
                 <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/WMSPlugin"/>
-                <attribute name="Plugin-Mainversion" value="1908"/>
+                <attribute name="Plugin-Mainversion" value="${josm.reference.release}"/>
                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
                 <attribute name="de_Plugin-Link" value="http://wiki.openstreetmap.org/wiki/DE:JOSM/Plugins/WMSPlugin"/>
@@ -55,3 +85,55 @@
         <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
     </target>
+	
+	<target name="core-info">
+	        <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">
+	                    <env key="LANG" value="C"/>
+	                    <arg value="info"/>
+	                    <arg value="--xml"/>
+	                    <arg value="../../core"/>
+	        </exec>
+	        <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>
+			<echo>Building against core revision ${coreversion.info.entry.revision} ...</echo>
+			<delete file="core.info.xml" />
+		</target>
+
+		
+		<target name="commit-current">
+			<echo>Commiting the plugin source ...</echo>
+		    <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
+		                    <env key="LANG" value="C"/>
+		                    <arg value="commit"/>
+		                    <arg value="-m &quot;${commit.message}&quot;"/>
+		                    <arg value="."/>
+		    </exec>	    
+		</target>
+
+		
+		<target name="update-current">
+			<echo>Updating basedir ...</echo>
+		    <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
+		                    <env key="LANG" value="C"/>
+		                    <arg value="up"/>
+		                    <arg value="."/>
+		    </exec>	    
+			<echo>Updating ${plugin.jar} ...</echo>
+		    <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
+		                    <env key="LANG" value="C"/>
+		                    <arg value="up"/>
+		                    <arg value="${plugin.jar}"/>
+		    </exec>	    
+		</target>
+		
+		<target name="commit-dist">
+				<echo>Commiting ${plugin.jar} ...</echo>
+			    <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">
+			                    <env key="LANG" value="C"/>
+			                    <arg value="commit"/>
+	                			<arg value="-m &quot;${commit.message}&quot;"/>
+			                    <arg value="${plugin.jar}"/>
+			    </exec>	    
+	   	</target>
+		
+		<target name="deploy" depends="core-info,commit-current,update-current,clean,dist,commit-dist">
+		</target>
 </project>
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/GeorefImage.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/GeorefImage.java	(revision 16862)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/GeorefImage.java	(revision 16872)
@@ -1,5 +1,4 @@
 package wmsplugin;
 
-import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics;
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSAdjustAction.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSAdjustAction.java	(revision 16862)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSAdjustAction.java	(revision 16872)
@@ -3,15 +3,30 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.Component;
 import java.awt.Cursor;
+import java.awt.GridBagLayout;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
+import java.util.List;
+
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.Icon;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.actions.mapmode.MapMode;
 import org.openstreetmap.josm.data.coor.EastNorth;
+import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.gui.MapFrame;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
+import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.tools.GBC;
 import org.openstreetmap.josm.tools.ImageProvider;
-import org.openstreetmap.josm.gui.layer.Layer;
 
 
@@ -20,7 +35,7 @@
 
     GeorefImage selectedImage;
-    WMSLayer selectedLayer;
     boolean mouseDown;
     EastNorth prevEastNorth;
+    private WMSLayer adjustingLayer;
 
     public WMSAdjustAction(MapFrame mapFrame) {
@@ -30,6 +45,23 @@
     }
 
+    
+    
     @Override public void enterMode() {
-        super.enterMode();
+        super.enterMode();       
+        if (!hasWMSLayersToAdjust()) {
+        	warnNoWMSLayers();
+        	return;
+        }
+        List<WMSLayer> wmsLayers = Main.map.mapView.getLayersOfType(WMSLayer.class);
+        if (wmsLayers.size() == 1) {
+        	adjustingLayer = wmsLayers.get(0);
+        } else {
+        	adjustingLayer = (WMSLayer)askAdjustLayer(Main.map.mapView.getLayersOfType(WMSLayer.class));
+        }
+        if (adjustingLayer == null)
+        	return;
+        if (!adjustingLayer.isVisible()) {
+        	adjustingLayer.setVisible(true);
+        }
         Main.map.mapView.addMouseListener(this);
         Main.map.mapView.addMouseMotionListener(this);
@@ -40,4 +72,5 @@
         Main.map.mapView.removeMouseListener(this);
         Main.map.mapView.removeMouseMotionListener(this);
+        adjustingLayer = null;
     }
 
@@ -46,9 +79,7 @@
             return;
 
-        Layer layer=Main.map.mapView.getActiveLayer();
-        if (layer.isVisible() && layer instanceof WMSLayer) {
+        if (adjustingLayer.isVisible()) {
             prevEastNorth=Main.map.mapView.getEastNorth(e.getX(),e.getY());
-            selectedLayer = ((WMSLayer)layer);
-            selectedImage = selectedLayer.findImage(prevEastNorth);
+            selectedImage = adjustingLayer.findImage(prevEastNorth);
             if(selectedImage!=null) {
                 Main.map.mapView.setCursor
@@ -62,5 +93,5 @@
             EastNorth eastNorth=
                     Main.map.mapView.getEastNorth(e.getX(),e.getY());
-            selectedLayer.displace(
+            adjustingLayer.displace(
                 eastNorth.east()-prevEastNorth.east(),
                 eastNorth.north()-prevEastNorth.north()
@@ -76,5 +107,4 @@
         selectedImage = null;
         prevEastNorth = null;
-        selectedLayer = null;
     }
     
@@ -99,3 +129,86 @@
         return (l instanceof WMSLayer) && l.isVisible();
     }
+    
+    /**
+    * the list cell renderer used to render layer list entries
+    * 
+    */
+   static public class LayerListCellRenderer extends DefaultListCellRenderer {
+
+       protected boolean isActiveLayer(Layer layer) {
+           if (Main.map == null)
+               return false;
+           if (Main.map.mapView == null)
+               return false;
+           return Main.map.mapView.getActiveLayer() == layer;
+       }
+
+       @Override
+       public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
+               boolean cellHasFocus) {
+           Layer layer = (Layer) value;
+           JLabel label = (JLabel) super.getListCellRendererComponent(list, layer.getName(), index, isSelected,
+                   cellHasFocus);
+           Icon icon = layer.getIcon();
+           label.setIcon(icon);
+           label.setToolTipText(layer.getToolTipText());
+           return label;
+       }
+   }
+
+   /**
+    * Prompts the user with a list of WMS layers which can be adjusted  
+    * 
+    * @param adjustableLayers the list of adjustable layers 
+    * @return  the selected layer; null, if no layer was selected 
+    */
+   protected Layer askAdjustLayer(List<? extends Layer> adjustableLayers) {
+       JComboBox layerList = new JComboBox();
+       layerList.setRenderer(new LayerListCellRenderer());
+       layerList.setModel(new DefaultComboBoxModel(adjustableLayers.toArray()));
+       layerList.setSelectedIndex(0);
+   
+       JPanel pnl = new JPanel();
+       pnl.setLayout(new GridBagLayout());
+       pnl.add(new JLabel(tr("Please select the WMS layer to adjust.")), GBC.eol());
+       pnl.add(layerList, GBC.eol());
+   
+       int decision = new ExtendedDialog(Main.parent, tr("Select WMS layer"), pnl, new String[] { tr("Start adjusting"),
+           tr("Cancel") }, new String[] { "mapmode/adjustwms", "cancel" }).getValue();
+       if (decision != 1)
+           return null;
+       Layer adjustLayer = (Layer) layerList.getSelectedItem();
+       return adjustLayer;
+   }
+
+   /**
+    * Displays a warning message if there are no WMS layers to adjust 
+    * 
+    */
+   protected void warnNoWMSLayers() {
+       OptionPaneUtil.showMessageDialog(
+    		   Main.parent,
+               tr("There are currently no WMS layer to adjust."),
+               tr("No layers to adjust"), 
+               JOptionPane.WARNING_MESSAGE
+       );
+   }
+   
+   /**
+    * Replies true if there is at least one WMS layer 
+    * 
+    * @return true if there is at least one WMS layer
+    */
+   protected boolean hasWMSLayersToAdjust() {
+	   if (Main.map == null) return false;
+	   if (Main.map.mapView == null) return false;
+	   return ! Main.map.mapView.getLayersOfType(WMSLayer.class).isEmpty();
+   }
+
+
+
+	@Override
+	protected void updateEnabledState() {
+		setEnabled(hasWMSLayersToAdjust());
+	}   
 }
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java	(revision 16862)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java	(revision 16872)
@@ -14,5 +14,4 @@
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
-import java.text.MessageFormat;
 import java.text.NumberFormat;
 import java.util.Locale;
@@ -27,5 +26,4 @@
 import org.openstreetmap.josm.data.coor.EastNorth;
 import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.data.projection.Epsg4326;
 import org.openstreetmap.josm.data.projection.Mercator;
 import org.openstreetmap.josm.gui.MapView;
