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

Revision 4982, 1.5 KB checked in by stoecker, 3 months ago (diff)

see #7226 - patch by akks (fixed a bit) - fix shortcut deprecations

  • Property svn:eol-style set to native
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;
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    public void actionPerformed(ActionEvent e) {
27        Main.main.menu.paste.pasteData(new PrimitiveDeepCopy(getCurrentDataSet().getSelected()), getEditLayer(), e);
28    }
29
30    @Override
31    protected void updateEnabledState() {
32        if (getCurrentDataSet() == null) {
33            setEnabled(false);
34        } else {
35            updateEnabledState(getCurrentDataSet().getSelected());
36        }
37    }
38
39    @Override
40    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
41        setEnabled(selection != null && !selection.isEmpty());
42    }
43}
Note: See TracBrowser for help on using the repository browser.