- Timestamp:
- 2017-09-04T02:10:29+02:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
r12630 r12719 10 10 import java.awt.event.FocusAdapter; 11 11 import java.awt.event.FocusEvent; 12 import java.awt.event.ItemEvent; 12 13 import java.awt.event.KeyAdapter; 13 14 import java.awt.event.KeyEvent; … … 20 21 import javax.swing.Action; 21 22 import javax.swing.BorderFactory; 23 import javax.swing.JCheckBox; 22 24 import javax.swing.JEditorPane; 23 25 import javax.swing.JPanel; … … 62 64 /** the panel with a summary of the upload parameters */ 63 65 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.")); 64 68 /** the changeset comment model */ 65 69 private final transient ChangesetCommentModel changesetCommentModel; 66 70 private final transient ChangesetCommentModel changesetSourceModel; 71 private final transient ChangesetReviewModel changesetReviewModel; 67 72 68 73 protected JPanel buildUploadCommentPanel() { … … 118 123 add(buildUploadCommentPanel(), BorderLayout.NORTH); 119 124 add(pnlUploadParameterSummary, BorderLayout.CENTER); 125 add(cbRequestReview, BorderLayout.SOUTH); 126 cbRequestReview.addItemListener(e -> changesetReviewModel.setReviewRequested(e.getStateChange() == ItemEvent.SELECTED)); 120 127 } 121 128 … … 125 132 * @param changesetCommentModel the model for the changeset comment. Must not be null 126 133 * @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. 127 135 * @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) { 130 140 CheckParameterUtil.ensureParameterNotNull(changesetCommentModel, "changesetCommentModel"); 131 141 CheckParameterUtil.ensureParameterNotNull(changesetSourceModel, "changesetSourceModel"); 142 CheckParameterUtil.ensureParameterNotNull(changesetReviewModel, "changesetReviewModel"); 132 143 this.changesetCommentModel = changesetCommentModel; 133 144 this.changesetSourceModel = changesetSourceModel; 145 this.changesetReviewModel = changesetReviewModel; 134 146 changesetCommentModel.addChangeListener(new ChangesetCommentChangeListener(hcbUploadComment)); 135 147 changesetSourceModel.addChangeListener(new ChangesetCommentChangeListener(hcbUploadSource)); 148 changesetReviewModel.addChangeListener(new ChangesetReviewChangeListener()); 136 149 build(); 137 150 } … … 250 263 } 251 264 } 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 } 252 280 } -
trunk/src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java
r12636 r12719 29 29 private final transient ChangesetCommentModel changesetCommentModel; 30 30 private final transient ChangesetCommentModel changesetSourceModel; 31 private final transient ChangesetReviewModel changesetReviewModel; 31 32 32 33 /** … … 35 36 * @param changesetCommentModel the changeset comment model. Must not be null. 36 37 * @param changesetSourceModel the changeset source model. Must not be null. 38 * @param changesetReviewModel the model for the changeset review. Must not be null. 37 39 * @throws IllegalArgumentException if {@code changesetCommentModel} is null 40 * @since 12719 (signature) 38 41 */ 39 public TagSettingsPanel(ChangesetCommentModel changesetCommentModel, ChangesetCommentModel changesetSourceModel) { 42 public TagSettingsPanel(ChangesetCommentModel changesetCommentModel, ChangesetCommentModel changesetSourceModel, 43 ChangesetReviewModel changesetReviewModel) { 40 44 CheckParameterUtil.ensureParameterNotNull(changesetCommentModel, "changesetCommentModel"); 41 45 CheckParameterUtil.ensureParameterNotNull(changesetSourceModel, "changesetSourceModel"); 46 CheckParameterUtil.ensureParameterNotNull(changesetReviewModel, "changesetReviewModel"); 42 47 this.changesetCommentModel = changesetCommentModel; 43 48 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()); 46 53 build(); 47 54 pnlTagEditor.getModel().addTableModelListener(this); … … 109 116 changesetCommentModel.setComment(getTagEditorValue("comment")); 110 117 changesetSourceModel.setComment(getTagEditorValue("source")); 118 changesetReviewModel.setReviewRequested("yes".equals(getTagEditorValue("review_requested"))); 111 119 } 112 120 … … 117 125 setProperty("comment", changesetCommentModel.getComment()); 118 126 setProperty("source", changesetSourceModel.getComment()); 127 setProperty("review_requested", changesetReviewModel.isReviewRequested() ? "yes" : null); 119 128 } 120 129 … … 142 151 } 143 152 } 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 } 144 173 } -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r12687 r12719 101 101 private final transient ChangesetCommentModel changesetCommentModel = new ChangesetCommentModel(); 102 102 private final transient ChangesetCommentModel changesetSourceModel = new ChangesetCommentModel(); 103 private final transient ChangesetReviewModel changesetReviewModel = new ChangesetReviewModel(); 103 104 104 105 private transient DataSet dataSet; … … 145 146 tpConfigPanels = new CompactTabbedPane(); 146 147 147 pnlBasicUploadSettings = new BasicUploadSettingsPanel(changesetCommentModel, changesetSourceModel );148 pnlBasicUploadSettings = new BasicUploadSettingsPanel(changesetCommentModel, changesetSourceModel, changesetReviewModel); 148 149 tpConfigPanels.add(pnlBasicUploadSettings); 149 150 tpConfigPanels.setTitleAt(0, tr("Settings")); 150 151 tpConfigPanels.setToolTipTextAt(0, tr("Decide how to upload the data and which changeset to use")); 151 152 152 pnlTagSettings = new TagSettingsPanel(changesetCommentModel, changesetSourceModel );153 pnlTagSettings = new TagSettingsPanel(changesetCommentModel, changesetSourceModel, changesetReviewModel); 153 154 tpConfigPanels.add(pnlTagSettings); 154 155 tpConfigPanels.setTitleAt(1, tr("Tags of new changeset")); -
trunk/test/unit/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanelTest.java
r10962 r12719 27 27 @Test 28 28 public void testBasicUploadSettingsPanel() { 29 assertNotNull(new BasicUploadSettingsPanel(new ChangesetCommentModel(), new ChangesetCommentModel() ));29 assertNotNull(new BasicUploadSettingsPanel(new ChangesetCommentModel(), new ChangesetCommentModel(), new ChangesetReviewModel())); 30 30 } 31 31 } -
trunk/test/unit/org/openstreetmap/josm/gui/io/TagSettingsPanelTest.java
r10962 r12719 27 27 @Test 28 28 public void testTagSettingsPanel() { 29 assertNotNull(new TagSettingsPanel(new ChangesetCommentModel(), new ChangesetCommentModel() ));29 assertNotNull(new TagSettingsPanel(new ChangesetCommentModel(), new ChangesetCommentModel(), new ChangesetReviewModel())); 30 30 } 31 31 }
Note:
See TracChangeset
for help on using the changeset viewer.