Changeset 17894 in josm for trunk/src/org


Ignore:
Timestamp:
2021-05-15T21:12:23+02:00 (4 years ago)
Author:
simon04
Message:

see #20690 - Upload dialog: add DocumentListener for changeset comments as an attempt to fix comments off-by-one error

File:
1 edited

Legend:

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

    r17709 r17894  
    2828import javax.swing.event.ChangeEvent;
    2929import javax.swing.event.ChangeListener;
     30import javax.swing.event.DocumentEvent;
     31import javax.swing.event.DocumentListener;
    3032import javax.swing.event.HyperlinkEvent;
    3133
     
    9698        hcbUploadComment.getEditor().addActionListener(commentModelListener);
    9799        hcbUploadComment.getEditorComponent().addFocusListener(commentModelListener);
     100        hcbUploadComment.getEditorComponent().getDocument().addDocumentListener(commentModelListener);
    98101        pnl.add(hcbUploadComment, GBC.eol().fill(GBC.HORIZONTAL));
    99102        pnl.add(uploadCommentFeedback, GBC.eol().insets(0, 3, 0, 0).fill(GBC.HORIZONTAL));
     
    133136        hcbUploadSource.getEditor().addActionListener(sourceModelListener);
    134137        hcbUploadSource.getEditorComponent().addFocusListener(sourceModelListener);
     138        hcbUploadSource.getEditorComponent().getDocument().addDocumentListener(sourceModelListener);
    135139        pnl.add(hcbUploadSource, GBC.eol().fill(GBC.HORIZONTAL));
    136140        pnl.add(hcbUploadSourceFeedback, GBC.eol().insets(0, 3, 0, 0).fill(GBC.HORIZONTAL));
     
    350354     * Updates the changeset comment model upon changes in the input field.
    351355     */
    352     static class CommentModelListener extends FocusAdapter implements ActionListener {
     356    static class CommentModelListener extends FocusAdapter implements ActionListener, DocumentListener {
    353357
    354358        private final HistoryComboBox source;
     
    360364        }
    361365
     366        private void setComment() {
     367            destination.setComment(source.getText());
     368        }
     369
    362370        @Override
    363371        public void actionPerformed(ActionEvent e) {
    364             destination.setComment(source.getText());
     372            setComment();
    365373        }
    366374
    367375        @Override
    368376        public void focusLost(FocusEvent e) {
    369             destination.setComment(source.getText());
     377            setComment();
     378        }
     379
     380        @Override
     381        public void insertUpdate(DocumentEvent e) {
     382            setComment();
     383        }
     384
     385        @Override
     386        public void removeUpdate(DocumentEvent e) {
     387            setComment();
     388        }
     389
     390        @Override
     391        public void changedUpdate(DocumentEvent e) {
     392            setComment();
    370393        }
    371394    }
Note: See TracChangeset for help on using the changeset viewer.