Changeset 2531 in josm for trunk/src/org
- Timestamp:
- 2009-11-28T14:40:35+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AddNodeAction.java
r2512 r2531 2 2 package org.openstreetmap.josm.actions; 3 3 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;6 6 7 7 import java.awt.GridBagLayout; 8 8 import java.awt.event.ActionEvent; 9 9 import java.awt.event.KeyEvent; 10 import java.awt.event.WindowAdapter; 11 import java.awt.event.WindowEvent; 10 12 13 import javax.swing.JDialog; 11 14 import javax.swing.JLabel; 12 15 import javax.swing.JOptionPane; … … 32 35 Shortcut.SHIFT_DEFAULT), true); 33 36 putValue("help", ht("/Action/AddNode")); 37 } 38 39 private String normalizeUserInputForLatLonValue(String value) { 40 if (value == null) return null; 41 value = value.trim(); 42 return value.replaceAll("\u00B0", ""); // the degree symbol 34 43 } 35 44 … … 58 67 while(nnew == null) { 59 68 JOptionPane pane = new JOptionPane(p, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); 60 pane.createDialog(Main.parent, tr("Add Node...")).setVisible(true); 69 JDialog dialog = pane.createDialog(Main.parent, tr("Add Node...")); 70 dialog.addWindowListener(new WindowAdapter() { 71 @Override 72 public void windowGainedFocus(WindowEvent e) { 73 lat.selectAll(); 74 lat.requestFocusInWindow(); 75 } 76 } 77 ); 78 dialog.setVisible(true); 79 61 80 if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue())) 62 81 return; 63 82 try { 64 LatLon ll = new LatLon(Double.parseDouble(lat.getText()), Double.parseDouble(lon.getText())); 83 LatLon ll = new LatLon( 84 Double.parseDouble( 85 normalizeUserInputForLatLonValue(lat.getText()) 86 ), 87 Double.parseDouble( 88 normalizeUserInputForLatLonValue(lon.getText()) 89 ) 90 ); 65 91 if (!ll.isOutSideWorld()) { 66 92 nnew = new Node(ll); 67 93 } 68 } catch (Exception ex) { } 94 } catch (Exception ex) { 95 ex.printStackTrace(); 96 JOptionPane.showMessageDialog( 97 Main.parent, 98 tr("Could not create a node with the entered latitude/longitude."), 99 tr("Illegal lat/lon value"), 100 JOptionPane.ERROR_MESSAGE 101 ); 102 } 69 103 } 70 104 … … 79 113 setEnabled(getEditLayer() != null); 80 114 } 81 82 115 }
Note:
See TracChangeset
for help on using the changeset viewer.