Changeset 5159 in josm


Ignore:
Timestamp:
Apr 1, 2012 10:20:11 PM (14 months ago)
Author:
simon04
Message:

see #7552 - damn confusion with Greek letters: apply delta instead of gamma patch ;-) (translation should work correctly now)

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r5158 r5159  
    7777import org.openstreetmap.josm.tools.ImageProvider; 
    7878import org.openstreetmap.josm.tools.UrlLabel; 
     79import org.openstreetmap.josm.tools.Utils; 
    7980import org.openstreetmap.josm.tools.XmlObjectParser; 
    8081import org.openstreetmap.josm.tools.template_engine.ParseError; 
     
    268269        public String short_description; 
    269270        public String icon; 
     271        public String locale_display_value; 
     272        public String locale_short_description; 
    270273 
    271274        public String getListDisplay() { 
     
    276279                return " "; 
    277280 
    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); 
    284284            res.append("</b>"); 
    285             if (short_description != null) { 
     285            final String descr = Utils.firstNonNull(locale_short_description, tr(short_description)); 
     286            if (descr != null) { 
    286287                // 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>"); 
    288289            } 
    289290            return res.toString(); 
     
    299300        public PresetListEntry(String value) { 
    300301            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; 
    307302        } 
    308303 
     
    593588 
    594589        private String[] initListEntriesFromAttributes() { 
    595  
    596590            char delChar = getDelChar(); 
    597591 
    598592            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); 
    615599 
    616600            if (display_array.length != value_array.length) { 
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r5132 r5159  
    6363    } 
    6464 
    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    } 
    6877 
    6978    /** 
Note: See TracChangeset for help on using the changeset viewer.