Changeset 5159 in josm for trunk/src/org
- Timestamp:
- 2012-04-01T22:20:11+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r5158 r5159 77 77 import org.openstreetmap.josm.tools.ImageProvider; 78 78 import org.openstreetmap.josm.tools.UrlLabel; 79 import org.openstreetmap.josm.tools.Utils; 79 80 import org.openstreetmap.josm.tools.XmlObjectParser; 80 81 import org.openstreetmap.josm.tools.template_engine.ParseError; … … 268 269 public String short_description; 269 270 public String icon; 271 public String locale_display_value; 272 public String locale_short_description; 270 273 271 274 public String getListDisplay() { … … 276 279 return " "; 277 280 278 StringBuilder res = new StringBuilder("<b>"); 279 if (display_value != null) { 280 res.append(display_value); 281 } else { 282 res.append(value); 283 } 281 final StringBuilder res = new StringBuilder("<b>"); 282 final String displ = Utils.firstNonNull(locale_display_value, tr(display_value), tr(value)); 283 res.append(displ); 284 284 res.append("</b>"); 285 if (short_description != null) { 285 final String descr = Utils.firstNonNull(locale_short_description, tr(short_description)); 286 if (descr != null) { 286 287 // wrap in table to restrict the text width 287 res.append("<div style=\"width:300px; padding:0 0 5px 5px\">").append( short_description).append("</div>");288 res.append("<div style=\"width:300px; padding:0 0 5px 5px\">").append(descr).append("</div>"); 288 289 } 289 290 return res.toString(); … … 299 300 public PresetListEntry(String value) { 300 301 this.value = value; 301 this.display_value = value;302 }303 304 public PresetListEntry(String value, String display_value) {305 this.value = value;306 this.display_value = display_value;307 302 } 308 303 … … 593 588 594 589 private String[] initListEntriesFromAttributes() { 595 596 590 char delChar = getDelChar(); 597 591 598 592 String[] value_array = splitEscaped(delChar, values); 599 String[] display_array; 600 String[] short_descriptions_array = null; 601 602 if (locale_display_values != null) { 603 display_array = splitEscaped(delChar, locale_display_values); 604 } else if (display_values != null) { 605 display_array = splitEscaped(delChar, display_values); 606 } else { 607 display_array = value_array; 608 } 609 610 if (locale_short_descriptions != null) { 611 short_descriptions_array = splitEscaped(delChar, locale_short_descriptions); 612 } else if (short_descriptions != null) { 613 short_descriptions_array = splitEscaped(delChar, short_descriptions); 614 } 593 594 final String displ = Utils.firstNonNull(locale_display_values, display_values); 595 String[] display_array = displ == null ? value_array : splitEscaped(delChar, displ); 596 597 final String descr = Utils.firstNonNull(locale_short_descriptions, short_descriptions); 598 String[] short_descriptions_array = descr == null ? null : splitEscaped(delChar, descr); 615 599 616 600 if (display_array.length != value_array.length) { -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r5132 r5159 63 63 } 64 64 65 public static <T> Collection<T> filter(Collection<? extends T> collection, Predicate<? super T> predicate) { 66 return new FilteredCollection<T>(collection, predicate); 67 } 65 public static <T> Collection<T> filter(Collection<? extends T> collection, Predicate<? super T> predicate) { 66 return new FilteredCollection<T>(collection, predicate); 67 } 68 69 public static <T> T firstNonNull(T... items) { 70 for (T i : items) { 71 if (i != null) { 72 return i; 73 } 74 } 75 return null; 76 } 68 77 69 78 /**
Note:
See TracChangeset
for help on using the changeset viewer.