- Timestamp:
- 2015-04-29T23:38:33+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r8291 r8293 1228 1228 public List<Layer> getSelectedLayers() { 1229 1229 List<Layer> selected = new ArrayList<>(); 1230 for (int i=0; i<getLayers().size(); i++) { 1230 List<Layer> layers = getLayers(); 1231 for (int i=0; i<layers.size(); i++) { 1231 1232 if (selectionModel.isSelectedIndex(i)) { 1232 selected.add( getLayers().get(i));1233 selected.add(layers.get(i)); 1233 1234 } 1234 1235 } … … 1316 1317 1317 1318 /** 1318 * Replies true if the currently selected layers can move up 1319 * by one position 1320 * 1321 * @return true if the currently selected layers can move up 1322 * by one position 1319 * Replies true if the currently selected layers can move up by one position 1320 * 1321 * @return true if the currently selected layers can move up by one position 1323 1322 */ 1324 1323 public boolean canMoveUp() { … … 1334 1333 if (!canMoveUp()) return; 1335 1334 List<Integer> sel = getSelectedRows(); 1335 List<Layer> layers = getLayers(); 1336 1336 for (int row : sel) { 1337 Layer l1 = getLayers().get(row);1338 Layer l2 = getLayers().get(row-1);1339 Main.map.mapView.moveLayer(l2, row);1337 Layer l1 = layers.get(row); 1338 Layer l2 = layers.get(row-1); 1339 Main.map.mapView.moveLayer(l2, row); 1340 1340 Main.map.mapView.moveLayer(l1, row-1); 1341 1341 } … … 1349 1349 1350 1350 /** 1351 * Replies true if the currently selected layers can move down 1352 * by one position 1353 * 1354 * @return true if the currently selected layers can move down 1355 * by one position 1351 * Replies true if the currently selected layers can move down by one position 1352 * 1353 * @return true if the currently selected layers can move down by one position 1356 1354 */ 1357 1355 public boolean canMoveDown() { … … 1368 1366 List<Integer> sel = getSelectedRows(); 1369 1367 Collections.reverse(sel); 1368 List<Layer> layers = getLayers(); 1370 1369 for (int row : sel) { 1371 Layer l1 = getLayers().get(row);1372 Layer l2 = getLayers().get(row+1);1370 Layer l1 = layers.get(row); 1371 Layer l2 = layers.get(row+1); 1373 1372 Main.map.mapView.moveLayer(l1, row+1); 1374 1373 Main.map.mapView.moveLayer(l2, row); … … 1390 1389 int index = selectionModel.getMinSelectionIndex(); 1391 1390 if (index < 0) return; 1392 if (index >= getLayers().size()) return; 1393 Layer layer = getLayers().get(index); 1391 List<Layer> layers = getLayers(); 1392 if (index >= layers.size()) return; 1393 Layer layer = layers.get(index); 1394 1394 fireMakeVisible(index, layer); 1395 1395 } … … 1436 1436 */ 1437 1437 protected void ensureActiveSelected() { 1438 if (getLayers().isEmpty()) 1438 List<Layer> layers = getLayers(); 1439 if (layers.isEmpty()) 1439 1440 return; 1440 1441 final Layer activeLayer = getActiveLayer(); 1441 1442 if (activeLayer != null) { 1442 1443 // there's an active layer - select it and make it visible 1443 int idx = getLayers().indexOf(activeLayer);1444 int idx = layers.indexOf(activeLayer); 1444 1445 selectionModel.setSelectionInterval(idx, idx); 1445 1446 ensureSelectedIsVisible(); … … 1479 1480 @Override 1480 1481 public Object getValueAt(int row, int col) { 1481 if (row >= 0 && row < getLayers().size()) { 1482 List<Layer> layers = getLayers(); 1483 if (row >= 0 && row < layers.size()) { 1482 1484 switch (col) { 1483 case 0: return getLayers().get(row) == getActiveLayer();1484 case 1: return getLayers().get(row);1485 case 2: return getLayers().get(row);1485 case 0: return layers.get(row) == getActiveLayer(); 1486 case 1: return layers.get(row); 1487 case 2: return layers.get(row); 1486 1488 default: throw new RuntimeException(); 1487 1489 } … … 1499 1501 @Override 1500 1502 public void setValueAt(Object value, int row, int col) { 1501 Layer l = getLayers().get(row); 1502 switch (col) { 1503 case 0: 1504 Main.map.mapView.setActiveLayer(l); 1505 l.setVisible(true); 1506 break; 1507 case 1: 1508 l.setVisible((Boolean) value); 1509 break; 1510 case 2: 1511 l.setName((String) value); 1512 break; 1513 default: throw new RuntimeException(); 1514 } 1515 fireTableCellUpdated(row, col); 1503 List<Layer> layers = getLayers(); 1504 if (row < layers.size()) { 1505 Layer l = layers.get(row); 1506 switch (col) { 1507 case 0: 1508 Main.map.mapView.setActiveLayer(l); 1509 l.setVisible(true); 1510 break; 1511 case 1: 1512 l.setVisible((Boolean) value); 1513 break; 1514 case 2: 1515 l.setName((String) value); 1516 break; 1517 default: throw new RuntimeException(); 1518 } 1519 fireTableCellUpdated(row, col); 1520 } 1516 1521 } 1517 1522
Note:
See TracChangeset
for help on using the changeset viewer.