Changeset 10605 in josm
- Timestamp:
- 2016-07-23T15:15:14+02:00 (8 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r10604 r10605 85 85 import org.openstreetmap.josm.gui.MapFrameListener; 86 86 import org.openstreetmap.josm.gui.datatransfer.OsmTransferHandler; 87 import org.openstreetmap.josm.gui.datatransfer.data.OsmLayerTransferData; 87 88 import org.openstreetmap.josm.gui.help.HelpUtil; 88 89 import org.openstreetmap.josm.gui.io.SaveLayersDialog; -
trunk/src/org/openstreetmap/josm/actions/CopyAction.java
r10604 r10605 19 19 import org.openstreetmap.josm.gui.datatransfer.PrimitiveTransferable; 20 20 import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData; 21 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 21 22 import org.openstreetmap.josm.tools.Shortcut; 22 23 … … 48 49 } 49 50 50 copy( selection);51 copy(getLayerManager().getEditLayer(), selection); 51 52 } 52 53 … … 54 55 * Copies the given primitive ids to the clipboard. The output by this function 55 56 * looks similar to: node 1089302677,node 1089303458,way 93793372 57 * @param source The OSM data layer source 56 58 * @param primitives The OSM primitives to copy 57 59 */ 58 public static void copy( Collection<OsmPrimitive> primitives) {60 public static void copy(OsmDataLayer source, Collection<OsmPrimitive> primitives) { 59 61 // copy ids to the clipboard 60 ClipboardUtils.copy(new PrimitiveTransferable(PrimitiveTransferData.getDataWithReferences(primitives) ));62 ClipboardUtils.copy(new PrimitiveTransferable(PrimitiveTransferData.getDataWithReferences(primitives), source)); 61 63 } 62 64 -
trunk/src/org/openstreetmap/josm/gui/datatransfer/PrimitiveTransferable.java
r10604 r10605 11 11 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 12 12 import org.openstreetmap.josm.data.osm.PrimitiveData; 13 import org.openstreetmap.josm.gui.datatransfer.data.OsmLayerTransferData; 13 14 import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData; 14 15 import org.openstreetmap.josm.gui.datatransfer.data.TagTransferData; 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 15 17 16 18 /** … … 27 29 TagTransferData.FLAVOR, DataFlavor.stringFlavor); 28 30 private final PrimitiveTransferData primitives; 31 private OsmDataLayer sourceLayer; 29 32 30 33 /** … … 33 36 */ 34 37 public PrimitiveTransferable(PrimitiveTransferData primitives) { 38 this(primitives, null); 39 } 40 41 /** 42 * Constructs a new {@code PrimitiveTransferable}. 43 * @param primitives collection of OSM primitives 44 * @param sourceLayer The layer the primitives are copied from 45 */ 46 public PrimitiveTransferable(PrimitiveTransferData primitives, OsmDataLayer sourceLayer) { 35 47 this.primitives = primitives; 48 this.sourceLayer = sourceLayer; 36 49 } 37 50 … … 39 52 public DataFlavor[] getTransferDataFlavors() { 40 53 ArrayList<DataFlavor> flavors = new ArrayList<>(PRIMITIVE_FLAVORS); 54 if (sourceLayer != null) { 55 flavors.addAll(OsmLayerTransferData.FLAVORS); 56 } 41 57 return flavors.toArray(new DataFlavor[flavors.size()]); 42 58 } … … 61 77 } else if (TagTransferData.FLAVOR.equals(flavor)) { 62 78 return new TagTransferData(primitives.getDirectlyAdded()); 79 } else if (sourceLayer != null && OsmLayerTransferData.FLAVORS.contains(flavor)) { 80 return new OsmLayerTransferData(null, sourceLayer); 63 81 } else { 64 82 throw new UnsupportedFlavorException(flavor); -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r10600 r10605 25 25 import javax.swing.DefaultCellEditor; 26 26 import javax.swing.DefaultListSelectionModel; 27 import javax.swing.DropMode; 27 28 import javax.swing.ImageIcon; 28 29 import javax.swing.JCheckBox; … … 52 53 import org.openstreetmap.josm.gui.dialogs.layer.DeleteLayerAction; 53 54 import org.openstreetmap.josm.gui.dialogs.layer.DuplicateAction; 55 import org.openstreetmap.josm.gui.dialogs.layer.LayerListTransferHandler; 54 56 import org.openstreetmap.josm.gui.dialogs.layer.LayerVisibilityAction; 55 57 import org.openstreetmap.josm.gui.dialogs.layer.MergeAction; … … 1104 1106 @Override 1105 1107 public void layerOrderChanged(LayerOrderChangeEvent e) { 1106 // ignored for now, since only we change layer order.1108 fireTableDataChanged(); 1107 1109 } 1108 1110 … … 1130 1132 super(dataModel); 1131 1133 dataModel.setLayerList(this); 1134 setDragEnabled(true); 1135 setDropMode(DropMode.INSERT_ROWS); 1136 setTransferHandler(new LayerListTransferHandler()); 1132 1137 } 1133 1138 … … 1141 1146 viewport.scrollRectToVisible(rect); 1142 1147 } 1148 1149 @Override 1150 public LayerListModel getModel() { 1151 return (LayerListModel) super.getModel(); 1152 } 1143 1153 } 1144 1154 -
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/DuplicateAction.java
r10600 r10605 5 5 6 6 import java.awt.event.ActionEvent; 7 import java.util.ArrayList;8 import java.util.List;9 7 10 8 import javax.swing.AbstractAction; … … 21 19 22 20 /** 23 * The action to merge the currentlyselected layer into another layer.21 * The action to dupplicate the given selected layer into another layer. 24 22 */ 25 23 public final class DuplicateAction extends AbstractAction implements IEnabledStateUpdating { … … 53 51 } 54 52 55 private void duplicate(Layer layer) { 56 if (!Main.isDisplayingMapView()) 57 return; 58 59 List<String> layerNames = new ArrayList<>(); 60 for (Layer l: Main.getLayerManager().getLayers()) { 61 layerNames.add(l.getName()); 62 } 53 private static void duplicate(Layer layer) { 63 54 if (layer instanceof OsmDataLayer) { 55 String newName = LayerListTransferHandler.suggestNewLayerName(layer.getName(), Main.getLayerManager().getLayers()); 64 56 OsmDataLayer oldLayer = (OsmDataLayer) layer; 65 // Translators: "Copy of {layer name}"66 String newName = tr("Copy of {0}", oldLayer.getName());67 int i = 2;68 while (layerNames.contains(newName)) {69 // Translators: "Copy {number} of {layer name}"70 newName = tr("Copy {1} of {0}", oldLayer.getName(), i);71 i++;72 }73 57 Main.getLayerManager().addLayer(new OsmDataLayer(new DataSet(oldLayer.data), newName, null)); 74 58 }
Note:
See TracChangeset
for help on using the changeset viewer.