Changeset 4959 in josm for trunk/src/org
- Timestamp:
- 2012-02-16T19:44:06+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r4953 r4959 52 52 53 53 import org.openstreetmap.josm.Main; 54 import org.openstreetmap.josm.actions.DuplicateLayerAction;55 54 import org.openstreetmap.josm.actions.MergeLayerAction; 56 55 import org.openstreetmap.josm.gui.MapFrame; … … 794 793 } 795 794 795 private void duplicate(Layer layer) { 796 if (Main.map == null || Main.map.mapView == null) 797 return; 798 799 List<String> layerNames = new ArrayList<String>(); 800 for (Layer l: Main.map.mapView.getAllLayers()) { 801 layerNames.add(l.getName()); 802 } 803 if (layer instanceof OsmDataLayer) { 804 OsmDataLayer oldLayer = (OsmDataLayer)layer; 805 // Translators: "Copy of {layer name}" 806 String newName = tr("Copy of {0}", oldLayer.getName()); 807 int i = 2; 808 while (layerNames.contains(newName)) { 809 // Translators: "Copy {number} of {layer name}" 810 newName = tr("Copy {1} of {0}", oldLayer.getName(), i); 811 i++; 812 } 813 Main.main.addLayer(new OsmDataLayer(oldLayer.data.clone(), newName, null)); 814 } 815 } 816 796 817 @Override 797 818 public void actionPerformed(ActionEvent e) { 798 819 if (layer != null) { 799 new DuplicateLayerAction().duplicate(layer);820 duplicate(layer); 800 821 } else { 801 Layer selectedLayer = getModel().getSelectedLayers().get(0); 802 new DuplicateLayerAction().duplicate(selectedLayer); 822 duplicate(getModel().getSelectedLayers().get(0)); 803 823 } 804 824 } 805 825 806 826 protected boolean isActiveLayer(Layer layer) { 807 if (Main.map == null ) return false;808 if (Main.map.mapView == null)return false;827 if (Main.map == null || Main.map.mapView == null) 828 return false; 809 829 return Main.map.mapView.getActiveLayer() == layer; 810 830 } … … 814 834 if (layer == null) { 815 835 if (getModel().getSelectedLayers().size() == 1) { 816 setEnabled( DuplicateLayerAction.canDuplicate(getModel().getSelectedLayers().get(0)));836 setEnabled(getModel().getSelectedLayers().get(0) instanceof OsmDataLayer); 817 837 } else { 818 838 setEnabled(false); 819 839 } 820 840 } else { 821 setEnabled( DuplicateLayerAction.canDuplicate(layer));841 setEnabled(layer instanceof OsmDataLayer); 822 842 } 823 843 }
Note:
See TracChangeset
for help on using the changeset viewer.