Changeset 3839 in josm
- Timestamp:
- 2011-02-01T08:28:03+01:00 (15 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
data/tagging-preset.xsd (modified) (12 diffs)
-
src/org/openstreetmap/josm/data/AutosaveTask.java (modified) (2 diffs)
-
src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java (modified) (6 diffs)
-
src/org/openstreetmap/josm/tools/PresetTextComparator.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/tagging-preset.xsd
r3793 r3839 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://josm.openstreetmap.de/tagging-preset-1.0" 3 xmlns:tns="http://josm.openstreetmap.de/tagging-preset-1.0" elementFormDefault="qualified"> 4 5 <!-- 6 Localized attributes (for example de.description are not supported by 7 xsd, so every element needs <anyAttribute/> 8 To cover at least some common errors, elements have specified prohibited attributes 9 --> 10 11 <element name="annotations" type="tns:root"/> 12 <element name="presets" type="tns:root"/> 3 xmlns:tns="http://josm.openstreetmap.de/tagging-preset-1.0" 4 elementFormDefault="qualified"> 5 6 <!-- Localized attributes (for example de.description are not supported 7 by xsd, so every element needs <anyAttribute/> To cover at least some common 8 errors, elements have specified prohibited attributes --> 9 10 <element name="annotations" type="tns:root" /> 11 <element name="presets" type="tns:root" /> 13 12 14 13 <complexType name="root"> 15 14 <complexContent> 16 <extension base="tns:group"> 15 <extension base="tns:group-parent"> 17 16 <attribute name="author" type="string" /> 18 17 <attribute name="version" type="string" /> 19 18 <attribute name="shortdescription" type="string" /> 20 19 <attribute name="description" type="string" /> 21 <attribute name="link" type="string"/> 22 23 <anyAttribute processContents="skip"/> 20 <attribute name="link" type="string" /> 21 22 <anyAttribute processContents="skip" /> 24 23 </extension> 25 24 </complexContent> 26 25 </complexType> 27 26 28 <complexType name="group"> 27 <complexType name="group-parent"> 29 28 <sequence> 30 29 <choice minOccurs="1" maxOccurs="unbounded"> … … 34 33 </choice> 35 34 </sequence> 36 <attribute name="name" type="string" />37 35 <attribute name="icon" type="string" /> 38 36 39 <attribute name="type" use="prohibited"/> 40 <attribute name="text" use="prohibited"/> 41 <anyAttribute processContents="skip"/> 37 <attribute name="type" use="prohibited" /> 38 <attribute name="text" use="prohibited" /> 39 <anyAttribute processContents="skip" /> 40 </complexType> 41 42 <complexType name="group"> 43 <complexContent> 44 <extension base="tns:group-parent"> 45 <attribute name="name" type="string" use="required" /> 46 </extension> 47 </complexContent> 42 48 </complexType> 43 49 … … 53 59 <element name="roles" type="tns:roles" minOccurs="0" /> 54 60 </sequence> 55 <attribute name="name" type="string" /> 61 <attribute name="name" type="string" use="required" /> 56 62 <attribute name="icon" type="string" /> 57 63 <attribute name="type" type="string" /> 58 64 59 <attribute name="text" use="prohibited"/> 60 <anyAttribute processContents="skip"/> 65 <attribute name="text" use="prohibited" /> 66 <anyAttribute processContents="skip" /> 61 67 </complexType> 62 68 … … 78 84 79 85 <complexType name="key"> 80 <attribute name="key" type="string" use="required"/> 81 <attribute name="value" type="string"/> 86 <attribute name="key" type="string" use="required" /> 87 <attribute name="value" type="string" /> 82 88 </complexType> 83 89 … … 88 94 <attribute name="text_context" type="string" /> 89 95 90 <attribute name="name" use="prohibited"/> 91 <anyAttribute processContents="skip"/> 96 <attribute name="name" use="prohibited" /> 97 <anyAttribute processContents="skip" /> 92 98 </complexType> 93 99 … … 96 102 <attribute name="text_context" type="string" /> 97 103 98 <attribute name="name" use="prohibited"/> 99 <anyAttribute processContents="skip"/> 104 <attribute name="name" use="prohibited" /> 105 <anyAttribute processContents="skip" /> 100 106 </complexType> 101 107 … … 103 109 104 110 <complexType name="text"> 105 <attribute name="key" type="string" use="required"/> 111 <attribute name="key" type="string" use="required" /> 106 112 <attribute name="text" type="string" /> 107 113 <attribute name="text_context" type="string" /> … … 109 115 <attribute name="delete_if_empty" type="boolean" /> 110 116 <attribute name="use_last_as_default" type="boolean" /> 111 <attribute name="required" type="boolean"/> 112 113 <attribute name="type" use="prohibited"/> 114 <attribute name="name" use="prohibited"/> 115 <attribute name="value" use="prohibited"/> 116 <attribute name="values" use="prohibited"/> 117 <anyAttribute processContents="skip"/> 117 <attribute name="required" type="boolean" /> 118 119 <attribute name="type" use="prohibited" /> 120 <attribute name="name" use="prohibited" /> 121 <attribute name="value" use="prohibited" /> 122 <attribute name="values" use="prohibited" /> 123 <anyAttribute processContents="skip" /> 118 124 </complexType> 119 125 120 126 <complexType name="combo"> 121 127 <sequence> 122 <element name="short_description" type="string" minOccurs="0" maxOccurs="unbounded"/> 128 <element name="short_description" type="string" minOccurs="0" 129 maxOccurs="unbounded" /> 123 130 </sequence> 124 131 <attribute name="key" type="string" use="required" /> … … 127 134 <attribute name="values" type="string" use="required" /> 128 135 <attribute name="values_context" type="string" /> 129 <attribute name="display_values" type="string"/> 136 <attribute name="display_values" type="string" /> 130 137 <attribute name="default" type="string" /> 131 138 <attribute name="editable" type="boolean" /> 132 139 <attribute name="delete_if_empty" type="boolean" /> 133 <attribute name="required" type="boolean"/> 134 135 <attribute name="type" use="prohibited"/> 136 <attribute name="value" use="prohibited"/> 137 <attribute name="name" use="prohibited"/> 138 <attribute name="delete-if-empty" use="prohibited"/> 139 <attribute name="display-values" use="prohibited"/> 140 <anyAttribute processContents="skip"/> 140 <attribute name="required" type="boolean" /> 141 142 <attribute name="type" use="prohibited" /> 143 <attribute name="value" use="prohibited" /> 144 <attribute name="name" use="prohibited" /> 145 <attribute name="delete-if-empty" use="prohibited" /> 146 <attribute name="display-values" use="prohibited" /> 147 <anyAttribute processContents="skip" /> 141 148 </complexType> 142 149 … … 147 154 <attribute name="values" type="string" use="required" /> 148 155 <attribute name="values_context" type="string" /> 149 <attribute name="display_values" type="string"/> 156 <attribute name="display_values" type="string" /> 150 157 <attribute name="default" type="string" /> 151 158 <attribute name="delimiter" type="string" /> 152 159 <attribute name="delete_if_empty" type="boolean" /> 153 <attribute name="required" type="boolean"/> 154 155 <attribute name="type" use="prohibited"/> 156 <attribute name="value" use="prohibited"/> 157 <attribute name="name" use="prohibited"/> 158 <attribute name="delete-if-empty" use="prohibited"/> 159 <attribute name="display-values" use="prohibited"/> 160 <anyAttribute processContents="skip"/> 160 <attribute name="required" type="boolean" /> 161 162 <attribute name="type" use="prohibited" /> 163 <attribute name="value" use="prohibited" /> 164 <attribute name="name" use="prohibited" /> 165 <attribute name="delete-if-empty" use="prohibited" /> 166 <attribute name="display-values" use="prohibited" /> 167 <anyAttribute processContents="skip" /> 161 168 </complexType> 162 169 … … 167 174 <attribute name="default" type="tns:check_default" /> 168 175 <attribute name="use_last_as_default" type="boolean" /> 169 <attribute name="required" type="boolean"/> 170 <attribute name="value_on" type="string"/> 171 <attribute name="value_off" type="string"/> 172 173 <attribute name="name" use="prohibited"/> 174 <attribute name="type" use="prohibited"/> 175 <attribute name="value" use="prohibited"/> 176 <anyAttribute processContents="skip"/> 176 <attribute name="required" type="boolean" /> 177 <attribute name="value_on" type="string" /> 178 <attribute name="value_off" type="string" /> 179 180 <attribute name="name" use="prohibited" /> 181 <attribute name="type" use="prohibited" /> 182 <attribute name="value" use="prohibited" /> 183 <anyAttribute processContents="skip" /> 177 184 </complexType> 178 185 … … 186 193 <complexType name="roles"> 187 194 <sequence> 188 <element name="role" type="tns:role" minOccurs="1" maxOccurs="unbounded"/> 195 <element name="role" type="tns:role" minOccurs="1" maxOccurs="unbounded" /> 189 196 </sequence> 190 197 </complexType> 191 198 192 199 <complexType name="role"> 193 <attribute name="key" type="string"/> 194 <attribute name="text" type="string"/> 195 <attribute name="text_context" type="string"/> 196 <attribute name="requisite" type="tns:role_requisite"/> 197 <attribute name="type" type="string"/> 198 <attribute name="count" type="integer"/> 199 <attribute name="required" type="boolean"/> 200 <attribute name="key" type="string" /> 201 <attribute name="text" type="string" /> 202 <attribute name="text_context" type="string" /> 203 <attribute name="requisite" type="tns:role_requisite" /> 204 <attribute name="type" type="string" /> 205 <attribute name="count" type="integer" /> 206 <attribute name="required" type="boolean" /> 200 207 </complexType> 201 208 202 209 <simpleType name="role_requisite"> 203 210 <restriction base="string"> 204 <enumeration value="required"/> 205 <enumeration value="optional"/> 211 <enumeration value="required" /> 212 <enumeration value="optional" /> 206 213 </restriction> 207 214 </simpleType> -
trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
r3720 r3839 7 7 import java.io.IOException; 8 8 import java.util.ArrayList; 9 import java.util.Arrays;10 9 import java.util.Date; 11 10 import java.util.Deque; … … 274 273 moveToDeletedLayersFolder(f); 275 274 } 276 } 275 } 277 276 }); 278 277 } -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r3796 r3839 11 11 import java.awt.Image; 12 12 import java.awt.Insets; 13 import java.awt.Color;14 13 import java.awt.event.ActionEvent; 15 14 import java.io.BufferedReader; … … 182 181 } 183 182 184 protected static class PresetListEntry {185 String value;186 String display_value;187 String short_description;188 189 public String getListDisplay() {190 if (value.equals(DIFFERENT))191 return "<b>"+DIFFERENT.replaceAll("<", "<").replaceAll(">", ">")+"</b>";192 193 if (value.equals(""))194 return " ";195 196 StringBuilder res = new StringBuilder("<b>");197 if (display_value != null) {198 res.append(display_value);199 } else {200 res.append(value);201 }202 res.append("</b>");203 if (short_description != null) {204 // wrap in table to restrict the text width205 res.append("<br><table><td width='232'>(").append(short_description).append(")</td></table>");206 }207 return res.toString();208 }209 210 public PresetListEntry(String value) {211 this.value = value;212 this.display_value = value;213 }214 215 public PresetListEntry(String value, String display_value) {216 this.value = value;217 this.display_value = display_value;218 }219 220 // toString is mainly used to initialize the Editor221 @Override222 public String toString() {223 if (value.equals(DIFFERENT))224 return DIFFERENT;225 return display_value.replaceAll("<.*>", ""); // remove additional markup, e.g. <br>226 }227 }183 protected static class PresetListEntry { 184 String value; 185 String display_value; 186 String short_description; 187 188 public String getListDisplay() { 189 if (value.equals(DIFFERENT)) 190 return "<b>"+DIFFERENT.replaceAll("<", "<").replaceAll(">", ">")+"</b>"; 191 192 if (value.equals("")) 193 return " "; 194 195 StringBuilder res = new StringBuilder("<b>"); 196 if (display_value != null) { 197 res.append(display_value); 198 } else { 199 res.append(value); 200 } 201 res.append("</b>"); 202 if (short_description != null) { 203 // wrap in table to restrict the text width 204 res.append("<br><table><td width='232'>(").append(short_description).append(")</td></table>"); 205 } 206 return res.toString(); 207 } 208 209 public PresetListEntry(String value) { 210 this.value = value; 211 this.display_value = value; 212 } 213 214 public PresetListEntry(String value, String display_value) { 215 this.value = value; 216 this.display_value = display_value; 217 } 218 219 // toString is mainly used to initialize the Editor 220 @Override 221 public String toString() { 222 if (value.equals(DIFFERENT)) 223 return DIFFERENT; 224 return display_value.replaceAll("<.*>", ""); // remove additional markup, e.g. <br> 225 } 226 } 228 227 229 228 public static class Text extends Item { … … 460 459 PresetListEntry e = new PresetListEntry(value_array[i]); 461 460 e.display_value = (locale_display_values == null) 462 ? (values_context == null ? tr(display_array[i])463 : trc(values_context, display_array[i])) : display_array[i];461 ? (values_context == null ? tr(display_array[i]) 462 : trc(values_context, display_array[i])) : display_array[i]; 464 463 if (short_descriptions_array != null) { 465 464 e.short_description = locale_short_descriptions == null ? tr(short_descriptions_array[i]) … … 633 632 int j = 0; 634 633 for (int i = 0; i < lm.getSize(); i++) { 635 if (parts.contains((((PresetListEntry)lm.getElementAt(i)).value))) 634 if (parts.contains((((PresetListEntry)lm.getElementAt(i)).value))) { 636 635 intParts[j++]=i; 636 } 637 637 } 638 638 setSelectedIndices(Arrays.copyOf(intParts, j)); 639 // check if we have acutally managed to represent the full 639 // check if we have acutally managed to represent the full 640 640 // value with our presets. if not, cop out; we will not offer 641 641 // a selection list that threatens to ruin the value. … … 647 647 int[] si = getSelectedIndices(); 648 648 StringBuilder builder = new StringBuilder(); 649 for (int i=0; i<si.length; i++) { 650 if (i>0) builder.append(delimiter); 649 for (int i=0; i<si.length; i++) { 650 if (i>0) { 651 builder.append(delimiter); 652 } 651 653 builder.append(((PresetListEntry)lm.getElementAt(si[i])).value); 652 654 } … … 726 728 PresetListEntry e = new PresetListEntry(value_array[i]); 727 729 e.display_value = (locale_display_values == null) 728 ? (values_context == null ? tr(display_array[i])729 : trc(values_context, display_array[i])) : display_array[i];730 ? (values_context == null ? tr(display_array[i]) 731 : trc(values_context, display_array[i])) : display_array[i]; 730 732 if (short_descriptions_array != null) { 731 733 e.short_description = locale_short_descriptions == null ? tr(short_descriptions_array[i]) -
trunk/src/org/openstreetmap/josm/tools/PresetTextComparator.java
r3719 r3839 7 7 import javax.swing.JMenuItem; 8 8 9 import org.openstreetmap.josm.Main; 10 9 11 public class PresetTextComparator implements Comparator<JMenuItem>, Serializable { 10 //TODO add error checking and stuff11 12 public int compare(JMenuItem arg0, JMenuItem arg1) { 12 return arg0.getText().compareTo(arg1.getText()); 13 if (Main.main.menu.presetSearchAction.equals(arg0.getAction())) 14 return -1; 15 else if (Main.main.menu.presetSearchAction.equals(arg0.getAction())) 16 return 1; 17 else if (arg0.getText() == arg1.getText()) 18 return 0; 19 else if (arg0.getText() == null) 20 return -1; 21 else if (arg1.getText() == null) 22 return 1; 23 else 24 return arg0.getText().compareTo(arg1.getText()); 13 25 } 14 26
Note:
See TracChangeset
for help on using the changeset viewer.
