Ticket #1234: DownloadURLonEnter.patch
File DownloadURLonEnter.patch, 3.0 KB (added by , 16 years ago) |
---|
-
src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java
diff -u -r -N -x .svn orig/src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java trunk/src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java
old new 9 9 import java.awt.event.FocusAdapter; 10 10 import java.awt.event.FocusEvent; 11 11 import java.awt.event.FocusListener; 12 import java.awt.event.KeyEvent; 13 import java.awt.event.KeyListener; 12 14 import java.awt.event.MouseAdapter; 13 15 import java.util.HashMap; 14 16 … … 17 19 import javax.swing.JTextArea; 18 20 import javax.swing.JTextField; 19 21 import javax.swing.SwingUtilities; 20 import javax.swing.event.DocumentListener;21 import javax.swing.event.DocumentEvent;22 22 23 23 import org.openstreetmap.josm.data.Bounds; 24 24 import org.openstreetmap.josm.data.coor.LatLon; … … 74 74 f.setMinimumSize(new Dimension(100,new JTextField().getMinimumSize().height)); 75 75 f.addFocusListener(dialogUpdater); 76 76 } 77 class osmUrlRefresher implements DocumentListener { 78 public void changedUpdate(DocumentEvent e) { dowork(); } 79 public void insertUpdate(DocumentEvent e) { dowork(); } 80 public void removeUpdate(DocumentEvent e) { dowork(); } 81 private void dowork() { 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 } 92 } 93 } 77 78 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 } 94 95 95 osmUrl.getDocument().addDocumentListener(new osmUrlRefresher()); 96 public void keyTyped(KeyEvent keyEvent) {} 97 }; 98 99 osmUrl.addKeyListener(osmUrlKeyListener); 96 100 97 101 // select content on receiving focus. this seems to be the default in the 98 102 // windows look+feel but not for others. needs invokeLater to avoid strange