Changeset 1953 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-08-11T09:51:27+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r1903 r1953 9 9 import java.util.Collection; 10 10 import java.util.HashSet; 11 import java.util.List; 11 12 12 13 import javax.swing.JOptionPane; … … 17 18 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 18 19 import org.openstreetmap.josm.gui.OptionPaneUtil; 20 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 19 21 import org.openstreetmap.josm.gui.layer.Layer; 20 22 import org.openstreetmap.josm.tools.Shortcut; … … 81 83 } 82 84 85 /** 86 * Replies the first selected layer in the layer list dialog. null, if no 87 * such layer exists, either because the layer list dialog is not yet created 88 * or because no layer is selected. 89 * 90 * @return the first selected layer in the layer list dialog 91 */ 92 protected Layer getFirstSelectedLayer() { 93 if (LayerListDialog.getInstance() == null) return null; 94 List<Layer> layers = LayerListDialog.getInstance().getModel().getSelectedLayers(); 95 if (layers.isEmpty()) return null; 96 return layers.get(0); 97 } 98 83 99 private BoundingXYVisitor getBoundingBox() { 84 100 BoundingXYVisitor v = new BoundingXYVisitor(); … … 90 106 if (getActiveLayer() == null) 91 107 return null; 92 getActiveLayer().visitBoundingBox(v); 108 // try to zoom to the first selected layer 109 // 110 Layer l = getFirstSelectedLayer(); 111 if (l == null) return null; 112 l.visitBoundingBox(v); 93 113 } else if (mode.equals("selection") || mode.equals("conflict")) { 94 114 Collection<OsmPrimitive> sel = new HashSet<OsmPrimitive>(); … … 142 162 setEnabled(getCurrentDataSet() != null && ! getCurrentDataSet().getSelected().isEmpty()); 143 163 } else if ("layer".equals(mode)) { 144 setEnabled(getActiveLayer() != null); 164 if (Main.map == null || Main.map.mapView == null || Main.map.mapView.getAllLayersAsList().isEmpty()) { 165 setEnabled(false); 166 } else { 167 // FIXME: should also check for whether a layer is selected in the layer list dialog 168 setEnabled(true); 169 } 145 170 } else { 146 171 setEnabled(
Note:
See TracChangeset
for help on using the changeset viewer.