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

Last change on this file since 2646 was 2323, checked in by Gubaer, 14 years ago

Added explicit help topics
See also current list of help topics with links to source files and to help pages

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
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;
11
12import org.openstreetmap.josm.data.osm.OsmPrimitive;
13import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy;
14import org.openstreetmap.josm.tools.Shortcut;
15
16public final class DuplicateAction extends JosmAction{
17
18 public DuplicateAction() {
19 super(tr("Duplicate"), "duplicate",
20 tr("Duplicate selection by copy and immediate paste."),
21 Shortcut.registerShortcut("system:duplicate", tr("Edit: {0}", tr("Duplicate")), KeyEvent.VK_D, Shortcut.GROUP_MENU), true);
22 putValue("help", ht("/Action/Duplicate"));
23 }
24
25 public void actionPerformed(ActionEvent e) {
26 new PasteAction().pasteData(new PrimitiveDeepCopy(getCurrentDataSet().getSelected()), getEditLayer(), e);
27 }
28
29 @Override
30 protected void updateEnabledState() {
31 if (getCurrentDataSet() == null) {
32 setEnabled(false);
33 } else {
34 updateEnabledState(getCurrentDataSet().getSelected());
35 }
36 }
37
38 @Override
39 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
40 setEnabled(selection != null && !selection.isEmpty());
41 }
42}
Note: See TracBrowser for help on using the repository browser.