source: josm/trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Key.java@ 12042

Last change on this file since 12042 was 9665, checked in by stoecker, 8 years ago

fix eol-style issues and similar formating stuff, see #12410

File size: 1.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.tagging.presets.items;
3
4import java.util.Collection;
5import java.util.Collections;
6import java.util.List;
7
8import javax.swing.JPanel;
9
10import org.openstreetmap.josm.data.osm.OsmPrimitive;
11import org.openstreetmap.josm.data.osm.Tag;
12
13/**
14 * Invisible type allowing to hardcode an OSM key/value from the preset definition.
15 */
16public class Key extends KeyedItem {
17
18 /** The hardcoded value for key */
19 public String value; // NOSONAR
20
21 @Override
22 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {
23 return false;
24 }
25
26 @Override
27 public void addCommands(List<Tag> changedTags) {
28 changedTags.add(asTag());
29 }
30
31 /**
32 * Returns the {@link Tag} set by this item
33 * @return the tag
34 */
35 public Tag asTag() {
36 return new Tag(key, value);
37 }
38
39 @Override
40 public MatchType getDefaultMatch() {
41 return MatchType.KEY_VALUE_REQUIRED;
42 }
43
44 @Override
45 public Collection<String> getValues() {
46 return Collections.singleton(value);
47 }
48
49 @Override
50 public String toString() {
51 return "Key [key=" + key + ", value=" + value + ", text=" + text
52 + ", text_context=" + text_context + ", match=" + match
53 + ']';
54 }
55}
Note: See TracBrowser for help on using the repository browser.