Changeset 6419 in josm for trunk/src


Ignore:
Timestamp:
2013-11-28T17:41:26+01:00 (11 years ago)
Author:
simon04
Message:

see #6381 - display specific, ignorable dialog on empty changeset source

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r6401 r6419  
    342342
    343343    /**
     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    /**
    344353     * Returns true if the dialog was canceled
    345354     *
     
    402411
    403412        /**
    404          * returns true if the user wants to revisit, false if they
    405          * want to continue
     413         * 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
    406415         */
    407416        protected boolean warnUploadComment() {
    408             ExtendedDialog dlg = new ExtendedDialog(UploadDialog.this,
     417            return warnUploadTag(
    409418                    tr("Please revise upload comment"),
    410                     new String[] {tr("Revise"), tr("Cancel"), tr("Continue as is")});
    411             dlg.setContent("<html>" +
    412419                    tr("Your upload comment is <i>empty</i>, or <i>very short</i>.<br /><br />" +
    413420                            "This is technically allowed, but please consider that many users who are<br />" +
     
    415422                            "to understand what is going on!<br /><br />" +
    416423                            "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>");
    419450            dlg.setButtonIcons(new Icon[] {
    420451                    ImageProvider.get("ok"),
     
    429460                    tr("Ignore this hint and upload anyway")});
    430461            dlg.setIcon(JOptionPane.WARNING_MESSAGE);
    431             dlg.toggleEnable("upload_comment_is_empty_or_very_short");
     462            dlg.toggleEnable(togglePref);
    432463            dlg.setToggleCheckboxText(tr("Do not show this message again"));
    433464            dlg.setCancelButton(1, 2);
     
    447478        @Override
    448479        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;
    456486            }
    457487
     
    460490            List<String> emptyChangesetTags = new ArrayList<String>();
    461491            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) {
    464496                    emptyChangesetTags.add(tr("{0}={1}", i.getKey(), i.getValue()));
    465497                }
Note: See TracChangeset for help on using the changeset viewer.