Index: trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 8170)
+++ trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 8171)
@@ -8,4 +8,5 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -22,4 +23,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.Bounds;
+import org.openstreetmap.josm.data.DataSource;
 import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -31,5 +33,4 @@
 import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
 import org.openstreetmap.josm.gui.dialogs.ValidatorDialog.ValidatorBoundingXYVisitor;
-import org.openstreetmap.josm.gui.download.DownloadDialog;
 import org.openstreetmap.josm.gui.layer.Layer;
 import org.openstreetmap.josm.tools.Shortcut;
@@ -55,4 +56,8 @@
     protected ZoomChangeAdapter zoomChangeAdapter;
     protected MapFrameAdapter mapFrameAdapter;
+    /** Time of last zoom to bounds action */
+    protected long lastZoomTime = -1;
+    /** Last zommed bounds */
+    protected int lastZoomArea = -1;
 
     /**
@@ -63,5 +68,6 @@
      */
     public static void zoomToSelection() {
-        if (Main.main == null || !Main.main.hasEditLayer()) return;
+        if (Main.main == null || !Main.main.hasEditLayer())
+            return;
         Collection<OsmPrimitive> sel = Main.main.getEditLayer().data.getSelected();
         if (sel.isEmpty()) {
@@ -70,6 +76,5 @@
                     tr("Nothing selected to zoom to."),
                     tr("Information"),
-                    JOptionPane.INFORMATION_MESSAGE
-            );
+                    JOptionPane.INFORMATION_MESSAGE);
             return;
         }
@@ -126,6 +131,6 @@
     public AutoScaleAction(final String mode) {
         super(tr("Zoom to {0}", tr(mode)), "dialogs/autoscale/" + mode, tr("Zoom the view to {0}.", tr(mode)),
-                Shortcut.registerShortcut("view:zoom"+mode, tr("View: {0}", tr("Zoom to {0}", tr(mode))), getModeShortcut(mode), Shortcut.DIRECT),
-                true, null, false);
+                Shortcut.registerShortcut("view:zoom" + mode, tr("View: {0}", tr("Zoom to {0}", tr(mode))),
+                        getModeShortcut(mode), Shortcut.DIRECT), true, null, false);
         String modeHelp = Character.toUpperCase(mode.charAt(0)) + mode.substring(1);
         putValue("help", "Action/AutoScale/" + modeHelp);
@@ -157,12 +162,12 @@
             break;
         default:
-            throw new IllegalArgumentException("Unknown mode: "+mode);
+            throw new IllegalArgumentException("Unknown mode: " + mode);
         }
         installAdapters();
     }
 
-    public void autoScale()  {
+    public void autoScale() {
         if (Main.isDisplayingMapView()) {
-            switch(mode) {
+            switch (mode) {
             case "previous":
                 Main.map.mapView.zoomPrevious();
@@ -195,5 +200,6 @@
     protected Layer getFirstSelectedLayer() {
         List<Layer> layers = LayerListDialog.getInstance().getModel().getSelectedLayers();
-        if (layers.isEmpty()) return null;
+        if (layers.isEmpty())
+            return null;
         return layers.get(0);
     }
@@ -202,10 +208,12 @@
         BoundingXYVisitor v = "problem".equals(mode) ? new ValidatorBoundingXYVisitor() : new BoundingXYVisitor();
 
-        switch(mode) {
+        switch (mode) {
         case "problem":
             TestError error = Main.map.validatorDialog.getSelectedError();
-            if (error == null) return null;
+            if (error == null)
+                return null;
             ((ValidatorBoundingXYVisitor) v).visit(error);
-            if (v.getBounds() == null) return null;
+            if (v.getBounds() == null)
+                return null;
             v.enlargeBoundingBox(Main.pref.getDouble("validator.zoom-enlarge-bbox", 0.0002));
             break;
@@ -220,5 +228,6 @@
             // try to zoom to the first selected layer
             Layer l = getFirstSelectedLayer();
-            if (l == null) return null;
+            if (l == null)
+                return null;
             l.visitBoundingBox(v);
             break;
@@ -241,6 +250,5 @@
                         ("selection".equals(mode) ? tr("Nothing selected to zoom to.") : tr("No conflicts to zoom to")),
                         tr("Information"),
-                        JOptionPane.INFORMATION_MESSAGE
-                );
+                        JOptionPane.INFORMATION_MESSAGE);
                 return null;
             }
@@ -256,11 +264,25 @@
             break;
         case "download":
-            Bounds bounds = DownloadDialog.getSavedDownloadBounds();
-            if (bounds != null) {
-                try {
-                    v.visit(bounds);
-                } catch (Exception e) {
-                    Main.warn(e);
-                }
+
+            if (lastZoomTime > 0 && System.currentTimeMillis() - lastZoomTime > Main.pref.getLong("zoom.bounds.reset.time", 10*1000)) {
+                lastZoomTime = -1;
+            }
+            ArrayList<DataSource> dataSources = new ArrayList<>(Main.main.getCurrentDataSet().getDataSources());
+            int s = dataSources.size();
+            if(s > 0) {
+                if(lastZoomTime == -1 || lastZoomArea == -1 || lastZoomArea > s) {
+                    lastZoomArea = s-1;
+                    v.visit(dataSources.get(lastZoomArea).bounds);
+                } else if(lastZoomArea > 0) {
+                    lastZoomArea -= 1;
+                    v.visit(dataSources.get(lastZoomArea).bounds);
+                } else {
+                    lastZoomArea = -1;
+                    v.visit(new Bounds(Main.main.getCurrentDataSet().getDataSourceArea().getBounds2D()));
+                }
+                lastZoomTime = System.currentTimeMillis();
+            } else {
+                lastZoomTime = -1;
+                lastZoomArea = -1;
             }
             break;
@@ -271,7 +293,7 @@
     @Override
     protected void updateEnabledState() {
-        switch(mode) {
+        switch (mode) {
         case "selection":
-            setEnabled(getCurrentDataSet() != null && ! getCurrentDataSet().getSelected().isEmpty());
+            setEnabled(getCurrentDataSet() != null && !getCurrentDataSet().getSelected().isEmpty());
             break;
         case "layer":
@@ -296,6 +318,5 @@
             break;
         default:
-            setEnabled(Main.isDisplayingMapView() && Main.map.mapView.hasLayers()
-            );
+            setEnabled(Main.isDisplayingMapView() && Main.map.mapView.hasLayers());
         }
     }
@@ -338,5 +359,6 @@
             if ("conflict".equals(mode)) {
                 conflictSelectionListener = new ListSelectionListener() {
-                    @Override public void valueChanged(ListSelectionEvent e) {
+                    @Override
+                    public void valueChanged(ListSelectionEvent e) {
                         updateEnabledState();
                     }
@@ -344,5 +366,6 @@
             } else if ("problem".equals(mode)) {
                 validatorSelectionListener = new TreeSelectionListener() {
-                    @Override public void valueChanged(TreeSelectionEvent e) {
+                    @Override
+                    public void valueChanged(TreeSelectionEvent e) {
                         updateEnabledState();
                     }
@@ -351,5 +374,6 @@
         }
 
-        @Override public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
+        @Override
+        public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
             if (conflictSelectionListener != null) {
                 if (newFrame != null) {
