Index: trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 1952)
+++ trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 1953)
@@ -9,4 +9,5 @@
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.List;
 
 import javax.swing.JOptionPane;
@@ -17,4 +18,5 @@
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
 import org.openstreetmap.josm.gui.OptionPaneUtil;
+import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
 import org.openstreetmap.josm.gui.layer.Layer;
 import org.openstreetmap.josm.tools.Shortcut;
@@ -81,4 +83,18 @@
     }
 
+    /**
+     * Replies the first selected layer in the layer list dialog. null, if no
+     * such layer exists, either because the layer list dialog is not yet created
+     * or because no layer is selected.
+     * 
+     * @return the first selected layer in the layer list dialog
+     */
+    protected Layer getFirstSelectedLayer() {
+        if (LayerListDialog.getInstance() == null) return null;
+        List<Layer> layers = LayerListDialog.getInstance().getModel().getSelectedLayers();
+        if (layers.isEmpty()) return null;
+        return layers.get(0);
+    }
+
     private BoundingXYVisitor getBoundingBox() {
         BoundingXYVisitor v = new BoundingXYVisitor();
@@ -90,5 +106,9 @@
             if (getActiveLayer() == null)
                 return null;
-            getActiveLayer().visitBoundingBox(v);
+            // try to zoom to the first selected layer
+            //
+            Layer l = getFirstSelectedLayer();
+            if (l == null) return null;
+            l.visitBoundingBox(v);
         } else if (mode.equals("selection") || mode.equals("conflict")) {
             Collection<OsmPrimitive> sel = new HashSet<OsmPrimitive>();
@@ -142,5 +162,10 @@
             setEnabled(getCurrentDataSet() != null && ! getCurrentDataSet().getSelected().isEmpty());
         }  else if ("layer".equals(mode)) {
-            setEnabled(getActiveLayer() != null);
+            if (Main.map == null || Main.map.mapView == null || Main.map.mapView.getAllLayersAsList().isEmpty()) {
+                setEnabled(false);
+            } else {
+                // FIXME: should also check for whether a layer is selected in the layer list dialog
+                setEnabled(true);
+            }
         } else {
             setEnabled(
