Changeset 435 in josm for trunk/src/org


Ignore:
Timestamp:
2007-10-27T18:09:50+02:00 (17 years ago)
Author:
framm
Message:
  • add a call for download area selection classes to close the download dialog
  • close download dialog on double-click of a bookmark (patch by Ulf Lamping)
Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/DownloadAction.java

    r412 r435  
    4242                JOptionPane pane = new JOptionPane(downPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    4343                JDialog dlg = pane.createDialog(Main.parent, tr("Download"));
     44                dialog.setOptionPane(pane);
    4445
    4546                if (dlg.getWidth() > 1000)
  • trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java

    r298 r435  
    88import java.awt.event.ActionEvent;
    99import java.awt.event.ActionListener;
     10import java.awt.event.MouseListener;
     11import java.awt.event.MouseAdapter;
     12import java.awt.event.MouseEvent;
    1013
    1114import javax.swing.DefaultListModel;
     
    3336public class BookmarkSelection implements DownloadSelection {
    3437
    35         private Preferences.Bookmark tempBookmark= null;
     38        private Preferences.Bookmark tempBookmark = null;
    3639        private BookmarkList bookmarks;
    3740       
     
    4245
    4346                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               
    4459                bookmarks.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    4560                        public void valueChanged(ListSelectionEvent e) {
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r434 r435  
    1010import javax.swing.JCheckBox;
    1111import javax.swing.JLabel;
     12import javax.swing.JOptionPane;
    1213import javax.swing.JPanel;
    1314import javax.swing.JTabbedPane;
     
    3334public class DownloadDialog extends JPanel {
    3435       
    35 
     36        // the JOptionPane that contains this dialog. required for the closeDialog() method.
     37        private JOptionPane optionPane;
     38       
    3639        public interface DownloadTask {
    3740                /**
     
    138141                return tabpane.getSelectedIndex();
    139142        }
     143       
     144        /**
     145         * Closes the download dialog. This is intended to be called by one of
     146         * the various download area selection "plugins".
     147         *
     148         * @param download true to download selected data, false to cancel download
     149         */
     150        public void closeDownloadDialog(boolean download) {
     151                optionPane.setValue(download ? JOptionPane.OK_OPTION : JOptionPane.CANCEL_OPTION);
     152        }
     153
     154        /**
     155         * Has to be called after this dialog has been added to a JOptionPane.
     156         * @param optionPane
     157         */
     158        public void setOptionPane(JOptionPane optionPane) {
     159        this.optionPane = optionPane;
     160    }
    140161}
Note: See TracChangeset for help on using the changeset viewer.