Ignore:
Timestamp:
2009-10-27T14:51:46+01:00 (14 years ago)
Author:
Gubaer
Message:

Cleanup in DownloadAction and DownloadDialog
Added context-sensitive help to DownloadDialog

File:
1 edited

Legend:

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

    r2330 r2331  
    3535public class DownloadAction extends JosmAction {
    3636    private static final Logger logger = Logger.getLogger(DownloadAction.class.getName());
    37    
    38     private DownloadDialog dialog;
    39     private ExtendedDialog downloadDialog;
    40 
     37 
    4138    public DownloadAction() {
    4239        super(tr("Download from OSM..."), "download", tr("Download map data from the OSM server."),
     
    4542    }
    4643
    47     /**
    48      * Creates the download dialog
    49      *
    50      * @return the downlaod dialog
    51      */
    52     protected ExtendedDialog createDownloadDialog() {
    53         if (dialog == null)
    54             dialog = new DownloadDialog();
    55         dialog.restoreSettings();
    56 
    57         final String prefName = dialog.getClass().getName()+ ".geometry";
    58         final WindowGeometry wg = WindowGeometry.centerInWindow(Main.parent,
    59                 new Dimension(1000,600));
    60 
    61         if (downloadDialog == null) {
    62             JPanel downPanel = new JPanel(new BorderLayout());
    63             downPanel.add(dialog, BorderLayout.CENTER);
    64             downloadDialog= new ExtendedDialog(Main.parent,
    65                 tr("Download"),
    66                 new String[] {tr("OK"), tr("Cancel")});
    67             downloadDialog.setContent(downPanel, false /* don't use a scroll pane inside the dialog */);
    68             downloadDialog.setButtonIcons(new String[] {"ok", "cancel"});
    69             downloadDialog.setRememberWindowGeometry(prefName, wg);
    70         }
    71         return downloadDialog;
    72     }
    73 
    7444    public void actionPerformed(ActionEvent e) {
    75         ExtendedDialog dlg = createDownloadDialog();
    76         boolean finish = false;
    77         while (!finish) {           
    78             dlg.showDialog();
    79             if (dlg.getValue() == 1 /* OK */) {
    80                 dialog.rememberSettings();
    81                 Bounds area = dialog.getSelectedDownloadArea();               
    82                 if (dialog.isDownloadOsmData()) {
    83                     DownloadOsmTask task = new DownloadOsmTask();
    84                     Future<?> future = task.download(dialog.isNewLayerRequired(), area, null);
    85                     Main.worker.submit(new PostDownloadHandler(task, future));
    86                     finish = true;
    87                 }
    88                 if (dialog.isDownloadGpxData()) {
    89                     DownloadGpsTask task = new DownloadGpsTask();
    90                     Future<?> future = task.download(dialog.isNewLayerRequired(),area, null);
    91                     Main.worker.submit(new PostDownloadHandler(task, future));
    92                     finish = true;
    93                 }
    94             } else {
    95                 finish = true;
     45        DownloadDialog dialog = DownloadDialog.getInstance();
     46        dialog.setVisible(true);
     47        if (! dialog.isCanceled()) {
     48            dialog.rememberSettings();
     49            Bounds area = dialog.getSelectedDownloadArea();               
     50            if (dialog.isDownloadOsmData()) {
     51                DownloadOsmTask task = new DownloadOsmTask();
     52                Future<?> future = task.download(dialog.isNewLayerRequired(), area, null);
     53                Main.worker.submit(new PostDownloadHandler(task, future));
    9654            }
    97             if (!finish) {
    98                 JOptionPane.showMessageDialog(
    99                         Main.parent,
    100                         tr("Please select at least one task to download"),
    101                         tr("Error"),
    102                         JOptionPane.ERROR_MESSAGE
    103                 );
     55            if (dialog.isDownloadGpxData()) {
     56                DownloadGpsTask task = new DownloadGpsTask();
     57                Future<?> future = task.download(dialog.isNewLayerRequired(),area, null);
     58                Main.worker.submit(new PostDownloadHandler(task, future));
    10459            }
    105         }
    106     }
     60        } 
     61    }   
    10762}
Note: See TracChangeset for help on using the changeset viewer.