Changeset 3849 in josm


Ignore:
Timestamp:
Feb 2, 2011 11:39:08 PM (2 years ago)
Author:
bastiK
Message:

continue fixes by jttt and stoecker

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java

    r3848 r3849  
    8080                if (osm instanceof Way && ((Way) osm).isClosed()) 
    8181                    return true; 
    82                 if (osm instanceof Relation && "multipolygon".equals(osm.get("type"))) 
     82                if (osm instanceof Relation && ((Relation) osm).isMultipolygon()) 
    8383                    return true; 
    8484                return false; 
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

    r3848 r3849  
    5050            if (osm instanceof Way && ((Way)osm).isClosed()) 
    5151                return true; 
    52             if (osm instanceof Relation && "multipolygon".equals(osm.get("type"))) 
     52            if (osm instanceof Relation && ((Relation) osm).isMultipolygon()) 
    5353                return true; 
    5454        } 
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r3842 r3849  
    418418            String def = default_; 
    419419 
    420             String[] value_array = splitEscaped(values); 
     420            String[] value_array = splitEscaped(',', values); 
    421421            String[] display_array; 
    422422            String[] short_descriptions_array = null; 
    423423 
    424424            if(locale_display_values != null) { 
    425                 display_array = splitEscaped(locale_display_values); 
     425                display_array = splitEscaped(',', locale_display_values); 
    426426            } else if (display_values != null) { 
    427                 display_array = splitEscaped(display_values); 
     427                display_array = splitEscaped(',', display_values); 
    428428            } else { 
    429429                display_array = value_array; 
     
    431431 
    432432            if (locale_short_descriptions != null) { 
    433                 short_descriptions_array = splitEscaped(locale_short_descriptions); 
     433                short_descriptions_array = splitEscaped(',', locale_short_descriptions); 
    434434            } else if (short_descriptions != null) { 
    435                 short_descriptions_array = splitEscaped(short_descriptions); 
     435                short_descriptions_array = splitEscaped(',', short_descriptions); 
    436436            } else if (short_description_list != null) { 
    437437                short_descriptions_array = short_description_list.toArray(new String[0]); 
     
    551551                return lbl; 
    552552            } 
    553         } 
    554  
    555         // allow escaped comma in comma separated list: 
    556         // "A\, B\, C,one\, two" --> ["A, B, C", "one, two"] 
    557         private static String[] splitEscaped(String s) { 
    558             List<String> result = new ArrayList<String>(); 
    559             boolean backslash = false; 
    560             StringBuffer item = new StringBuffer(); 
    561             for (int i=0; i<s.length(); i++) { 
    562                 char ch = s.charAt(i); 
    563                 if (backslash) { 
    564                     item.append(ch); 
    565                     backslash = false; 
    566                 } else if (ch == '\\') { 
    567                     backslash = true; 
    568                 } else if (ch == ',') { 
    569                     result.add(item.toString()); 
    570                     item.setLength(0); 
    571                 } else { 
    572                     item.append(ch); 
    573                 } 
    574             } 
    575             return result.toArray(new String[result.size()]); 
    576553        } 
    577554 
     
    700677            String def = default_; 
    701678 
    702             String[] value_array = values.split(delimiter); 
     679            char delChar = ';'; 
     680            if (delimiter.length() > 0) { 
     681                delChar = delimiter.charAt(0); 
     682            } 
     683 
     684            String[] value_array = splitEscaped(delChar, values); 
    703685            String[] display_array; 
    704686            String[] short_descriptions_array = null; 
    705687 
    706688            if (locale_display_values != null) { 
    707                 display_array = splitEscaped(delimiter, locale_display_values); 
     689                display_array = splitEscaped(delChar, locale_display_values); 
    708690            } else if (display_values != null) { 
    709                 display_array = splitEscaped(delimiter, display_values); 
     691                display_array = splitEscaped(delChar, display_values); 
    710692            } else { 
    711693                display_array = value_array; 
     
    713695 
    714696            if (locale_short_descriptions != null) { 
    715                 short_descriptions_array = splitEscaped(delimiter, locale_short_descriptions); 
     697                short_descriptions_array = splitEscaped(delChar, locale_short_descriptions); 
    716698            } else if (short_descriptions != null) { 
    717                 short_descriptions_array = splitEscaped(delimiter, short_descriptions); 
     699                short_descriptions_array = splitEscaped(delChar, short_descriptions); 
    718700            } else if (short_description_list != null) { 
    719701                short_descriptions_array = short_description_list.toArray(new String[0]); 
     
    817799        } 
    818800 
    819         // allow escaped delimiter in comma separated list: 
    820         // "A\, B\, C,one\, two" --> ["A, B, C", "one, two"] 
    821         private static String[] splitEscaped(String delimiter, String s) { 
    822             String[] res = s.replaceAll("\\\\,", "\u0091").split(delimiter); 
    823             for (int i=0; i<res.length; ++i) { 
    824                 res[i] = res[i].replaceAll("\u0091", delimiter); 
    825             } 
    826             return res; 
    827         } 
    828  
    829801        @Override public void addCommands(List<Tag> changedTags) { 
    830802            Object obj = list.getSelectedItem(); 
     
    871843 
    872844        @Override boolean requestFocusInWindow() {return list.requestFocusInWindow();} 
     845    } 
     846 
     847    /** 
     848     * allow escaped comma in comma separated list: 
     849     * "A\, B\, C,one\, two" --> ["A, B, C", "one, two"] 
     850     * @param delimiter the delimiter, e.g. a comma. separates the entries and 
     851     *      must be escaped within one entry 
     852     * @param s the string 
     853     */ 
     854    private static String[] splitEscaped(char delemiter, String s) { 
     855        List<String> result = new ArrayList<String>(); 
     856        boolean backslash = false; 
     857        StringBuilder item = new StringBuilder(); 
     858        for (int i=0; i<s.length(); i++) { 
     859            char ch = s.charAt(i); 
     860            if (backslash) { 
     861                item.append(ch); 
     862                backslash = false; 
     863            } else if (ch == '\\') { 
     864                backslash = true; 
     865            } else if (ch == delemiter) { 
     866                result.add(item.toString()); 
     867                item.setLength(0); 
     868            } else { 
     869                item.append(ch); 
     870            } 
     871        } 
     872        return result.toArray(new String[result.size()]); 
    873873    } 
    874874 
Note: See TracChangeset for help on using the changeset viewer.