Index: applications/editors/josm/plugins/lakewalker/build.xml
===================================================================
--- applications/editors/josm/plugins/lakewalker/build.xml	(revision 15961)
+++ applications/editors/josm/plugins/lakewalker/build.xml	(revision 16586)
@@ -26,5 +26,5 @@
                 <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
                 <attribute name="Plugin-Description" value="Helps vectorizing WMS images." />
-                <attribute name="Plugin-Mainversion" value="1465"/>
+                <attribute name="Plugin-Mainversion" value="1813"/>
                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
             </manifest>
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/Lakewalker.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/Lakewalker.java	(revision 15961)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/Lakewalker.java	(revision 16586)
@@ -3,15 +3,12 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import java.io.BufferedReader;
 import java.io.File;
-import java.util.*;
-
-import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.command.AddCommand;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedList;
+
 import org.openstreetmap.josm.command.Command;
-import org.openstreetmap.josm.command.SequenceCommand;
-import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.gui.progress.ProgressMonitor;
 
 public class Lakewalker {
@@ -94,123 +91,130 @@
      * @param br_lat
      */
-    public ArrayList<double[]> trace(double lat, double lon, double tl_lon, double br_lon, double tl_lat, double br_lat) throws LakewalkerException {
-
-        LakewalkerWMS wms = new LakewalkerWMS(this.resolution, this.tilesize, this.wmslayer, this.workingdir);
-        LakewalkerBBox bbox = new LakewalkerBBox(tl_lat,tl_lon,br_lat,br_lon);
-
-        Boolean detect_loop = false;
-
-        ArrayList<double[]> nodelist = new ArrayList<double[]>();
-
-        int[] xy = geo_to_xy(lat,lon,this.resolution);
-
-        if(!bbox.contains(lat, lon)){
-            throw new LakewalkerException(tr("The starting location was not within the bbox"));
-        }
-
-        int v;
-
-        setStatus(tr("Looking for shoreline..."));
-
-        while(true){
-            double[] geo = xy_to_geo(xy[0],xy[1],this.resolution);
-            if(bbox.contains(geo[0],geo[1])==false){
-                break;
-            }
-
-            v = wms.getPixel(xy[0], xy[1]);
-            if(v > this.threshold){
-                break;
-            }
-
-            int delta_lat = this.dirslat[getDirectionIndex(this.startdir)];
-            int delta_lon = this.dirslon[getDirectionIndex(this.startdir)];
-
-            xy[0] = xy[0]+delta_lon;
-            xy[1] = xy[1]+delta_lat;
-
-        }
-
-        int[] startxy = new int[] {xy[0], xy[1]};
-        double[] startgeo = xy_to_geo(xy[0],xy[1],this.resolution);
-
-        //System.out.printf("Found shore at lat %.4f lon %.4f\n",lat,lon);
-
-        int last_dir = this.getDirectionIndex(this.startdir);
-
-        for(int i = 0; i < this.maxnode; i++){
-
-            // Print a counter
-            if(i % 250 == 0){
-                setStatus(tr("{0} nodes so far...",i));
-                //System.out.println(i+" nodes so far...");
-            }
-
-            // Some variables we need
-            int d;
-            int test_x=0;
-            int test_y=0;
-            int new_dir = 0;
-
-            // Loop through all the directions we can go
-            for(d = 1; d <= this.dirslat.length; d++){
-
-                // Decide which direction we want to look at from this pixel
-                new_dir = (last_dir + d + 4) % 8;
-
-                test_x = xy[0] + this.dirslon[new_dir];
-                test_y = xy[1] + this.dirslat[new_dir];
-
-                double[] geo = xy_to_geo(test_x,test_y,this.resolution);
-
-                if(!bbox.contains(geo[0], geo[1])){
-                    System.out.println("Outside bbox");
-                    break;
-                }
-
-                v = wms.getPixel(test_x, test_y);
-                if(v > this.threshold){
-                    break;
-                }
-
-                if(d == this.dirslat.length-1){
-                    System.out.println("Got stuck");
-                    break;
-                }
-            }
-
-            // Remember this direction
-            last_dir = new_dir;
-
-            // Set the pixel we found as current
-            xy[0] = test_x;
-            xy[1] = test_y;
-
-            // Break the loop if we managed to get back to our starting point
-            if(xy[0] == startxy[0] && xy[1] == startxy[1]){
-                break;
-            }
-
-            // Store this node
-            double[] geo = xy_to_geo(xy[0],xy[1],this.resolution);
-            nodelist.add(geo);
-            //System.out.println("Adding node at "+xy[0]+","+xy[1]+" ("+geo[1]+","+geo[0]+")");
-
-            // Check if we got stuck in a loop
-            double start_proximity = Math.pow((geo[0] - startgeo[0]),2) + Math.pow((geo[1] - startgeo[1]),2);
-
-            if(detect_loop){
-                if(start_proximity < Math.pow(start_radius_small,2)){
-                    System.out.println("Detected loop");
-                    break;
-                }
-            }else{
-                if(start_proximity > Math.pow(start_radius_big,2)){
-                    detect_loop = true;
-                }
-            }
-        }
-
-        return nodelist;
+    public ArrayList<double[]> trace(double lat, double lon, double tl_lon, double br_lon, double tl_lat, double br_lat, ProgressMonitor progressMonitor) throws LakewalkerException {
+
+    	progressMonitor.beginTask(null);
+
+    	try {
+
+    		LakewalkerWMS wms = new LakewalkerWMS(this.resolution, this.tilesize, this.wmslayer, this.workingdir);
+    		LakewalkerBBox bbox = new LakewalkerBBox(tl_lat,tl_lon,br_lat,br_lon);
+
+    		Boolean detect_loop = false;
+
+    		ArrayList<double[]> nodelist = new ArrayList<double[]>();
+
+    		int[] xy = geo_to_xy(lat,lon,this.resolution);
+
+    		if(!bbox.contains(lat, lon)){
+    			throw new LakewalkerException(tr("The starting location was not within the bbox"));
+    		}
+
+    		int v;
+
+    		progressMonitor.indeterminateSubTask(tr("Looking for shoreline..."));
+
+    		while(true){
+    			double[] geo = xy_to_geo(xy[0],xy[1],this.resolution);
+    			if(bbox.contains(geo[0],geo[1])==false){
+    				break;
+    			}
+
+    			v = wms.getPixel(xy[0], xy[1], progressMonitor.createSubTaskMonitor(0, false));
+    			if(v > this.threshold){
+    				break;
+    			}
+
+    			int delta_lat = this.dirslat[getDirectionIndex(this.startdir)];
+    			int delta_lon = this.dirslon[getDirectionIndex(this.startdir)];
+
+    			xy[0] = xy[0]+delta_lon;
+    			xy[1] = xy[1]+delta_lat;
+
+    		}
+
+    		int[] startxy = new int[] {xy[0], xy[1]};
+    		double[] startgeo = xy_to_geo(xy[0],xy[1],this.resolution);
+
+    		//System.out.printf("Found shore at lat %.4f lon %.4f\n",lat,lon);
+
+    		int last_dir = this.getDirectionIndex(this.startdir);
+
+    		for(int i = 0; i < this.maxnode; i++){
+
+    			// Print a counter
+    			if(i % 250 == 0){
+    				progressMonitor.indeterminateSubTask(tr("{0} nodes so far...",i));
+    				//System.out.println(i+" nodes so far...");
+    			}
+
+    			// Some variables we need
+    			int d;
+    			int test_x=0;
+    			int test_y=0;
+    			int new_dir = 0;
+
+    			// Loop through all the directions we can go
+    			for(d = 1; d <= this.dirslat.length; d++){
+
+    				// Decide which direction we want to look at from this pixel
+    				new_dir = (last_dir + d + 4) % 8;
+
+    				test_x = xy[0] + this.dirslon[new_dir];
+    				test_y = xy[1] + this.dirslat[new_dir];
+
+    				double[] geo = xy_to_geo(test_x,test_y,this.resolution);
+
+    				if(!bbox.contains(geo[0], geo[1])){
+    					System.out.println("Outside bbox");
+    					break;
+    				}
+
+    				v = wms.getPixel(test_x, test_y, progressMonitor.createSubTaskMonitor(0, false));
+    				if(v > this.threshold){
+    					break;
+    				}
+
+    				if(d == this.dirslat.length-1){
+    					System.out.println("Got stuck");
+    					break;
+    				}
+    			}
+
+    			// Remember this direction
+    			last_dir = new_dir;
+
+    			// Set the pixel we found as current
+    			xy[0] = test_x;
+    			xy[1] = test_y;
+
+    			// Break the loop if we managed to get back to our starting point
+    			if(xy[0] == startxy[0] && xy[1] == startxy[1]){
+    				break;
+    			}
+
+    			// Store this node
+    			double[] geo = xy_to_geo(xy[0],xy[1],this.resolution);
+    			nodelist.add(geo);
+    			//System.out.println("Adding node at "+xy[0]+","+xy[1]+" ("+geo[1]+","+geo[0]+")");
+
+    			// Check if we got stuck in a loop
+    			double start_proximity = Math.pow((geo[0] - startgeo[0]),2) + Math.pow((geo[1] - startgeo[1]),2);
+
+    			if(detect_loop){
+    				if(start_proximity < Math.pow(start_radius_small,2)){
+    					System.out.println("Detected loop");
+    					break;
+    				}
+    			}else{
+    				if(start_proximity > Math.pow(start_radius_big,2)){
+    					detect_loop = true;
+    				}
+    			}
+    		}
+
+    		return nodelist;
+    	} finally {
+    		progressMonitor.finishTask();
+    	}
     }
 
@@ -431,9 +435,4 @@
     }
 
-    protected void setStatus(String s) {
-      Main.pleaseWaitDlg.currentAction.setText(s);
-      Main.pleaseWaitDlg.repaint();
-    }
-
     /**
      * Class to do checking of whether the point is within our bbox
@@ -468,9 +467,4 @@
         }
     }
-    private void printarr(int[] a){
-        for(int i = 0; i<a.length; i++){
-            System.out.println(i+": "+a[i]);
-        }
-    }
 }
 
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java	(revision 15961)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java	(revision 16586)
@@ -15,5 +15,4 @@
 import java.util.Comparator;
 import java.util.LinkedList;
-import java.util.List;
 
 import javax.swing.JOptionPane;
@@ -26,7 +25,7 @@
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.Node;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
+import org.openstreetmap.josm.gui.progress.ProgressMonitor;
 import org.openstreetmap.josm.tools.ImageProvider;
 import org.openstreetmap.josm.tools.Shortcut;
@@ -152,7 +151,9 @@
         PleaseWaitRunnable lakewalkerTask = new PleaseWaitRunnable(tr("Tracing")){
           @Override protected void realRun() throws SAXException {
-              setStatus(tr("checking cache..."));
+        	  progressMonitor.subTask(tr("checking cache..."));
               cleanupCache();
-              processnodelist(pos, topLeft, botRight, waylen,maxnode,threshold,epsilon,resolution,tilesize,startdir,wmslayer,working_dir);
+              processnodelist(pos, topLeft, botRight, waylen, maxnode, threshold,
+            		  epsilon,resolution,tilesize,startdir,wmslayer, working_dir,
+            		  progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
           }
           @Override protected void finish() {
@@ -171,126 +172,132 @@
   }
 
-  private void processnodelist(LatLon pos, LatLon topLeft, LatLon botRight, int waylen, int maxnode, int threshold, double epsilon, int resolution, int tilesize, String startdir, String wmslayer, File workingdir){
-
-    ArrayList<double[]> nodelist = new ArrayList<double[]>();
-
-    Lakewalker lw = new Lakewalker(waylen,maxnode,threshold,epsilon,resolution,tilesize,startdir,wmslayer,workingdir);
-    try {
-        nodelist = lw.trace(pos.lat(),pos.lon(),topLeft.lon(),botRight.lon(),topLeft.lat(),botRight.lat());
-    } catch(LakewalkerException e){
-        System.out.println(e.getError());
-    }
-
-    System.out.println(nodelist.size()+" nodes generated");
-
-    /**
-     * Run the nodelist through a vertex reduction algorithm
-     */
-
-    setStatus(tr("Running vertex reduction..."));
-
-    nodelist = lw.vertexReduce(nodelist, epsilon);
-
-    //System.out.println("After vertex reduction "+nodelist.size()+" nodes remain.");
-
-    /**
-     * And then through douglas-peucker approximation
-     */
-
-    setStatus(tr("Running Douglas-Peucker approximation..."));
-
-    nodelist = lw.douglasPeucker(nodelist, epsilon, 0);
-
-    //System.out.println("After Douglas-Peucker approximation "+nodelist.size()+" nodes remain.");
-
-    /**
-     * And then through a duplicate node remover
-     */
-
-    setStatus(tr("Removing duplicate nodes..."));
-
-    nodelist = lw.duplicateNodeRemove(nodelist);
-
-    //System.out.println("After removing duplicate nodes, "+nodelist.size()+" nodes remain.");
-
-
-    // if for some reason (image loading failed, ...) nodelist is empty, no more processing required.
-    if (nodelist.size() == 0) {
-        return;
-    }
-
-    /**
-     * Turn the arraylist into osm nodes
-     */
-
-    Way way = new Way();
-    Node n = null;
-    Node fn = null;
-
-    double eastOffset = Main.pref.getDouble(LakewalkerPreferences.PREF_EAST_OFFSET, 0.0);
-    double northOffset = Main.pref.getDouble(LakewalkerPreferences.PREF_NORTH_OFFSET, 0.0);
-
-    int nodesinway = 0;
-
-    for(int i = 0; i< nodelist.size(); i++){
-        if (cancel) {
-            return;
-        }
-
-        try {
-          LatLon ll = new LatLon(nodelist.get(i)[0]+northOffset, nodelist.get(i)[1]+eastOffset);
-          n = new Node(ll);
-          if(fn==null){
-            fn = n;
-          }
-          commands.add(new AddCommand(n));
-
-        } catch (Exception ex) {
-        }
-
-        way.nodes.add(n);
-
-        if(nodesinway > Main.pref.getInteger(LakewalkerPreferences.PREF_MAX_SEG, 500)){
-            String waytype = Main.pref.get(LakewalkerPreferences.PREF_WAYTYPE, "water");
-
-            if(!waytype.equals("none")){
-              way.put("natural",waytype);
-            }
-
-            way.put("source", Main.pref.get(LakewalkerPreferences.PREF_SOURCE, "Landsat"));
-            commands.add(new AddCommand(way));
-
-            way = new Way();
-
-            way.nodes.add(n);
-
-            nodesinway = 0;
-        }
-        nodesinway++;
-    }
-
-
-    String waytype = Main.pref.get(LakewalkerPreferences.PREF_WAYTYPE, "water");
-
-    if(!waytype.equals("none")){
-      way.put("natural",waytype);
-    }
-
-    way.put("source", Main.pref.get(LakewalkerPreferences.PREF_SOURCE, "Landsat"));
-
-    way.nodes.add(fn);
-
-    commands.add(new AddCommand(way));
-
-    if (!commands.isEmpty()) {
-        Main.main.undoRedo.add(new SequenceCommand(tr("Lakewalker trace"), commands));
-        Main.ds.setSelected(ways);
-    } else {
-      System.out.println("Failed");
-    }
-
-    commands = new LinkedList<Command>();
-    ways = new ArrayList<Way>();
-
+  private void processnodelist(LatLon pos, LatLon topLeft, LatLon botRight, int waylen, int maxnode, int threshold, double epsilon, int resolution, int tilesize, String startdir, String wmslayer, File workingdir, ProgressMonitor progressMonitor){
+	  progressMonitor.beginTask(null, 3);
+	  try {
+		  ArrayList<double[]> nodelist = new ArrayList<double[]>();
+
+		  Lakewalker lw = new Lakewalker(waylen,maxnode,threshold,epsilon,resolution,tilesize,startdir,wmslayer,workingdir);
+		  try {
+			  nodelist = lw.trace(pos.lat(),pos.lon(),topLeft.lon(),botRight.lon(),topLeft.lat(),botRight.lat(),
+					  progressMonitor.createSubTaskMonitor(1, false));
+		  } catch(LakewalkerException e){
+			  System.out.println(e.getError());
+		  }
+
+		  System.out.println(nodelist.size()+" nodes generated");
+
+		  /**
+		   * Run the nodelist through a vertex reduction algorithm
+		   */
+
+		  progressMonitor.subTask(tr("Running vertex reduction..."));
+
+		  nodelist = lw.vertexReduce(nodelist, epsilon);
+
+		  //System.out.println("After vertex reduction "+nodelist.size()+" nodes remain.");
+
+		  /**
+		   * And then through douglas-peucker approximation
+		   */
+
+		  progressMonitor.worked(1);
+		  progressMonitor.subTask(tr("Running Douglas-Peucker approximation..."));
+
+		  nodelist = lw.douglasPeucker(nodelist, epsilon, 0);
+
+		  //System.out.println("After Douglas-Peucker approximation "+nodelist.size()+" nodes remain.");
+
+		  /**
+		   * And then through a duplicate node remover
+		   */
+
+		  progressMonitor.worked(1);
+		  progressMonitor.subTask(tr("Removing duplicate nodes..."));
+
+		  nodelist = lw.duplicateNodeRemove(nodelist);
+
+		  //System.out.println("After removing duplicate nodes, "+nodelist.size()+" nodes remain.");
+
+
+		  // if for some reason (image loading failed, ...) nodelist is empty, no more processing required.
+		  if (nodelist.size() == 0) {
+			  return;
+		  }
+
+		  /**
+		   * Turn the arraylist into osm nodes
+		   */
+
+		  Way way = new Way();
+		  Node n = null;
+		  Node fn = null;
+
+		  double eastOffset = Main.pref.getDouble(LakewalkerPreferences.PREF_EAST_OFFSET, 0.0);
+		  double northOffset = Main.pref.getDouble(LakewalkerPreferences.PREF_NORTH_OFFSET, 0.0);
+
+		  int nodesinway = 0;
+
+		  for(int i = 0; i< nodelist.size(); i++){
+			  if (cancel) {
+				  return;
+			  }
+
+			  try {
+				  LatLon ll = new LatLon(nodelist.get(i)[0]+northOffset, nodelist.get(i)[1]+eastOffset);
+				  n = new Node(ll);
+				  if(fn==null){
+					  fn = n;
+				  }
+				  commands.add(new AddCommand(n));
+
+			  } catch (Exception ex) {
+			  }
+
+			  way.nodes.add(n);
+
+			  if(nodesinway > Main.pref.getInteger(LakewalkerPreferences.PREF_MAX_SEG, 500)){
+				  String waytype = Main.pref.get(LakewalkerPreferences.PREF_WAYTYPE, "water");
+
+				  if(!waytype.equals("none")){
+					  way.put("natural",waytype);
+				  }
+
+				  way.put("source", Main.pref.get(LakewalkerPreferences.PREF_SOURCE, "Landsat"));
+				  commands.add(new AddCommand(way));
+
+				  way = new Way();
+
+				  way.nodes.add(n);
+
+				  nodesinway = 0;
+			  }
+			  nodesinway++;
+		  }
+
+
+		  String waytype = Main.pref.get(LakewalkerPreferences.PREF_WAYTYPE, "water");
+
+		  if(!waytype.equals("none")){
+			  way.put("natural",waytype);
+		  }
+
+		  way.put("source", Main.pref.get(LakewalkerPreferences.PREF_SOURCE, "Landsat"));
+
+		  way.nodes.add(fn);
+
+		  commands.add(new AddCommand(way));
+
+		  if (!commands.isEmpty()) {
+			  Main.main.undoRedo.add(new SequenceCommand(tr("Lakewalker trace"), commands));
+			  Main.ds.setSelected(ways);
+		  } else {
+			  System.out.println("Failed");
+		  }
+
+		  commands = new LinkedList<Command>();
+		  ways = new ArrayList<Way>();
+	  } finally {
+		  progressMonitor.finishTask();
+	  }
   }
 
@@ -316,7 +323,3 @@
   public void mouseReleased(MouseEvent e) {
   }
-  protected void setStatus(String s) {
-      Main.pleaseWaitDlg.currentAction.setText(s);
-      Main.pleaseWaitDlg.repaint();
-  }
 }
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerApp.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerApp.java	(revision 15961)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerApp.java	(revision 16586)
@@ -2,5 +2,7 @@
 
 import java.io.File;
-import java.util.*;
+import java.util.ArrayList;
+
+import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
 
 public class LakewalkerApp {
@@ -37,5 +39,5 @@
         Lakewalker lw = new Lakewalker(waylen,maxnode,threshold,dp,resolution,tilesize,startdir,wmslayer,working_dir);
         try {
-            nodelist = lw.trace(lat,lon,leftlon,rightlon,toplat,botlat);
+            nodelist = lw.trace(lat,lon,leftlon,rightlon,toplat,botlat, NullProgressMonitor.INSTANCE);
         } catch(LakewalkerException e){
             System.out.println(e.getError());
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerReader.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerReader.java	(revision 15961)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerReader.java	(revision 16586)
@@ -20,4 +20,5 @@
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.gui.progress.ProgressMonitor;
 
 public class LakewalkerReader {
@@ -29,5 +30,5 @@
     * Read the data
     */
-    public void read(BufferedReader input) {
+    public void read(BufferedReader input, ProgressMonitor progressMonitor) {
         /*
         * Lakewalker will output data it stdout. Each line has a code in
@@ -42,75 +43,79 @@
         */
 
-        Way way = new Way();
-        String line;
-        setStatus("Initializing");
-        double eastOffset = Main.pref.getDouble(LakewalkerPreferences.PREF_EAST_OFFSET, 0.0);
-        double northOffset = Main.pref.getDouble(LakewalkerPreferences.PREF_NORTH_OFFSET, 0.0);
-        char option = ' ';
+    	progressMonitor.beginTask(null);
+    	try {
+    		Way way = new Way();
+    		String line;
+    		progressMonitor.indeterminateSubTask(tr("Initializing"));
+    		double eastOffset = Main.pref.getDouble(LakewalkerPreferences.PREF_EAST_OFFSET, 0.0);
+    		double northOffset = Main.pref.getDouble(LakewalkerPreferences.PREF_NORTH_OFFSET, 0.0);
+    		char option = ' ';
 
-        try {
-            Node n = null;  // The current node being created
-            Node tn = null; // The last node of the previous way
-            Node fn = null; // Node to hold the first node in the trace
+    		try {
+    			Node n = null;  // The current node being created
+    			Node tn = null; // The last node of the previous way
+    			Node fn = null; // Node to hold the first node in the trace
 
-            while ((line = input.readLine()) != null) {
-                if (cancel)
-                    return;
-                System.out.println(line);
-                option = line.charAt(0);
-                switch (option) {
-                case 'n':
-                    String[] tokens = line.split(" ");
+    			while ((line = input.readLine()) != null) {
+    				if (cancel)
+    					return;
+    				System.out.println(line);
+    				option = line.charAt(0);
+    				switch (option) {
+    				case 'n':
+    					String[] tokens = line.split(" ");
 
-                    if(tn==null){
-                        try {
-                            LatLon ll = new LatLon(Double.parseDouble(tokens[1])+northOffset,
-                            Double.parseDouble(tokens[2])+eastOffset);
-                            n = new Node(ll);
-                            if(fn==null)
-                                fn = n;
-                            commands.add(new AddCommand(n));
-                        }
-                        catch (Exception ex) {}
-                    } else {
-                        // If there is a last node, and this node has the same coordinates
-                        // then we substitute for the previous node
-                        n = tn;
-                        tn = null;
-                    }
-                    way.nodes.add(n);
-                    break;
-                case 's':
-                    setStatus(line.substring(2));
-                    break;
-                case 'x':
-                    String waytype = Main.pref.get(LakewalkerPreferences.PREF_WAYTYPE, "water");
+    					if(tn==null){
+    						try {
+    							LatLon ll = new LatLon(Double.parseDouble(tokens[1])+northOffset,
+    									Double.parseDouble(tokens[2])+eastOffset);
+    							n = new Node(ll);
+    							if(fn==null)
+    								fn = n;
+    							commands.add(new AddCommand(n));
+    						}
+    						catch (Exception ex) {}
+    					} else {
+    						// If there is a last node, and this node has the same coordinates
+    						// then we substitute for the previous node
+    						n = tn;
+    						tn = null;
+    					}
+    					way.nodes.add(n);
+    					break;
+    				case 's':
+    					progressMonitor.indeterminateSubTask(line.substring(2));
+    					break;
+    				case 'x':
+    					String waytype = Main.pref.get(LakewalkerPreferences.PREF_WAYTYPE, "water");
 
-                    if(!waytype.equals("none"))
-                        way.put("natural",waytype);
-                    way.put("source", Main.pref.get(LakewalkerPreferences.PREF_SOURCE, "Landsat"));
-                    commands.add(new AddCommand(way));
-                    break;
-                case 't':
-                    way = new Way();
-                    tn = n;
-                    break;
-                case 'e':
-                    String error = line.substring(2);
-                    cancel = true;
-                    break;
-                }
-            }
-            input.close();
+    					if(!waytype.equals("none"))
+    						way.put("natural",waytype);
+    					way.put("source", Main.pref.get(LakewalkerPreferences.PREF_SOURCE, "Landsat"));
+    					commands.add(new AddCommand(way));
+    					break;
+    				case 't':
+    					way = new Way();
+    					tn = n;
+    					break;
+    				case 'e':
+    					cancel = true;
+    					break;
+    				}
+    			}
+    			input.close();
 
-            // Add the start node to the end of the trace to form a closed shape 
-            way.nodes.add(fn);
-        }
-        catch (Exception ex) { }
+    			// Add the start node to the end of the trace to form a closed shape
+    			way.nodes.add(fn);
+    		}
+    		catch (Exception ex) { }
 
-        if (!commands.isEmpty()) {
-            Main.main.undoRedo.add(new SequenceCommand(tr("Lakewalker trace"), commands));
-            Main.ds.setSelected(ways);
-        }
+    		if (!commands.isEmpty()) {
+    			Main.main.undoRedo.add(new SequenceCommand(tr("Lakewalker trace"), commands));
+    			Main.ds.setSelected(ways);
+    		}
+    	} finally {
+    		progressMonitor.finishTask();
+    	}
     }
 
@@ -121,7 +126,3 @@
         cancel = true;
     }
-    protected void setStatus(String s) {
-        Main.pleaseWaitDlg.currentAction.setText(s);
-        Main.pleaseWaitDlg.repaint();
-    }
 }
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerWMS.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerWMS.java	(revision 15961)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerWMS.java	(revision 16586)
@@ -3,16 +3,20 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import org.openstreetmap.josm.Main;
-import java.awt.Image;
-import javax.imageio.*;
-import java.math.*;
-import java.io.*;
-import java.net.*;
 import java.awt.image.BufferedImage;
-import java.awt.*;
-import java.awt.image.*;
-import java.awt.geom.*;
-import java.util.*;
-import java.text.*;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Vector;
+
+import javax.imageio.ImageIO;
+
+import org.openstreetmap.josm.gui.progress.ProgressMonitor;
 
 public class LakewalkerWMS {
@@ -41,115 +45,115 @@
     }
 
-    public BufferedImage getTile(int x, int y) throws LakewalkerException {
-        String status = getStatus();
-        setStatus(tr("Downloading image tile..."));
-
-        String layer = "global_mosaic_base";
-
-        int[] bottom_left_xy = new int[2];
-        bottom_left_xy[0] = floor(x,this.tilesize);
-        bottom_left_xy[1] = floor(y,this.tilesize);
-
-        int[] top_right_xy = new int[2];
-        top_right_xy[0] = (int)bottom_left_xy[0] + this.tilesize;
-        top_right_xy[1] = (int)bottom_left_xy[1] + this.tilesize;
-
-        double[] topright_geo = xy_to_geo(top_right_xy[0],top_right_xy[1],this.resolution);
-        double[] bottomleft_geo = xy_to_geo(bottom_left_xy[0],bottom_left_xy[1],this.resolution);
-
-        String filename = this.wmslayer+"/landsat_"+this.resolution+"_"+this.tilesize+
-            "_xy_"+bottom_left_xy[0]+"_"+bottom_left_xy[1]+".png";
-
-        // The WMS server only understands decimal points using periods, so we need
-        // to convert to a locale that uses that to build the proper URL
-        NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH);
-        DecimalFormat df = (DecimalFormat)nf;
-        df.applyLocalizedPattern("0.000000");
-
-        String urlloc = "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&layers="+layer+
-            "&styles="+wmslayer+"&srs=EPSG:4326&format=image/png"+
-            "&bbox="+df.format(bottomleft_geo[1])+","+df.format(bottomleft_geo[0])+
-            ","+df.format(topright_geo[1])+","+df.format(topright_geo[0])+
-            "&width="+this.tilesize+"&height="+this.tilesize;
-
-        File file = new File(this.working_dir,filename);
-
-        // Calculate the hashmap key
-        String hashkey = Integer.toString(bottom_left_xy[0])+":"+Integer.toString(bottom_left_xy[1]);
-
-        // See if this image is already loaded
-        if(this.image != null){
-            if(this.imagex != bottom_left_xy[0] || this.imagey != bottom_left_xy[1]){
-
-                // Check if this image exists in the hashmap
-                if(this.imageindex.containsKey(hashkey)){
-                    // Store which image we have
-                    this.imagex = bottom_left_xy[0];
-                    this.imagey = bottom_left_xy[1];
-
-                    // Retrieve from cache
-                    this.image = this.images.get(this.imageindex.get(hashkey));
-                    return this.image;
-                } else {
-                    this.image = null;
-                }
-            } else {
-                return this.image;
-            }
-        }
-
-        try {
-            System.out.println("Looking for image in disk cache: "+filename);
-
-            // Read from a file
-            this.image = ImageIO.read(file);
-
-            this.images.add(this.image);
-            this.imageindex.put(hashkey,this.images.size()-1);
-
-        } catch(FileNotFoundException e){
-            System.out.println("Could not find cached image, downloading.");
-        } catch(IOException e){
-            System.out.println(e.getMessage());
-        } catch(Exception e){
-            System.out.println(e.getMessage());
-        }
-
-        if(this.image == null){
-            /**
-             * Try downloading the image
-             */
-            try {
-                System.out.println("Downloading from "+urlloc);
-
-                // Read from a URL
-                URL url = new URL(urlloc);
-                this.image = ImageIO.read(url); // this can return null!
-            } catch(MalformedURLException e){
-                System.out.println(e.getMessage());
-            } catch(IOException e){
-                System.out.println(e.getMessage());
-            } catch(Exception e){
-                System.out.println(e.getMessage());
-            }
-
-            if (this.image != null) {
-                this.images.add(this.image);
-                this.imageindex.put(hashkey,this.images.size()-1);
-
-                this.saveimage(file,this.image);
-            }
-        }
-
-        this.imagex = bottom_left_xy[0];
-        this.imagey = bottom_left_xy[1];
-
-        if(this.image == null){
-            throw new LakewalkerException(tr("Could not acquire image"));
-        }
-
-        setStatus(status);
-
-        return this.image;
+    public BufferedImage getTile(int x, int y, ProgressMonitor progressMonitor) throws LakewalkerException {
+    	progressMonitor.beginTask(tr("Downloading image tile..."));
+    	try {
+    		String layer = "global_mosaic_base";
+
+    		int[] bottom_left_xy = new int[2];
+    		bottom_left_xy[0] = floor(x,this.tilesize);
+    		bottom_left_xy[1] = floor(y,this.tilesize);
+
+    		int[] top_right_xy = new int[2];
+    		top_right_xy[0] = bottom_left_xy[0] + this.tilesize;
+    		top_right_xy[1] = bottom_left_xy[1] + this.tilesize;
+
+    		double[] topright_geo = xy_to_geo(top_right_xy[0],top_right_xy[1],this.resolution);
+    		double[] bottomleft_geo = xy_to_geo(bottom_left_xy[0],bottom_left_xy[1],this.resolution);
+
+    		String filename = this.wmslayer+"/landsat_"+this.resolution+"_"+this.tilesize+
+    		"_xy_"+bottom_left_xy[0]+"_"+bottom_left_xy[1]+".png";
+
+    		// The WMS server only understands decimal points using periods, so we need
+    		// to convert to a locale that uses that to build the proper URL
+    		NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH);
+    		DecimalFormat df = (DecimalFormat)nf;
+    		df.applyLocalizedPattern("0.000000");
+
+    		String urlloc = "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&layers="+layer+
+    		"&styles="+wmslayer+"&srs=EPSG:4326&format=image/png"+
+    		"&bbox="+df.format(bottomleft_geo[1])+","+df.format(bottomleft_geo[0])+
+    		","+df.format(topright_geo[1])+","+df.format(topright_geo[0])+
+    		"&width="+this.tilesize+"&height="+this.tilesize;
+
+    		File file = new File(this.working_dir,filename);
+
+    		// Calculate the hashmap key
+    		String hashkey = Integer.toString(bottom_left_xy[0])+":"+Integer.toString(bottom_left_xy[1]);
+
+    		// See if this image is already loaded
+    		if(this.image != null){
+    			if(this.imagex != bottom_left_xy[0] || this.imagey != bottom_left_xy[1]){
+
+    				// Check if this image exists in the hashmap
+    				if(this.imageindex.containsKey(hashkey)){
+    					// Store which image we have
+    					this.imagex = bottom_left_xy[0];
+    					this.imagey = bottom_left_xy[1];
+
+    					// Retrieve from cache
+    					this.image = this.images.get(this.imageindex.get(hashkey));
+    					return this.image;
+    				} else {
+    					this.image = null;
+    				}
+    			} else {
+    				return this.image;
+    			}
+    		}
+
+    		try {
+    			System.out.println("Looking for image in disk cache: "+filename);
+
+    			// Read from a file
+    			this.image = ImageIO.read(file);
+
+    			this.images.add(this.image);
+    			this.imageindex.put(hashkey,this.images.size()-1);
+
+    		} catch(FileNotFoundException e){
+    			System.out.println("Could not find cached image, downloading.");
+    		} catch(IOException e){
+    			System.out.println(e.getMessage());
+    		} catch(Exception e){
+    			System.out.println(e.getMessage());
+    		}
+
+    		if(this.image == null){
+    			/**
+    			 * Try downloading the image
+    			 */
+    			try {
+    				System.out.println("Downloading from "+urlloc);
+
+    				// Read from a URL
+    				URL url = new URL(urlloc);
+    				this.image = ImageIO.read(url); // this can return null!
+    			} catch(MalformedURLException e){
+    				System.out.println(e.getMessage());
+    			} catch(IOException e){
+    				System.out.println(e.getMessage());
+    			} catch(Exception e){
+    				System.out.println(e.getMessage());
+    			}
+
+    			if (this.image != null) {
+    				this.images.add(this.image);
+    				this.imageindex.put(hashkey,this.images.size()-1);
+
+    				this.saveimage(file,this.image);
+    			}
+    		}
+
+    		this.imagex = bottom_left_xy[0];
+    		this.imagey = bottom_left_xy[1];
+
+    		if(this.image == null){
+    			throw new LakewalkerException(tr("Could not acquire image"));
+    		}
+
+    		return this.image;
+    	} finally {
+    		progressMonitor.finishTask();
+    	}
     }
 
@@ -166,6 +170,5 @@
     }
 
-    public int getPixel(int x, int y) throws LakewalkerException{
-
+    public int getPixel(int x, int y, ProgressMonitor progressMonitor) throws LakewalkerException{
         // Get the previously shown text
 
@@ -174,5 +177,5 @@
 
         try {
-            image = this.getTile(x,y);
+            image = this.getTile(x,y, progressMonitor);
         } catch(LakewalkerException e){
             System.out.println(e.getError());
@@ -229,16 +232,3 @@
         return xy;
     }
-
-    private void printarr(int[] a){
-        for(int i = 0; i<a.length; i++){
-            System.out.println(i+": "+a[i]);
-        }
-    }
-    protected void setStatus(String s) {
-        Main.pleaseWaitDlg.currentAction.setText(s);
-        Main.pleaseWaitDlg.repaint();
-    }
-    protected String getStatus(){
-        return Main.pleaseWaitDlg.currentAction.getText();
-    }
 }
