Ticket #2088: FixInsertingViaMouse.patch
| File FixInsertingViaMouse.patch, 3.0 KB (added by , 17 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java
19 19 import javax.swing.JTextArea; 20 20 import javax.swing.JTextField; 21 21 import javax.swing.SwingUtilities; 22 import javax.swing.event.DocumentListener; 23 import javax.swing.event.DocumentEvent; 22 24 23 25 import org.openstreetmap.josm.data.Bounds; 24 26 import org.openstreetmap.josm.data.coor.LatLon; … … 75 77 f.addFocusListener(dialogUpdater); 76 78 } 77 79 80 class osmUrlRefresher implements DocumentListener { 81 public void changedUpdate(DocumentEvent e) { parseURL(gui); } 82 public void insertUpdate(DocumentEvent e) { parseURL(gui); } 83 public void removeUpdate(DocumentEvent e) { parseURL(gui); } 84 } 85 78 86 KeyListener osmUrlKeyListener = new KeyListener() { 79 public void keyPressed(KeyEvent keyEvent) {} 80 81 public void keyReleased(KeyEvent keyEvent) { 82 Bounds b = OsmUrlToBounds.parse(osmUrl.getText()); 83 if (b != null) { 84 gui.minlon = b.min.lon(); 85 gui.minlat = b.min.lat(); 86 gui.maxlon = b.max.lon(); 87 gui.maxlat = b.max.lat(); 88 gui.boundingBoxChanged(BoundingBoxSelection.this); 89 updateBboxFields(gui); 90 updateUrl(gui); 91 if(keyEvent.getKeyCode() == keyEvent.VK_ENTER) 92 gui.closeDownloadDialog(true); 93 } 94 } 95 96 public void keyTyped(KeyEvent keyEvent) {} 87 public void keyPressed(KeyEvent keyEvent) {} 88 public void keyReleased(KeyEvent keyEvent) { 89 if (keyEvent.getKeyCode() == keyEvent.VK_ENTER && parseURL(gui)) 90 gui.closeDownloadDialog(true); 91 } 92 public void keyTyped(KeyEvent keyEvent) {} 97 93 }; 98 94 99 95 osmUrl.addKeyListener(osmUrlKeyListener); 96 osmUrl.getDocument().addDocumentListener(new osmUrlRefresher()); 100 97 101 98 // select content on receiving focus. this seems to be the default in the 102 99 // windows look+feel but not for others. needs invokeLater to avoid strange … … 144 141 updateBboxFields(gui); 145 142 updateUrl(gui); 146 143 } 144 145 private boolean parseURL(DownloadDialog gui) { 146 Bounds b = OsmUrlToBounds.parse(osmUrl.getText()); 147 if(b == null) return false; 148 gui.minlon = b.min.lon(); 149 gui.minlat = b.min.lat(); 150 gui.maxlon = b.max.lon(); 151 gui.maxlat = b.max.lat(); 152 gui.boundingBoxChanged(BoundingBoxSelection.this); 153 updateBboxFields(gui); 154 updateUrl(gui); 155 return true; 156 } 147 157 148 158 private void updateBboxFields(DownloadDialog gui) { 149 159 latlon[0].setText(Double.toString(gui.minlat));
