Changeset 29348 in osm
- Timestamp:
- 2013-03-06T23:33:30+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reverter/src/reverter/ChangesetIdQuery.java
r29347 r29348 9 9 import java.awt.event.KeyListener; 10 10 import java.text.NumberFormat; 11 import java.text.ParseException; 11 12 12 13 import javax.swing.ButtonGroup; … … 28 29 @SuppressWarnings("serial") 29 30 public 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); 31 33 private final ButtonGroup bgRevertType = new ButtonGroup(); 32 34 private final JRadioButton rbFull = new JRadioButton(tr("Revert changeset fully")); … … 39 41 public int getChangesetId() { 40 42 try { 41 return Integer.parseInt(tcid.getText());42 } catch ( NumberFormatException e) {43 return format.parse(tcid.getText()).intValue(); 44 } catch (ParseException e) { 43 45 return 0; 44 46 } … … 101 103 @Override public void changedUpdate(DocumentEvent e) { idChanged(); } 102 104 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 } 106 110 } 107 111 }); … … 112 116 // Initially disables the Revert button 113 117 buttons.get(0).setEnabled(false); 114 118 115 119 // When pressing Enter in the changeset id field, validate the dialog if the id is correct (i.e. Revert button enabled) 116 120 tcid.addKeyListener(new KeyListener() {
Note:
See TracChangeset
for help on using the changeset viewer.