Ignore:
Timestamp:
2009-01-27T19:59:33+01:00 (15 years ago)
Author:
stoecker
Message:

close #2088, #2091, update translations, added tr, patch by xeen and Claudius Henrichs

File:
1 edited

Legend:

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

    r1336 r1345  
    2020import javax.swing.JTextField;
    2121import javax.swing.SwingUtilities;
     22import javax.swing.event.DocumentListener;
     23import javax.swing.event.DocumentEvent;
    2224
    2325import org.openstreetmap.josm.data.Bounds;
     
    7678        }
    7779       
     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       
    7886        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) {}
    9793        };
    9894       
    9995        osmUrl.addKeyListener(osmUrlKeyListener);
     96        osmUrl.getDocument().addDocumentListener(new osmUrlRefresher());
    10097
    10198        // select content on receiving focus. this seems to be the default in the
     
    145142        updateUrl(gui);
    146143    }
     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    }
    147157
    148158    private void updateBboxFields(DownloadDialog gui) {
Note: See TracChangeset for help on using the changeset viewer.