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

Last change on this file since 10600 was 10409, checked in by Don-vip, 8 years ago
  • remove duplicated code
  • fix various sonar warnings
  • add some javadoc and unit tests
  • Property svn:eol-style set to native
File size: 1.5 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.Main;
13import org.openstreetmap.josm.data.osm.OsmPrimitive;
14import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy;
15import org.openstreetmap.josm.tools.Shortcut;
16
17public final class DuplicateAction extends JosmAction {
18
19 /**
20 * Constructs a new {@code DuplicateAction}.
21 */
22 public DuplicateAction() {
23 super(tr("Duplicate"), "duplicate",
24 tr("Duplicate selection by copy and immediate paste."),
25 Shortcut.registerShortcut("system:duplicate", tr("Edit: {0}", tr("Duplicate")), KeyEvent.VK_D, Shortcut.CTRL), true);
26 putValue("help", ht("/Action/Duplicate"));
27 }
28
29 @Override
30 public void actionPerformed(ActionEvent e) {
31 Main.main.menu.paste.pasteData(
32 new PrimitiveDeepCopy(getLayerManager().getEditDataSet().getSelected()), getLayerManager().getEditLayer(), e);
33 }
34
35 @Override
36 protected void updateEnabledState() {
37 updateEnabledStateOnCurrentSelection();
38 }
39
40 @Override
41 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
42 setEnabled(selection != null && !selection.isEmpty());
43 }
44}
Note: See TracBrowser for help on using the repository browser.