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/BasicUploadSettingsPanel.java

    r12630 r12719  
    1010import java.awt.event.FocusAdapter;
    1111import java.awt.event.FocusEvent;
     12import java.awt.event.ItemEvent;
    1213import java.awt.event.KeyAdapter;
    1314import java.awt.event.KeyEvent;
     
    2021import javax.swing.Action;
    2122import javax.swing.BorderFactory;
     23import javax.swing.JCheckBox;
    2224import javax.swing.JEditorPane;
    2325import javax.swing.JPanel;
     
    6264    /** the panel with a summary of the upload parameters */
    6365    private final UploadParameterSummaryPanel pnlUploadParameterSummary = new UploadParameterSummaryPanel();
     66    /** the checkbox to request feedback from other users */
     67    private final JCheckBox cbRequestReview = new JCheckBox(tr("I would like someone to review my edits."));
    6468    /** the changeset comment model */
    6569    private final transient ChangesetCommentModel changesetCommentModel;
    6670    private final transient ChangesetCommentModel changesetSourceModel;
     71    private final transient ChangesetReviewModel changesetReviewModel;
    6772
    6873    protected JPanel buildUploadCommentPanel() {
     
    118123        add(buildUploadCommentPanel(), BorderLayout.NORTH);
    119124        add(pnlUploadParameterSummary, BorderLayout.CENTER);
     125        add(cbRequestReview, BorderLayout.SOUTH);
     126        cbRequestReview.addItemListener(e -> changesetReviewModel.setReviewRequested(e.getStateChange() == ItemEvent.SELECTED));
    120127    }
    121128
     
    125132     * @param changesetCommentModel the model for the changeset comment. Must not be null
    126133     * @param changesetSourceModel the model for the changeset source. Must not be null.
     134     * @param changesetReviewModel the model for the changeset review. Must not be null.
    127135     * @throws IllegalArgumentException if {@code changesetCommentModel} is null
    128      */
    129     public BasicUploadSettingsPanel(ChangesetCommentModel changesetCommentModel, ChangesetCommentModel changesetSourceModel) {
     136     * @since 12719 (signature)
     137     */
     138    public BasicUploadSettingsPanel(ChangesetCommentModel changesetCommentModel, ChangesetCommentModel changesetSourceModel,
     139            ChangesetReviewModel changesetReviewModel) {
    130140        CheckParameterUtil.ensureParameterNotNull(changesetCommentModel, "changesetCommentModel");
    131141        CheckParameterUtil.ensureParameterNotNull(changesetSourceModel, "changesetSourceModel");
     142        CheckParameterUtil.ensureParameterNotNull(changesetReviewModel, "changesetReviewModel");
    132143        this.changesetCommentModel = changesetCommentModel;
    133144        this.changesetSourceModel = changesetSourceModel;
     145        this.changesetReviewModel = changesetReviewModel;
    134146        changesetCommentModel.addChangeListener(new ChangesetCommentChangeListener(hcbUploadComment));
    135147        changesetSourceModel.addChangeListener(new ChangesetCommentChangeListener(hcbUploadSource));
     148        changesetReviewModel.addChangeListener(new ChangesetReviewChangeListener());
    136149        build();
    137150    }
     
    250263        }
    251264    }
     265
     266    /**
     267     * Observes the changeset review model and keeps the review checkbox
     268     * in sync with the current changeset review request
     269     */
     270    class ChangesetReviewChangeListener implements ChangeListener {
     271        @Override
     272        public void stateChanged(ChangeEvent e) {
     273            if (!(e.getSource() instanceof ChangesetReviewModel)) return;
     274            boolean newState = ((ChangesetReviewModel) e.getSource()).isReviewRequested();
     275            if (cbRequestReview.isSelected() != newState) {
     276                cbRequestReview.setSelected(newState);
     277            }
     278        }
     279    }
    252280}
Note: See TracChangeset for help on using the changeset viewer.