001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.dialogs.properties; 003 004import static org.openstreetmap.josm.tools.I18n.tr; 005 006import java.util.Collection; 007import java.util.Collections; 008import java.util.function.IntFunction; 009import java.util.function.Supplier; 010 011import javax.swing.JTable; 012 013import org.openstreetmap.josm.data.osm.Tagged; 014 015/** 016 * Copy the value of the selected tag to clipboard. 017 * @since 13521 018 */ 019public class CopyValueAction extends AbstractCopyAction { 020 021 /** 022 * Constructs a new {@code CopyValueAction}. 023 * @param tagTable the tag table 024 * @param keyFn a function which returns the selected key for a given row index 025 * @param objectSp a supplier which returns the selected tagged object(s) 026 */ 027 public CopyValueAction(JTable tagTable, IntFunction<String> keyFn, Supplier<Collection<? extends Tagged>> objectSp) { 028 super(tagTable, keyFn, objectSp); 029 putValue(NAME, tr("Copy Value")); 030 putValue(SHORT_DESCRIPTION, tr("Copy the value of the selected tag to clipboard")); 031 } 032 033 @Override 034 protected Collection<String> getString(Tagged p, String key) { 035 String v = p.get(key); 036 return v == null ? null : Collections.singleton(v); 037 } 038}