001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.tagging.presets.items; 003 004import java.util.Collection; 005import java.util.Collections; 006import java.util.List; 007 008import javax.swing.JPanel; 009 010import org.openstreetmap.josm.data.osm.OsmPrimitive; 011import org.openstreetmap.josm.data.osm.Tag; 012 013/** 014 * Invisible type allowing to hardcode an OSM key/value from the preset definition. 015 */ 016public class Key extends KeyedItem { 017 018 /** The hardcoded value for key */ 019 public String value; 020 021 @Override 022 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 023 return false; 024 } 025 026 @Override 027 public void addCommands(List<Tag> changedTags) { 028 changedTags.add(new Tag(key, value)); 029 } 030 031 @Override 032 public MatchType getDefaultMatch() { 033 return MatchType.KEY_VALUE_REQUIRED; 034 } 035 036 @Override 037 public Collection<String> getValues() { 038 return Collections.singleton(value); 039 } 040 041 @Override 042 public String toString() { 043 return "Key [key=" + key + ", value=" + value + ", text=" + text 044 + ", text_context=" + text_context + ", match=" + match 045 + ']'; 046 } 047}