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

Last change on this file since 13564 was 13434, checked in by Don-vip, 6 years ago

see #8039, see #10456 - support read-only data layers

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