source: josm/trunk/src/org/openstreetmap/josm/actions/PasteTagsAction.java@ 13664

Last change on this file since 13664 was 13434, checked in by Don-vip, 6 years ago

see #8039, see #10456 - support read-only data layers

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.ActionEvent;
8import java.awt.event.KeyEvent;
9import java.util.Collection;
10
11import org.openstreetmap.josm.data.osm.OsmPrimitive;
12import org.openstreetmap.josm.gui.datatransfer.OsmTransferHandler;
13import org.openstreetmap.josm.tools.Shortcut;
14
15/**
16 * Action, to paste all tags from one primitive to another.
17 *
18 * It will take the primitive from the copy-paste buffer an apply all its tags
19 * to the selected primitive(s).
20 *
21 * @author David Earl
22 */
23public final class PasteTagsAction extends JosmAction {
24
25 private static final String HELP = ht("/Action/PasteTags");
26 private final OsmTransferHandler transferHandler = new OsmTransferHandler();
27
28 /**
29 * Constructs a new {@code PasteTagsAction}.
30 */
31 public PasteTagsAction() {
32 super(tr("Paste Tags"), "pastetags",
33 tr("Apply tags of contents of paste buffer to all selected items."),
34 Shortcut.registerShortcut("system:pastestyle", tr("Edit: {0}", tr("Paste Tags")),
35 KeyEvent.VK_V, Shortcut.CTRL_SHIFT), true);
36 putValue("help", HELP);
37 }
38
39 @Override
40 public void actionPerformed(ActionEvent e) {
41 Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();
42
43 if (selection.isEmpty())
44 return;
45
46 transferHandler.pasteTags(selection);
47 }
48
49 @Override
50 protected void updateEnabledState() {
51 updateEnabledStateOnCurrentSelection();
52 }
53
54 @Override
55 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
56 updateEnabledStateOnModifiableSelection(selection);
57 }
58}
Note: See TracBrowser for help on using the repository browser.