1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.dialogs.properties;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.util.Collection;
|
---|
7 | import java.util.Collections;
|
---|
8 | import java.util.function.IntFunction;
|
---|
9 | import java.util.function.Supplier;
|
---|
10 |
|
---|
11 | import javax.swing.JTable;
|
---|
12 |
|
---|
13 | import org.openstreetmap.josm.data.osm.Tagged;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Copy the value of the selected tag to clipboard.
|
---|
17 | * @since 13521
|
---|
18 | */
|
---|
19 | public class CopyValueAction extends AbstractCopyAction {
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Constructs a new {@code CopyValueAction}.
|
---|
23 | * @param tagTable the tag table
|
---|
24 | * @param keyFn a function which returns the selected key for a given row index
|
---|
25 | * @param objectSp a supplier which returns the selected tagged object(s)
|
---|
26 | */
|
---|
27 | public CopyValueAction(JTable tagTable, IntFunction<String> keyFn, Supplier<Collection<? extends Tagged>> objectSp) {
|
---|
28 | super(tagTable, keyFn, objectSp);
|
---|
29 | putValue(NAME, tr("Copy Value"));
|
---|
30 | putValue(SHORT_DESCRIPTION, tr("Copy the value of the selected tag to clipboard"));
|
---|
31 | }
|
---|
32 |
|
---|
33 | @Override
|
---|
34 | protected Collection<String> getString(Tagged p, String key) {
|
---|
35 | String v = p.get(key);
|
---|
36 | return v == null ? null : Collections.singleton(v);
|
---|
37 | }
|
---|
38 | }
|
---|