- Timestamp:
- 2013-08-26T01:17:52+02:00 (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/defaultpresets.xml
r6189 r6190 1056 1056 pt_BR.href="http://wiki.openstreetmap.org/wiki/Pt-br:Tag:highway=traffic_signals" 1057 1057 ru.href="http://wiki.openstreetmap.org/wiki/RU:Tag:highway=traffic_signals" /> 1058 <label text="Edit Traffic Signal" /> 1059 <space /> 1058 1060 <key key="highway" value="traffic_signals" /> 1059 <optional >1061 <optional text="Optional crossing attributes:"> 1060 1062 <combo key="crossing" text="Pedestrian crossing type" values="uncontrolled,traffic_signals,island,unmarked,no,unknown" /> 1063 <combo key="crossing_ref" text="Crossing type name (UK)" values="zebra,pelican,toucan,puffin,pegasus,tiger" /> 1064 <check key="supervised" text="Crossing attendant" default="off" /> 1065 <check key="bicycle" text="Cross by bicycle" default="off" /> 1061 1066 <check key="horse" text="Cross on horseback" default="off" /> 1062 <check key="bicycle" text="Cross by bicycle" default="off" />1063 <check key="supervised" text="Crossing attendant" default="off" />1064 <combo key="crossing_ref" text="Crossing type name (UK)" values="zebra,pelican,toucan,puffin,pegasus,tiger" />1065 1067 </optional> 1066 1068 </item> … … 1079 1081 ru.href="http://wiki.openstreetmap.org/wiki/RU:Tag:highway=mini_roundabout" /> 1080 1082 <key key="highway" value="mini_roundabout" /> 1083 <label text="Edit Mini-Roundabout" /> 1084 <space /> 1081 1085 <combo key="direction" text="Direction" values="clockwise" /> 1082 1086 </item> … … 1089 1093 pt_BR.href="http://wiki.openstreetmap.org/wiki/Pt-br:Key:crossing" 1090 1094 ru.href="http://wiki.openstreetmap.org/wiki/RU:Key:crossing" /> 1091 <label text="Edit Crossing" /> 1095 <label text="Edit Pedestrian Crossing" /> 1096 <space /> 1092 1097 <key key="highway" value="crossing" /> 1093 <combo key="crossing" text="Type" values="uncontrolled,traffic_signals,island,unmarked,no,unknown" /> 1098 <combo key="crossing" text="Pedestrian crossing type" values="uncontrolled,traffic_signals,island,unmarked,no,unknown" /> 1099 <combo key="crossing_ref" text="Crossing type name (UK)" values="zebra,pelican,toucan,puffin,pegasus,tiger" /> 1100 <check key="supervised" text="Crossing attendant" default="off" /> 1094 1101 <check key="bicycle" text="Cross by bicycle" default="off" /> 1095 1102 <check key="horse" text="Cross on horseback" default="off" /> 1096 <check key="supervised" text="Crossing attendant" default="off" />1097 <combo key="crossing_ref" text="Type name (UK)" values="zebra,pelican,toucan,puffin,pegasus,tiger" />1098 1103 </item> 1099 1104 <item name="Traffic Calming" icon="presets/chicane.png" type="node,way"> … … 1107 1112 ru.href="http://wiki.openstreetmap.org/wiki/RU:Key:traffic_calming"/> 1108 1113 <label text="Edit Traffic Calming" /> 1114 <space /> 1109 1115 <combo key="traffic_calming" text="Type" values="yes,bump,chicane,choker,cushion,hump,island,rumble_strip,table" match="key" /> 1110 1116 </item> -
trunk/data/tagging-preset.xsd
r6114 r6190 71 71 <complexType name="optional"> 72 72 <group ref="tns:optional_elements" maxOccurs="unbounded" /> 73 <attribute name="text" type="string" /> 74 <attribute name="text_context" type="string" /> 73 75 </complexType> 74 76 -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java
r6158 r6190 295 295 } 296 296 297 public static class Label extends TaggingPresetItem { 298 297 /** 298 * A tagging preset item displaying a localizable text. 299 * @since 6190 300 */ 301 public static abstract class TaggingPresetTextItem extends TaggingPresetItem { 302 303 /** 304 * The text to display 305 */ 299 306 public String text; 307 308 /** 309 * The context used for translating {@link #text} 310 */ 300 311 public String text_context; 312 313 /** 314 * The localized version of {@link #text} 315 */ 301 316 public String locale_text; 302 317 303 @Override 304 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 305 if (locale_text == null) { 306 if (text_context != null) { 307 locale_text = trc(text_context, fixPresetString(text)); 308 } else { 309 locale_text = tr(fixPresetString(text)); 310 } 311 } 312 p.add(new JLabel(locale_text), GBC.eol()); 313 return false; 314 } 315 316 @Override 317 public void addCommands(List<Tag> changedTags) { 318 } 319 320 @Override 321 public String toString() { 322 return "Label [" 323 + (text != null ? "text=" + text + ", " : "") 324 + (text_context != null ? "text_context=" + text_context 325 + ", " : "") 326 + (locale_text != null ? "locale_text=" + locale_text : "") 327 + "]"; 328 } 329 } 330 331 public static class Link extends TaggingPresetItem { 332 333 public String href; 334 public String text; 335 public String text_context; 336 public String locale_text; 337 public String locale_href; 338 339 @Override 340 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 318 protected final void initializeLocaleText(String defaultText) { 341 319 if (locale_text == null) { 342 320 if (text == null) { 343 locale_text = tr("More information about this feature");321 locale_text = defaultText; 344 322 } else if (text_context != null) { 345 323 locale_text = trc(text_context, fixPresetString(text)); … … 348 326 } 349 327 } 328 } 329 330 @Override 331 void addCommands(List<Tag> changedTags) { 332 } 333 334 protected String fieldsToString() { 335 return (text != null ? "text=" + text + ", " : "") 336 + (text_context != null ? "text_context=" + text_context + ", " : "") 337 + (locale_text != null ? "locale_text=" + locale_text : ""); 338 } 339 340 @Override 341 public String toString() { 342 return getClass().getSimpleName() + " [" + fieldsToString() + "]"; 343 } 344 } 345 346 public static class Label extends TaggingPresetTextItem { 347 348 @Override 349 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 350 initializeLocaleText(null); 351 p.add(new JLabel(locale_text), GBC.eol()); 352 return false; 353 } 354 } 355 356 public static class Link extends TaggingPresetTextItem { 357 358 /** 359 * The link to display 360 */ 361 public String href; 362 363 /** 364 * The localized version of {@link #href} 365 */ 366 public String locale_href; 367 368 @Override 369 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 370 initializeLocaleText(tr("More information about this feature")); 350 371 String url = locale_href; 351 372 if (url == null) { … … 359 380 360 381 @Override 361 public void addCommands(List<Tag> changedTags) { 382 protected String fieldsToString() { 383 return super.fieldsToString() 384 + (href != null ? "href=" + href + ", " : "") 385 + (locale_href != null ? "locale_href=" + locale_href + ", " : ""); 362 386 } 363 387 } … … 389 413 } 390 414 391 public static class Optional extends TaggingPreset Item {415 public static class Optional extends TaggingPresetTextItem { 392 416 393 417 // TODO: Draw a box around optional stuff 394 418 @Override 395 419 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 420 initializeLocaleText(tr("Optional Attributes:")); 396 421 p.add(new JLabel(" "), GBC.eol()); // space 397 p.add(new JLabel( tr("Optional Attributes:")), GBC.eol());422 p.add(new JLabel(locale_text), GBC.eol()); 398 423 p.add(new JLabel(" "), GBC.eol()); // space 399 424 return false; 400 }401 402 @Override403 public void addCommands(List<Tag> changedTags) {404 }405 406 @Override407 public String toString() {408 return "Optional";409 425 } 410 426 }
Note:
See TracChangeset
for help on using the changeset viewer.