- Timestamp:
- 2013-11-28T17:41:26+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r6401 r6419 342 342 343 343 /** 344 * Returns the current value for the changeset source 345 * 346 * @return the current value for the changeset source 347 */ 348 protected String getUploadSource() { 349 return changesetSourceModel.getComment(); 350 } 351 352 /** 344 353 * Returns true if the dialog was canceled 345 354 * … … 402 411 403 412 /** 404 * returns true if the user wants to revisit, false if they405 * want to continue413 * Displays a warning message indicating that the upload comment is empty/short. 414 * @return true if the user wants to revisit, false if they want to continue 406 415 */ 407 416 protected boolean warnUploadComment() { 408 ExtendedDialog dlg = new ExtendedDialog(UploadDialog.this,417 return warnUploadTag( 409 418 tr("Please revise upload comment"), 410 new String[] {tr("Revise"), tr("Cancel"), tr("Continue as is")});411 dlg.setContent("<html>" +412 419 tr("Your upload comment is <i>empty</i>, or <i>very short</i>.<br /><br />" + 413 420 "This is technically allowed, but please consider that many users who are<br />" + … … 415 422 "to understand what is going on!<br /><br />" + 416 423 "If you spend a minute now to explain your change, you will make life<br />" + 417 "easier for many other mappers.") + 418 "</html>"); 424 "easier for many other mappers."), 425 "upload_comment_is_empty_or_very_short" 426 ); 427 } 428 429 /** 430 * Displays a warning message indicating that no changeset source is given. 431 * @return true if the user wants to revisit, false if they want to continue 432 */ 433 protected boolean warnUploadSource() { 434 return warnUploadTag( 435 tr("Please revise specify a changeset source"), 436 tr("You did not specify a source for your changes.<br />" + 437 "This is technically allowed, but it assists other users <br />" + 438 "to understand the origins of the data.<br /><br />" + 439 "If you spend a minute now to explain your change, you will make life<br />" + 440 "easier for many other mappers."), 441 "upload_source_is_empty" 442 ); 443 } 444 445 protected boolean warnUploadTag(final String title, final String message, final String togglePref) { 446 ExtendedDialog dlg = new ExtendedDialog(UploadDialog.this, 447 title, 448 new String[] {tr("Revise"), tr("Cancel"), tr("Continue as is")}); 449 dlg.setContent("<html>" + message + "</html>"); 419 450 dlg.setButtonIcons(new Icon[] { 420 451 ImageProvider.get("ok"), … … 429 460 tr("Ignore this hint and upload anyway")}); 430 461 dlg.setIcon(JOptionPane.WARNING_MESSAGE); 431 dlg.toggleEnable( "upload_comment_is_empty_or_very_short");462 dlg.toggleEnable(togglePref); 432 463 dlg.setToggleCheckboxText(tr("Do not show this message again")); 433 464 dlg.setCancelButton(1, 2); … … 447 478 @Override 448 479 public void actionPerformed(ActionEvent e) { 449 if (getUploadComment().trim().length() < 10) { 450 if (warnUploadComment()) 451 { 452 tpConfigPanels.setSelectedIndex(0); 453 pnlBasicUploadSettings.initEditingOfUploadComment(); 454 return; 455 } 480 if ((getUploadComment().trim().length() < 10 && warnUploadComment()) /* abort for missing comment */ 481 || (getUploadSource().trim().isEmpty() && warnUploadSource()) /* abort for missing changeset source */ 482 ) { 483 tpConfigPanels.setSelectedIndex(0); 484 pnlBasicUploadSettings.initEditingOfUploadComment(); 485 return; 456 486 } 457 487 … … 460 490 List<String> emptyChangesetTags = new ArrayList<String>(); 461 491 for (final Entry<String, String> i : pnlTagSettings.getTags(true).entrySet()) { 462 if ((i.getKey() == null || i.getKey().trim().isEmpty()) 463 ^ (i.getValue() == null || i.getValue().trim().isEmpty())) { 492 final boolean isKeyEmpty = i.getKey() == null || i.getKey().trim().isEmpty(); 493 final boolean isValueEmpty = i.getValue() == null || i.getValue().trim().isEmpty(); 494 final boolean ignoreKey = "comment".equals(i.getKey()) || "source".equals(i.getKey()); 495 if ((isKeyEmpty ^ isValueEmpty) && !ignoreKey) { 464 496 emptyChangesetTags.add(tr("{0}={1}", i.getKey(), i.getValue())); 465 497 }
Note:
See TracChangeset
for help on using the changeset viewer.