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

Last change on this file since 8624 was 6380, checked in by Don-vip, 10 years ago

update license/copyright information

  • 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.tools.I18n.tr;
6import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
7
8import java.awt.event.ActionEvent;
9import java.awt.event.KeyEvent;
10import java.util.Collection;
11import org.openstreetmap.josm.Main;
12
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 public DuplicateAction() {
20 super(tr("Duplicate"), "duplicate",
21 tr("Duplicate selection by copy and immediate paste."),
22 Shortcut.registerShortcut("system:duplicate", tr("Edit: {0}", tr("Duplicate")), KeyEvent.VK_D, Shortcut.CTRL), true);
23 putValue("help", ht("/Action/Duplicate"));
24 }
25
26 @Override
27 public void actionPerformed(ActionEvent e) {
28 Main.main.menu.paste.pasteData(new PrimitiveDeepCopy(getCurrentDataSet().getSelected()), getEditLayer(), e);
29 }
30
31 @Override
32 protected void updateEnabledState() {
33 if (getCurrentDataSet() == null) {
34 setEnabled(false);
35 } else {
36 updateEnabledState(getCurrentDataSet().getSelected());
37 }
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.