Index: /trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java	(revision 805)
+++ /trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java	(revision 806)
@@ -24,17 +24,17 @@
 /**
  * Main download dialog.
- * 
+ *
  * Can be extended by plugins in two ways:
  * (1) by adding download tasks that are then called with the selected bounding box
  * (2) by adding "DownloadSelection" objects that implement different ways of selecting a bounding box
- * 
+ *
  * @author Frederik Ramm <frederik@remote.org>
  *
  */
 public class DownloadDialog extends JPanel {
-	
+
 	// the JOptionPane that contains this dialog. required for the closeDialog() method.
 	private JOptionPane optionPane;
-	
+
 	public interface DownloadTask {
 		/**
@@ -63,17 +63,17 @@
 	public final JTabbedPane tabpane = new JTabbedPane();
 	public final JCheckBox newLayer;
-	
+
 	public double minlon;
 	public double minlat;
 	public double maxlon;
 	public double maxlat;
-	
-	
+
+
 	public DownloadDialog() {
 		setLayout(new GridBagLayout());
-		
+
 		downloadTasks.add(new DownloadOsmTask());
 		downloadTasks.add(new DownloadGpsTask());
-		
+
 		// adding the download tasks
 		add(new JLabel(tr("Data Sources and Types")), GBC.eol().insets(0,5,0,0));
@@ -85,15 +85,15 @@
 			}
 		}
-		
+
 		// predefined download selections
 		downloadSelections.add(new BoundingBoxSelection());
-		downloadSelections.add(new BookmarkSelection());	
+		downloadSelections.add(new BookmarkSelection());
 		downloadSelections.add(new WorldChooser());
-		
+
 		// add selections from plugins
 		for (PluginProxy p : Main.plugins) {
 			p.addDownloadSelection(downloadSelections);
 		}
-		
+
 		// now everybody may add their tab to the tabbed pane
 		// (not done right away to allow plugins to remove one of
@@ -102,5 +102,5 @@
 			s.addGui(this);
 		}
-		
+
 		if (Main.map != null) {
 			MapView mv = Main.map.mapView;
@@ -111,4 +111,18 @@
 			boundingBoxChanged(null);
 		}
+		else if (Main.pref.hasKey("osm-download.bounds")) {
+			// read the bounding box from the preferences
+			try {
+				String bounds[] = Main.pref.get("osm-download.bounds").split(";");
+				minlat = Double.parseDouble(bounds[0]);
+				minlon = Double.parseDouble(bounds[1]);
+				maxlat = Double.parseDouble(bounds[2]);
+				maxlon = Double.parseDouble(bounds[3]);
+				boundingBoxChanged(null);
+			}
+			catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
 
 		newLayer = new JCheckBox(tr("Download as new layer"), Main.pref.getBoolean("download.newlayer", false));
@@ -117,5 +131,5 @@
 		add(new JLabel(tr("Download Area")), GBC.eol().insets(0,5,0,0));
 		add(tabpane, GBC.eol().fill());
-		
+
 		try {
 			tabpane.setSelectedIndex(Integer.parseInt(Main.pref.get("download.tab", "0")));
@@ -124,10 +138,10 @@
 		}
 	}
-	
+
 	/**
-	 * Distributes a "bounding box changed" from one DownloadSelection 
-	 * object to the others, so they may update or clear their input 
+	 * Distributes a "bounding box changed" from one DownloadSelection
+	 * object to the others, so they may update or clear their input
 	 * fields.
-	 * 
+	 *
 	 * @param eventSource - the DownloadSelection object that fired this notification.
 	 */
@@ -135,5 +149,5 @@
 		for (DownloadSelection s : downloadSelections) {
 			if (s != eventSource) s.boundingBoxChanged(this);
-		}	
+		}
 	}
 
@@ -144,9 +158,9 @@
 		return tabpane.getSelectedIndex();
 	}
-	
+
 	/**
 	 * Closes the download dialog. This is intended to be called by one of
 	 * the various download area selection "plugins".
-	 * 
+	 *
 	 * @param download true to download selected data, false to cancel download
 	 */
@@ -160,5 +174,5 @@
 	 */
 	public void setOptionPane(JOptionPane optionPane) {
-    	this.optionPane = optionPane;
-    }
+		this.optionPane = optionPane;
+	}
 }
Index: /trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java	(revision 805)
+++ /trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java	(revision 806)
@@ -19,7 +19,7 @@
 
 	/**
-     * The boundings of the desired map data.
-     */
-    private final double lat1;
+	 * The boundings of the desired map data.
+	 */
+	private final double lat1;
 	private final double lon1;
 	private final double lat2;
@@ -31,25 +31,28 @@
 		this.lat2 = lat2;
 		this.lon2 = lon2;
-    }
+		// store the bounding box in the preferences so it can be
+		// re-used across invocations of josm
+		Main.pref.put("osm-download.bounds", lat1+";"+lon1+";"+lat2+";"+lon2);
+	}
 
 	/**
-     * Retrieve raw gps waypoints from the server API.
-     * @return A list of all primitives retrieved. Currently, the list of lists
-     * 		contain only one list, since the server cannot distinguish between
-     * 		ways.
-     */
+	 * Retrieve raw gps waypoints from the server API.
+	 * @return A list of all primitives retrieved. Currently, the list of lists
+	 *      contain only one list, since the server cannot distinguish between
+	 *      ways.
+	 */
 	public GpxData parseRawGps() throws IOException, SAXException {
 		Main.pleaseWaitDlg.progress.setValue(0);
 		Main.pleaseWaitDlg.currentAction.setText(tr("Contacting OSM Server..."));
-    	try {
-    		String url = "trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page=";
+		try {
+			String url = "trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page=";
 
 			boolean done = false;
 			GpxData result = null;
 			for (int i = 0;!done;++i) {
-    			Main.pleaseWaitDlg.currentAction.setText(tr("Downloading points {0} to {1}...", i * 5000, ((i + 1) * 5000)));
-    			InputStream in = getInputStream(url+i, Main.pleaseWaitDlg);
-    			if (in == null)
-    				break;
+				Main.pleaseWaitDlg.currentAction.setText(tr("Downloading points {0} to {1}...", i * 5000, ((i + 1) * 5000)));
+				InputStream in = getInputStream(url+i, Main.pleaseWaitDlg);
+				if (in == null)
+					break;
 				GpxData currentGpx = new GpxReader(in, null).data;
 				if (result == null) {
@@ -59,67 +62,59 @@
 				} else{
 					done = true;
-    			}
-    			in.close();
-    			activeConnection = null;
-    		}
+				}
+				in.close();
+				activeConnection = null;
+			}
 			result.fromServer = true;
 			return result;
-    	} catch (IllegalArgumentException e) {
-    		// caused by HttpUrlConnection in case of illegal stuff in the response
-    		if (cancel)
-    			return null;
-    		throw new SAXException("Illegal characters within the HTTP-header response", e);
-    	} catch (IOException e) {
-    		if (cancel)
-    			return null;
-    		throw e;
-    	} catch (SAXException e) {
-    		throw e;
-    	} catch (Exception e) {
-    		if (cancel)
-    			return null;
-    		if (e instanceof RuntimeException)
-    			throw (RuntimeException)e;
-    		throw new RuntimeException(e);
-    	}
-    }
+		} catch (IllegalArgumentException e) {
+			// caused by HttpUrlConnection in case of illegal stuff in the response
+			if (cancel)
+				return null;
+			throw new SAXException("Illegal characters within the HTTP-header response", e);
+		} catch (IOException e) {
+			if (cancel)
+				return null;
+			throw e;
+		} catch (SAXException e) {
+			throw e;
+		} catch (Exception e) {
+			if (cancel)
+				return null;
+			if (e instanceof RuntimeException)
+				throw (RuntimeException)e;
+			throw new RuntimeException(e);
+		}
+	}
 
 	/**
-     * Read the data from the osm server address.
-     * @return A data set containing all data retrieved from that url
-     */
-    public DataSet parseOsm() throws SAXException, IOException {
-    	try {
+	 * Read the data from the osm server address.
+	 * @return A data set containing all data retrieved from that url
+	 */
+	public DataSet parseOsm() throws SAXException, IOException {
+		try {
 			Main.pleaseWaitDlg.progress.setValue(0);
-    		Main.pleaseWaitDlg.currentAction.setText(tr("Contacting OSM Server..."));
-    		final InputStream in = getInputStream("map?bbox="+lon1+","+lat1+","+lon2+","+lat2, Main.pleaseWaitDlg);
-    		if (in == null)
-    			return null;
-    		Main.pleaseWaitDlg.currentAction.setText(tr("Downloading OSM data..."));
-    		final DataSet data = OsmReader.parseDataSet(in, null, Main.pleaseWaitDlg);
-            /*
-             * We're not doing this here anymore as the API now properly sets a bounds element
-             * which will get parsed.
-    		String origin = Main.pref.get("osm-server.url")+"/"+Main.pref.get("osm-server.version", "0.5");
-    		Bounds bounds = new Bounds(new LatLon(lat1, lon1), new LatLon(lat2, lon2));
-			DataSource src = new DataSource(bounds, origin);
-    		data.dataSources.add(src);
-             */
-    		in.close();
-    		activeConnection = null;
-    		return data;
-    	} catch (IOException e) {
-    		if (cancel)
-    			return null;
-    		throw e;
-    	} catch (SAXException e) {
-    		throw e;
-    	} catch (Exception e) {
-    		if (cancel)
-    			return null;
-    		if (e instanceof RuntimeException)
-    			throw (RuntimeException)e;
-    		throw new RuntimeException(e);
-    	}
-    }
+			Main.pleaseWaitDlg.currentAction.setText(tr("Contacting OSM Server..."));
+			final InputStream in = getInputStream("map?bbox="+lon1+","+lat1+","+lon2+","+lat2, Main.pleaseWaitDlg);
+			if (in == null)
+				return null;
+			Main.pleaseWaitDlg.currentAction.setText(tr("Downloading OSM data..."));
+			final DataSet data = OsmReader.parseDataSet(in, null, Main.pleaseWaitDlg);
+			in.close();
+			activeConnection = null;
+			return data;
+		} catch (IOException e) {
+			if (cancel)
+				return null;
+			throw e;
+		} catch (SAXException e) {
+			throw e;
+		} catch (Exception e) {
+			if (cancel)
+				return null;
+			if (e instanceof RuntimeException)
+				throw (RuntimeException)e;
+			throw new RuntimeException(e);
+		}
+	}
 }
