Ticket #13203: patch-fix-13203.patch

File patch-fix-13203.patch, 3.0 KB (added by michael2402, 8 years ago)
  • src/org/openstreetmap/josm/actions/DuplicateAction.java

    diff --git a/src/org/openstreetmap/josm/actions/DuplicateAction.java b/src/org/openstreetmap/josm/actions/DuplicateAction.java
    index c297076..d26003e 100644
    a b import java.awt.event.KeyEvent;  
    1010import java.util.Collection;
    1111
    1212import org.openstreetmap.josm.Main;
     13import org.openstreetmap.josm.data.coor.EastNorth;
    1314import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1415import org.openstreetmap.josm.gui.datatransfer.OsmTransferHandler;
    1516import org.openstreetmap.josm.gui.datatransfer.PrimitiveTransferable;
    public final class DuplicateAction extends JosmAction {  
    3435    @Override
    3536    public void actionPerformed(ActionEvent e) {
    3637        PrimitiveTransferData data = PrimitiveTransferData.getDataWithReferences(getLayerManager().getEditDataSet().getSelected());
    37         new OsmTransferHandler().pasteOn(Main.getLayerManager().getEditLayer(), data.getCenter(), new PrimitiveTransferable(data));
     38        EastNorth mPosition = PasteAction.computePastePosition(e, getValue(NAME));
     39        new OsmTransferHandler().pasteOn(Main.getLayerManager().getEditLayer(), mPosition, new PrimitiveTransferable(data));
    3840    }
    3941
    4042    @Override
  • src/org/openstreetmap/josm/actions/PasteAction.java

    diff --git a/src/org/openstreetmap/josm/actions/PasteAction.java b/src/org/openstreetmap/josm/actions/PasteAction.java
    index 19f076b..a81bc0a 100644
    a b public final class PasteAction extends JosmAction implements FlavorListener {  
    4242
    4343    @Override
    4444    public void actionPerformed(ActionEvent e) {
     45        EastNorth mPosition = computePastePosition(e, getValue(NAME));
     46
     47        transferHandler.pasteOn(Main.getLayerManager().getEditLayer(), mPosition);
     48    }
     49
     50    static EastNorth computePastePosition(ActionEvent e, Object name) {
    4551        // default to paste in center of map (pasted via menu or cursor not in MapView)
    4652        EastNorth mPosition = Main.map.mapView.getCenter();
    4753        // We previously checked for modifier to know if the action has been trigerred via shortcut or via menu
    4854        // But this does not work if the shortcut is changed to a single key (see #9055)
    4955        // Observed behaviour: getActionCommand() returns Action.NAME when triggered via menu, but shortcut text when triggered with it
    50         if (e != null && !getValue(NAME).equals(e.getActionCommand())) {
     56        if (e != null && !name.equals(e.getActionCommand())) {
    5157            final Point mp = MouseInfo.getPointerInfo().getLocation();
    5258            final Point tl = Main.map.mapView.getLocationOnScreen();
    5359            final Point pos = new Point(mp.x-tl.x, mp.y-tl.y);
    public final class PasteAction extends JosmAction implements FlavorListener {  
    5561                mPosition = Main.map.mapView.getEastNorth(pos.x, pos.y);
    5662            }
    5763        }
    58 
    59         transferHandler.pasteOn(Main.getLayerManager().getEditLayer(), mPosition);
     64        return mPosition;
    6065    }
    6166
    6267    @Override