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

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

SonarQube - fix minor code issues

  • 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.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.LinkedList;
9import java.util.List;
10import java.util.Map.Entry;
11import java.util.function.IntFunction;
12import java.util.function.Supplier;
13
14import javax.swing.JTable;
15
16import org.openstreetmap.josm.data.osm.Tag;
17import org.openstreetmap.josm.data.osm.Tagged;
18import org.openstreetmap.josm.gui.MainApplication;
19import org.openstreetmap.josm.tools.Shortcut;
20
21/**
22 * Copy the key and value of all the tags to clipboard.
23 * @since 13521
24 */
25public class CopyAllKeyValueAction extends AbstractCopyAction {
26
27 /**
28 * Constructs a new {@code CopyAllKeyValueAction}.
29 * @param tagTable the tag table
30 * @param keyFn a function which returns the selected key for a given row index
31 * @param objectSp a supplier which returns the selected tagged object(s)
32 */
33 public CopyAllKeyValueAction(JTable tagTable, IntFunction<String> keyFn, Supplier<Collection<? extends Tagged>> objectSp) {
34 super(tagTable, keyFn, objectSp);
35 putValue(NAME, tr("Copy all Keys/Values"));
36 putValue(SHORT_DESCRIPTION, tr("Copy the key and value of all the tags to clipboard"));
37 Shortcut sc = Shortcut.registerShortcut("system:copytags", tr("Edit: {0}", tr("Copy Tags")), KeyEvent.CHAR_UNDEFINED, Shortcut.NONE);
38 MainApplication.registerActionShortcut(this, sc);
39 sc.setAccelerator(this);
40 }
41
42 @Override
43 protected Collection<String> getString(Tagged p, String key) {
44 List<String> r = new LinkedList<>();
45 for (Entry<String, String> kv : p.getKeys().entrySet()) {
46 r.add(new Tag(kv.getKey(), kv.getValue()).toString());
47 }
48 return r;
49 }
50}
Note: See TracBrowser for help on using the repository browser.