Changeset 29348 in osm


Ignore:
Timestamp:
2013-03-06T23:33:30+01:00 (12 years ago)
Author:
donvip
Message:

[josm_reverter] fix two regressions introduced in last commit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reverter/src/reverter/ChangesetIdQuery.java

    r29347 r29348  
    99import java.awt.event.KeyListener;
    1010import java.text.NumberFormat;
     11import java.text.ParseException;
    1112
    1213import javax.swing.ButtonGroup;
     
    2829@SuppressWarnings("serial")
    2930public class ChangesetIdQuery extends ExtendedDialog {
    30     private final JFormattedTextField tcid = new JFormattedTextField(NumberFormat.getIntegerInstance());
     31    private final NumberFormat format = NumberFormat.getIntegerInstance();
     32    private final JFormattedTextField tcid = new JFormattedTextField(format);
    3133    private final ButtonGroup bgRevertType = new ButtonGroup();
    3234    private final JRadioButton rbFull = new JRadioButton(tr("Revert changeset fully"));
     
    3941    public int getChangesetId() {
    4042        try {
    41             return Integer.parseInt(tcid.getText());
    42         } catch (NumberFormatException e) {
     43            return format.parse(tcid.getText()).intValue();
     44        } catch (ParseException e) {
    4345            return 0;
    4446        }
     
    101103            @Override public void changedUpdate(DocumentEvent e) { idChanged(); }
    102104            private void idChanged() {
    103                 boolean idOK = getChangesetId() > 0;
    104                 tcid.setForeground(idOK ? defaultForegroundColor : Color.RED);
    105                 buttons.get(0).setEnabled(idOK);
     105                if (tcid.hasFocus()) {
     106                    boolean idOK = getChangesetId() > 0;
     107                    tcid.setForeground(idOK ? defaultForegroundColor : Color.RED);
     108                    buttons.get(0).setEnabled(idOK);
     109                }
    106110            }
    107111        });
     
    112116        // Initially disables the Revert button
    113117        buttons.get(0).setEnabled(false);
    114        
     118               
    115119        // When pressing Enter in the changeset id field, validate the dialog if the id is correct (i.e. Revert button enabled)
    116120        tcid.addKeyListener(new KeyListener() {
Note: See TracChangeset for help on using the changeset viewer.