source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/properties/CopyAllKeyValueAction.java@ 17032

Last change on this file since 17032 was 17032, checked in by Klumbumbus, 4 years ago

Add missing icons in Tags/Membership Dialog context menu, fix icons of HelpAction and SelectInRelationListAction

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.properties;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.KeyEvent;
7import java.util.Collection;
8import java.util.function.IntFunction;
9import java.util.function.Supplier;
10import java.util.stream.Collectors;
11
12import javax.swing.JTable;
13
14import org.openstreetmap.josm.data.osm.Tag;
15import org.openstreetmap.josm.data.osm.Tagged;
16import org.openstreetmap.josm.gui.MainApplication;
17import org.openstreetmap.josm.tools.Shortcut;
18import org.openstreetmap.josm.tools.ImageProvider;
19
20/**
21 * Copy the key and value of all the tags to clipboard.
22 * @since 13521
23 */
24public class CopyAllKeyValueAction extends AbstractCopyAction {
25
26 /**
27 * Constructs a new {@code CopyAllKeyValueAction}.
28 * @param tagTable the tag table
29 * @param keyFn a function which returns the selected key for a given row index
30 * @param objectSp a supplier which returns the selected tagged object(s)
31 */
32 public CopyAllKeyValueAction(JTable tagTable, IntFunction<String> keyFn, Supplier<Collection<? extends Tagged>> objectSp) {
33 super(tagTable, keyFn, objectSp);
34 putValue(NAME, tr("Copy all Keys/Values"));
35 putValue(SHORT_DESCRIPTION, tr("Copy the key and value of all the tags to clipboard"));
36 new ImageProvider("copy").getResource().attachImageIcon(this, true);
37 }
38
39 /**
40 * Registers this action shortcut
41 * @return this instance, for easy chaining
42 */
43 CopyAllKeyValueAction registerShortcut() {
44 Shortcut sc = Shortcut.registerShortcut("system:copytags", tr("Edit: {0}", tr("Copy Tags")), KeyEvent.CHAR_UNDEFINED, Shortcut.NONE);
45 MainApplication.registerActionShortcut(this, sc);
46 sc.setAccelerator(this);
47 return this;
48 }
49
50 @Override
51 protected Collection<String> getString(Tagged p, String key) {
52 return p.getKeys().entrySet().stream()
53 .map(kv -> new Tag(kv.getKey(), kv.getValue()).toString())
54 .collect(Collectors.toList());
55 }
56}
Note: See TracBrowser for help on using the repository browser.