Ignore:
Timestamp:
2008-06-26T19:36:52+02:00 (16 years ago)
Author:
framm
Message:
  • patch for better handling of entering URLs in download dialog by Dirk Stoecker <openstreetmap@…>, fixes #934
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java

    r627 r659  
    1111import java.awt.event.FocusEvent;
    1212import java.awt.event.FocusListener;
    13 import java.awt.event.KeyAdapter;
    14 import java.awt.event.KeyEvent;
    15 import java.awt.event.KeyListener;
    1613import java.util.HashMap;
    1714
     
    2118import javax.swing.JTextField;
    2219import javax.swing.SwingUtilities;
     20import javax.swing.event.DocumentListener;
     21import javax.swing.event.DocumentEvent;
    2322
    2423import org.openstreetmap.josm.Main;
     
    7877                        f.addFocusListener(dialogUpdater);
    7978                }
    80                
    81                 final KeyListener osmUrlRefresher = new KeyAdapter() {
    82                         @Override public void keyTyped(KeyEvent e) {
    83                                 SwingUtilities.invokeLater(new Runnable() {
    84                                         public void run() {
    85                                                 Bounds b = osmurl2bounds(osmUrl.getText());
    86                                                 if (b != null) {
    87                                                         gui.minlon = b.min.lon();
    88                                                         gui.minlat = b.min.lat();
    89                                                         gui.maxlon = b.max.lon();
    90                                                         gui.maxlat = b.max.lat();
    91                                                         gui.boundingBoxChanged(BoundingBoxSelection.this);
    92                                                         updateBboxFields(gui);
    93                                                         updateSizeCheck(gui);
    94                                                 }
    95                                         }
    96                                 });
     79                class osmUrlRefresher implements DocumentListener {
     80                        public void changedUpdate(DocumentEvent e) { dowork(); }
     81                        public void insertUpdate(DocumentEvent e) { dowork(); }
     82                        public void removeUpdate(DocumentEvent e) { dowork(); }
     83                        private void dowork() {
     84                                Bounds b = osmurl2bounds(osmUrl.getText());
     85                                if (b != null) {
     86                                        gui.minlon = b.min.lon();
     87                                        gui.minlat = b.min.lat();
     88                                        gui.maxlon = b.max.lon();
     89                                        gui.maxlat = b.max.lat();
     90                                        gui.boundingBoxChanged(BoundingBoxSelection.this);
     91                                        updateBboxFields(gui);
     92                                        updateSizeCheck(gui);
     93                                }
    9794                        }
    9895                };
    9996               
    100                 osmUrl.addKeyListener(osmUrlRefresher);
     97                osmUrl.getDocument().addDocumentListener(new osmUrlRefresher());
    10198               
    10299                // select content on receiving focus. this seems to be the default in the
Note: See TracChangeset for help on using the changeset viewer.