- Timestamp:
- 2010-01-28T17:52:55+01:00 (15 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r2897 r2901 38 38 39 39 import org.openstreetmap.josm.Main; 40 import org.openstreetmap.josm.actions.DuplicateLayerAction; 40 41 import org.openstreetmap.josm.actions.MergeLayerAction; 41 42 import org.openstreetmap.josm.gui.MapFrame; … … 130 131 buttonPanel.add(new SideButton(mergeLayerAction)); 131 132 133 // -- duplicate layer action 134 DuplicateAction duplicateLayerAction = new DuplicateAction(); 135 adaptTo(duplicateLayerAction, model); 136 adaptTo(duplicateLayerAction, selectionModel); 137 buttonPanel.add(new SideButton(duplicateLayerAction)); 138 132 139 //-- delete layer action 133 140 DeleteLayerAction deleteLayerAction = new DeleteLayerAction(); … … 480 487 481 488 /** 489 * The action to merge the currently selected layer into another layer. 490 */ 491 public final class DuplicateAction extends AbstractAction implements IEnabledStateUpdating { 492 private Layer layer; 493 494 public DuplicateAction(Layer layer) throws IllegalArgumentException { 495 this(); 496 CheckParameterUtil.ensureParameterNotNull(layer, "layer"); 497 this.layer = layer; 498 putValue(NAME, tr("Duplicate")); 499 updateEnabledState(); 500 } 501 502 public DuplicateAction() { 503 putValue(SMALL_ICON, ImageProvider.get("dialogs", "duplicatelayer")); 504 putValue(SHORT_DESCRIPTION, tr("Duplicate this layer")); 505 putValue("help", HelpUtil.ht("/Dialog/LayerDialog#DuplicateLayer")); 506 updateEnabledState(); 507 } 508 509 public void actionPerformed(ActionEvent e) { 510 if (layer != null) { 511 new DuplicateLayerAction().duplicate(layer); 512 } else { 513 Layer selectedLayer = getModel().getSelectedLayers().get(0); 514 new DuplicateLayerAction().duplicate(selectedLayer); 515 } 516 } 517 518 protected boolean isActiveLayer(Layer layer) { 519 if (Main.map == null) return false; 520 if (Main.map.mapView == null) return false; 521 return Main.map.mapView.getActiveLayer() == layer; 522 } 523 524 public void updateEnabledState() { 525 if (layer == null) { 526 if (getModel().getSelectedLayers().size() == 1) { 527 setEnabled(DuplicateLayerAction.canDuplicate(getModel().getSelectedLayers().get(0))); 528 } else { 529 setEnabled(false); 530 } 531 } else { 532 setEnabled(DuplicateLayerAction.canDuplicate(layer)); 533 } 534 } 535 } 536 537 /** 482 538 * the list cell renderer used to render layer list entries 483 539 *
Note:
See TracChangeset
for help on using the changeset viewer.