Ticket #20823: patch-20823.patch

File patch-20823.patch, 5.1 KB (added by ljdelight, 5 years ago)
  • src/org/openstreetmap/josm/gui/io/UploadTextComponentValidator.java

    diff --git src/org/openstreetmap/josm/gui/io/UploadTextComponentValidator.java src/org/openstreetmap/josm/gui/io/UploadTextComponentValidator.java
    index 5d22d2b66..f6f60b671 100644
    import org.openstreetmap.josm.tools.Utils;  
    2121 */
    2222abstract class UploadTextComponentValidator extends AbstractTextComponentValidator {
    2323    private final JLabel feedback;
    24     protected boolean uploadRejected;
     24    protected boolean isUploadCommentRejected;
     25    protected boolean isUploadSourceRejected;
    2526
    2627    UploadTextComponentValidator(JTextComponent tc, JLabel feedback) {
    2728        super(tc);
    abstract class UploadTextComponentValidator extends AbstractTextComponentValidat  
    6566     * @since 17238
    6667     */
    6768    public final boolean isUploadRejected() {
    68         return uploadRejected;
     69        return isUploadCommentRejected || isUploadSourceRejected;
    6970    }
    7071
    7172    /**
    abstract class UploadTextComponentValidator extends AbstractTextComponentValidat  
    8485                return;
    8586            }
    8687            String uploadComment = getComponent().getText();
    87             if (UploadDialog.UploadAction.isUploadCommentTooShort(uploadComment)) {
     88            String rejection = UploadDialog.UploadAction.validateUploadTag(uploadComment, "upload.comment",
     89                    Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
     90            isUploadCommentRejected = rejection != null;
     91
     92            if (isUploadCommentRejected) {
     93                feedbackWarning(tr("Your upload comment is <i>rejected</i>.") + "<br />" + rejection);
     94            } else if (UploadDialog.UploadAction.isUploadCommentTooShort(uploadComment)) {
    8895                feedbackWarning(tr("Your upload comment is <i>empty</i>, or <i>very short</i>.<br /><br />" +
    8996                        "This is technically allowed, but please consider that many users who are<br />" +
    9097                        "watching changes in their area depend on meaningful changeset comments<br />" +
    abstract class UploadTextComponentValidator extends AbstractTextComponentValidat  
    9299                        "If you spend a minute now to explain your change, you will make life<br />" +
    93100                        "easier for many other mappers.").replace("<br />", " "));
    94101            } else {
    95                 String rejection = UploadDialog.UploadAction.validateUploadTag(uploadComment, "upload.comment",
    96                         Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
    97                 uploadRejected = rejection != null;
    98                 if (uploadRejected) {
    99                     feedbackWarning(tr("Your upload comment is <i>rejected</i>.") + "<br />" + rejection);
    100                 } else {
    101                     feedbackValid(tr("Thank you for providing a changeset comment! " +
    102                             "This gives other mappers a better understanding of your intent."));
    103                 }
     102                feedbackValid(tr("Thank you for providing a changeset comment! " +
     103                        "This gives other mappers a better understanding of your intent."));
    104104            }
    105105        }
    106106    }
    abstract class UploadTextComponentValidator extends AbstractTextComponentValidat  
    121121                return;
    122122            }
    123123            String uploadSource = getComponent().getText();
    124             if (Utils.isStripEmpty(uploadSource)) {
     124            final String rejection = UploadDialog.UploadAction.validateUploadTag(
     125                    uploadSource, "upload.source", Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
     126            isUploadSourceRejected = rejection != null;
     127
     128            if (isUploadSourceRejected) {
     129                feedbackWarning(tr("Your changeset source is <i>rejected</i>.") + "<br />" + rejection);
     130            } else if (Utils.isStripEmpty(uploadSource)) {
    125131                feedbackWarning(tr("You did not specify a source for your changes.<br />" +
    126132                        "It is technically allowed, but this information helps<br />" +
    127133                        "other users to understand the origins of the data.<br /><br />" +
    128134                        "If you spend a minute now to explain your change, you will make life<br />" +
    129135                        "easier for many other mappers.").replace("<br />", " "));
    130136            } else {
    131                 final String rejection = UploadDialog.UploadAction.validateUploadTag(
    132                         uploadSource, "upload.source", Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
    133                 uploadRejected = rejection != null;
    134                 if (uploadRejected) {
    135                     feedbackWarning(tr("Your changeset source is <i>rejected</i>.") + "<br />" + rejection);
    136                 } else {
    137                     feedbackValid(tr("Thank you for providing the data source!"));
    138                 }
     137                feedbackValid(tr("Thank you for providing the data source!"));
    139138            }
    140139        }
    141140    }