- Timestamp:
- 2013-08-26T01:17:52+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.