Changeset 3849 in josm
- Timestamp:
- 2011-02-02T23:39:08+01:00 (14 years ago)
- 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 80 80 if (osm instanceof Way && ((Way) osm).isClosed()) 81 81 return true; 82 if (osm instanceof Relation && "multipolygon".equals(osm.get("type")))82 if (osm instanceof Relation && ((Relation) osm).isMultipolygon()) 83 83 return true; 84 84 return false; -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r3848 r3849 50 50 if (osm instanceof Way && ((Way)osm).isClosed()) 51 51 return true; 52 if (osm instanceof Relation && "multipolygon".equals(osm.get("type")))52 if (osm instanceof Relation && ((Relation) osm).isMultipolygon()) 53 53 return true; 54 54 } -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r3842 r3849 418 418 String def = default_; 419 419 420 String[] value_array = splitEscaped( values);420 String[] value_array = splitEscaped(',', values); 421 421 String[] display_array; 422 422 String[] short_descriptions_array = null; 423 423 424 424 if(locale_display_values != null) { 425 display_array = splitEscaped( locale_display_values);425 display_array = splitEscaped(',', locale_display_values); 426 426 } else if (display_values != null) { 427 display_array = splitEscaped( display_values);427 display_array = splitEscaped(',', display_values); 428 428 } else { 429 429 display_array = value_array; … … 431 431 432 432 if (locale_short_descriptions != null) { 433 short_descriptions_array = splitEscaped( locale_short_descriptions);433 short_descriptions_array = splitEscaped(',', locale_short_descriptions); 434 434 } else if (short_descriptions != null) { 435 short_descriptions_array = splitEscaped( short_descriptions);435 short_descriptions_array = splitEscaped(',', short_descriptions); 436 436 } else if (short_description_list != null) { 437 437 short_descriptions_array = short_description_list.toArray(new String[0]); … … 551 551 return lbl; 552 552 } 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()]);576 553 } 577 554 … … 700 677 String def = default_; 701 678 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); 703 685 String[] display_array; 704 686 String[] short_descriptions_array = null; 705 687 706 688 if (locale_display_values != null) { 707 display_array = splitEscaped(del imiter, locale_display_values);689 display_array = splitEscaped(delChar, locale_display_values); 708 690 } else if (display_values != null) { 709 display_array = splitEscaped(del imiter, display_values);691 display_array = splitEscaped(delChar, display_values); 710 692 } else { 711 693 display_array = value_array; … … 713 695 714 696 if (locale_short_descriptions != null) { 715 short_descriptions_array = splitEscaped(del imiter, locale_short_descriptions);697 short_descriptions_array = splitEscaped(delChar, locale_short_descriptions); 716 698 } else if (short_descriptions != null) { 717 short_descriptions_array = splitEscaped(del imiter, short_descriptions);699 short_descriptions_array = splitEscaped(delChar, short_descriptions); 718 700 } else if (short_description_list != null) { 719 701 short_descriptions_array = short_description_list.toArray(new String[0]); … … 817 799 } 818 800 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 829 801 @Override public void addCommands(List<Tag> changedTags) { 830 802 Object obj = list.getSelectedItem(); … … 871 843 872 844 @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()]); 873 873 } 874 874
Note:
See TracChangeset
for help on using the changeset viewer.