1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | // Author: David Earl
|
---|
3 | package org.openstreetmap.josm.actions;
|
---|
4 |
|
---|
5 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
---|
6 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
7 |
|
---|
8 | import java.awt.event.ActionEvent;
|
---|
9 | import java.awt.event.KeyEvent;
|
---|
10 | import java.util.Collection;
|
---|
11 |
|
---|
12 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
13 | import org.openstreetmap.josm.gui.datatransfer.PrimitiveTransferable;
|
---|
14 | import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData;
|
---|
15 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * An action that duplicates the given nodes. They are not added to the clipboard.
|
---|
19 | */
|
---|
20 | public 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 | }
|
---|