1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.tagging.presets.items;
|
---|
3 |
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.data.osm.Tag;
|
---|
7 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem;
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * A tagging preset item displaying a localizable text.
|
---|
11 | * @since 6190
|
---|
12 | */
|
---|
13 | public abstract class TextItem extends TaggingPresetItem {
|
---|
14 |
|
---|
15 | /** The text to display */
|
---|
16 | public String text; // NOSONAR
|
---|
17 |
|
---|
18 | /** The context used for translating {@link #text} */
|
---|
19 | public String text_context; // NOSONAR
|
---|
20 |
|
---|
21 | /** The localized version of {@link #text} */
|
---|
22 | public String locale_text; // NOSONAR
|
---|
23 |
|
---|
24 | protected final void initializeLocaleText(String defaultText) {
|
---|
25 | if (locale_text == null) {
|
---|
26 | locale_text = getLocaleText(text, text_context, defaultText);
|
---|
27 | }
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | public void addCommands(List<Tag> changedTags) {
|
---|
32 | // Do nothing
|
---|
33 | }
|
---|
34 |
|
---|
35 | protected String fieldsToString() {
|
---|
36 | return (text != null ? "text=" + text + ", " : "")
|
---|
37 | + (text_context != null ? "text_context=" + text_context + ", " : "")
|
---|
38 | + (locale_text != null ? "locale_text=" + locale_text : "");
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Override
|
---|
42 | public String toString() {
|
---|
43 | return getClass().getSimpleName() + " [" + fieldsToString() + ']';
|
---|
44 | }
|
---|
45 | }
|
---|