source: josm/trunk/src/org/openstreetmap/josm/actions/DuplicateAction.java@ 13133

Last change on this file since 13133 was 10766, checked in by Don-vip, 8 years ago

fix #13290 - pasting from other layer changes objects position (modified patch by michael2402) - gsoc-core

  • Property svn:eol-style set to native
File size: 1.6 KB
RevLine 
[6380]1// License: GPL. For details, see LICENSE file.
[626]2// Author: David Earl
3package org.openstreetmap.josm.actions;
4
[9059]5import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
[626]6import static org.openstreetmap.josm.tools.I18n.tr;
7
8import java.awt.event.ActionEvent;
9import java.awt.event.KeyEvent;
[2256]10import java.util.Collection;
[9059]11
[2256]12import org.openstreetmap.josm.data.osm.OsmPrimitive;
[10604]13import org.openstreetmap.josm.gui.datatransfer.PrimitiveTransferable;
14import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData;
[1084]15import org.openstreetmap.josm.tools.Shortcut;
[626]16
[10604]17/**
[10606]18 * An action that duplicates the given nodes. They are not added to the clipboard.
[10604]19 */
[10766]20public final class DuplicateAction extends AbstractPasteAction {
[626]21
[9059]22 /**
23 * Constructs a new {@code DuplicateAction}.
24 */
[626]25 public DuplicateAction() {
[1169]26 super(tr("Duplicate"), "duplicate",
[10604]27 tr("Duplicate selection."),
[4982]28 Shortcut.registerShortcut("system:duplicate", tr("Edit: {0}", tr("Duplicate")), KeyEvent.VK_D, Shortcut.CTRL), true);
[2323]29 putValue("help", ht("/Action/Duplicate"));
[626]30 }
31
[6084]32 @Override
[1169]33 public void actionPerformed(ActionEvent e) {
[10604]34 PrimitiveTransferData data = PrimitiveTransferData.getDataWithReferences(getLayerManager().getEditDataSet().getSelected());
[10766]35 doPaste(e, new PrimitiveTransferable(data));
[626]36 }
[1023]37
[1820]38 @Override
39 protected void updateEnabledState() {
[10409]40 updateEnabledStateOnCurrentSelection();
[1814]41 }
[2256]42
43 @Override
44 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
45 setEnabled(selection != null && !selection.isEmpty());
46 }
[626]47}
Note: See TracBrowser for help on using the repository browser.