Ignore:
Timestamp:
2017-09-04T02:10:29+02:00 (18 months ago)
Author:
Don-vip
Message:

fix #15232 - Allow user to request feedback when uploading by adding the review_requested=yes changeset tag.
Inspired by:

File:
1 edited

Legend:

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

    r12636 r12719  
    2929    private final transient ChangesetCommentModel changesetCommentModel;
    3030    private final transient ChangesetCommentModel changesetSourceModel;
     31    private final transient ChangesetReviewModel changesetReviewModel;
    3132
    3233    /**
     
    3536     * @param changesetCommentModel the changeset comment model. Must not be null.
    3637     * @param changesetSourceModel the changeset source model. Must not be null.
     38     * @param changesetReviewModel the model for the changeset review. Must not be null.
    3739     * @throws IllegalArgumentException if {@code changesetCommentModel} is null
     40     * @since 12719 (signature)
    3841     */
    39     public TagSettingsPanel(ChangesetCommentModel changesetCommentModel, ChangesetCommentModel changesetSourceModel) {
     42    public TagSettingsPanel(ChangesetCommentModel changesetCommentModel, ChangesetCommentModel changesetSourceModel,
     43            ChangesetReviewModel changesetReviewModel) {
    4044        CheckParameterUtil.ensureParameterNotNull(changesetCommentModel, "changesetCommentModel");
    4145        CheckParameterUtil.ensureParameterNotNull(changesetSourceModel, "changesetSourceModel");
     46        CheckParameterUtil.ensureParameterNotNull(changesetReviewModel, "changesetReviewModel");
    4247        this.changesetCommentModel = changesetCommentModel;
    4348        this.changesetSourceModel = changesetSourceModel;
    44         this.changesetCommentModel.addChangeListener(new ChangesetCommentChangeListener("comment"));
    45         this.changesetSourceModel.addChangeListener(new ChangesetCommentChangeListener("source"));
     49        this.changesetReviewModel = changesetReviewModel;
     50        changesetCommentModel.addChangeListener(new ChangesetCommentChangeListener("comment"));
     51        changesetSourceModel.addChangeListener(new ChangesetCommentChangeListener("source"));
     52        changesetReviewModel.addChangeListener(new ChangesetReviewChangeListener());
    4653        build();
    4754        pnlTagEditor.getModel().addTableModelListener(this);
     
    109116        changesetCommentModel.setComment(getTagEditorValue("comment"));
    110117        changesetSourceModel.setComment(getTagEditorValue("source"));
     118        changesetReviewModel.setReviewRequested("yes".equals(getTagEditorValue("review_requested")));
    111119    }
    112120
     
    117125        setProperty("comment", changesetCommentModel.getComment());
    118126        setProperty("source", changesetSourceModel.getComment());
     127        setProperty("review_requested", changesetReviewModel.isReviewRequested() ? "yes" : null);
    119128    }
    120129
     
    142151        }
    143152    }
     153
     154    /**
     155     * Observes the changeset review model and keeps the tag editor in sync
     156     * with the current changeset review request
     157     */
     158    class ChangesetReviewChangeListener implements ChangeListener {
     159
     160        private final String key = "review_requested";
     161
     162        @Override
     163        public void stateChanged(ChangeEvent e) {
     164            if (e.getSource() instanceof ChangesetReviewModel) {
     165                boolean newState = ((ChangesetReviewModel) e.getSource()).isReviewRequested();
     166                boolean oldState = "yes".equals(Optional.ofNullable(getTagEditorValue(key)).orElse(""));
     167                if (oldState != newState) {
     168                    setProperty(key, newState ? "yes" : null);
     169                }
     170            }
     171        }
     172    }
    144173}
Note: See TracChangeset for help on using the changeset viewer.