1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.tagging.presets.items;
|
---|
3 |
|
---|
4 | import java.util.Collection;
|
---|
5 | import java.util.Collections;
|
---|
6 | import java.util.List;
|
---|
7 |
|
---|
8 | import javax.swing.JPanel;
|
---|
9 |
|
---|
10 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
11 | import org.openstreetmap.josm.data.osm.Tag;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * Invisible type allowing to hardcode an OSM key/value from the preset definition.
|
---|
15 | */
|
---|
16 | public 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 | }
|
---|