Changeset 2142 in josm for trunk


Ignore:
Timestamp:
2009-09-15T21:16:43+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3514: NullPointerException when double-clicking on a download bookmark

Location:
trunk/src/org/openstreetmap/josm/gui/download
Files:
3 edited

Legend:

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

    r2017 r2142  
    4545
    4646        bookmarks = new BookmarkList();
    47 
    48         /* add a handler for "double click" mouse events */
    49         MouseListener mouseListener = new MouseAdapter() {
    50             @Override public void mouseClicked(MouseEvent e) {
    51                 if (e.getClickCount() == 2) {
    52                     //int index = bookmarks.locationToIndex(e.getPoint());
    53                     gui.closeDownloadDialog(true);
    54                 }
    55             }
    56         };
    57         bookmarks.addMouseListener(mouseListener);
    58 
    5947        bookmarks.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    6048            public void valueChanged(ListSelectionEvent e) {
  • trunk/src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java

    r2017 r2142  
    8181        }
    8282
    83         KeyListener osmUrlKeyListener = new KeyListener() {
    84             public void keyPressed(KeyEvent keyEvent) {}
    85             public void keyReleased(KeyEvent keyEvent) {
    86                 if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER && parseURL(gui))
    87                     gui.closeDownloadDialog(true);
    88             }
    89             public void keyTyped(KeyEvent keyEvent) {}
    90         };
    91 
    92         osmUrl.addKeyListener(osmUrlKeyListener);
    9383        osmUrl.getDocument().addDocumentListener(new osmUrlRefresher());
    9484
     
    9989            @Override public void focusGained(FocusEvent e) {
    10090                SwingUtilities.invokeLater(new Runnable() {
    101                         public void run() {
    102                             osmUrl.selectAll();
    103                         }
     91                    public void run() {
     92                        osmUrl.selectAll();
     93                    }
    10494                });
    10595            }
     
    123113        showUrl.setBackground(dlg.getBackground());
    124114        showUrl.addFocusListener(new FocusAdapter(){
    125            @Override
     115            @Override
    126116            public void focusGained(FocusEvent e) {
    127117                showUrl.selectAll();
     
    158148        latlon[2].setText(Double.toString(gui.maxlat));
    159149        latlon[3].setText(Double.toString(gui.maxlon));
    160         for (JTextField f : latlon)
     150        for (JTextField f : latlon) {
    161151            f.setCaretPosition(0);
     152        }
    162153    }
    163154
    164155    private void updateUrl(DownloadDialog gui) {
    165156        showUrl.setText(OsmUrlToBounds.getURL(new Bounds(
    166         new LatLon(gui.minlat, gui.minlon), new LatLon(gui.maxlat, gui.maxlon))));
     157                new LatLon(gui.minlat, gui.minlon), new LatLon(gui.maxlat, gui.maxlon))));
    167158    }
    168159}
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r1811 r2142  
    1919import javax.swing.JCheckBox;
    2020import javax.swing.JLabel;
    21 import javax.swing.JOptionPane;
    2221import javax.swing.JPanel;
    2322import javax.swing.JTabbedPane;
     
    4746public class DownloadDialog extends JPanel {
    4847
    49     // the JOptionPane that contains this dialog. required for the closeDialog() method.
    50     private JOptionPane optionPane;
    51 
    5248    public interface DownloadTask {
    5349        /**
     
    179175
    180176        getInputMap(WHEN_IN_FOCUSED_WINDOW).put(
    181         KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK), "checkClipboardContents");
     177                KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK), "checkClipboardContents");
    182178
    183179        getActionMap().put("checkClipboardContents", new AbstractAction() {
     
    231227    public void boundingBoxChanged(DownloadSelection eventSource) {
    232228        for (DownloadSelection s : downloadSelections) {
    233             if (s != eventSource) s.boundingBoxChanged(this);
     229            if (s != eventSource) {
     230                s.boundingBoxChanged(this);
     231            }
    234232        }
    235233        updateSizeCheck();
     
    242240        return tabpane.getSelectedIndex();
    243241    }
    244 
    245     /**
    246      * Closes the download dialog. This is intended to be called by one of
    247      * the various download area selection "plugins".
    248      *
    249      * @param download true to download selected data, false to cancel download
    250      */
    251     public void closeDownloadDialog(boolean download) {
    252         optionPane.setValue(download ? JOptionPane.OK_OPTION : JOptionPane.CANCEL_OPTION);
    253     }
    254 
    255     /**
    256      * Has to be called after this dialog has been added to a JOptionPane.
    257      * @param optionPane
    258      */
    259     public void setOptionPane(JOptionPane optionPane) {
    260         this.optionPane = optionPane;
    261     }
    262242}
Note: See TracChangeset for help on using the changeset viewer.