Changeset 2328 in josm for trunk


Ignore:
Timestamp:
2009-10-27T01:27:50+01:00 (12 years ago)
Author:
Gubaer
Message:

More cleanup in download logic (less globals, more encapsulation)

Location:
trunk/src/org/openstreetmap/josm
Files:
6 edited

Legend:

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

    r2327 r2328  
    424424                //DownloadTask osmTask = main.menu.download.downloadTasks.get(0);
    425425                DownloadTask osmTask = new DownloadOsmTask();
    426                 Future<?> future = osmTask.download(main.menu.download, b, null);
     426                Future<?> future = osmTask.download(true, b, null);
    427427                Main.worker.submit(new PostDownloadHandler(osmTask, future));
    428428            }
     
    475475                DownloadTask task = rawGps ? new DownloadGpsTask() : new DownloadOsmTask();
    476476                // asynchronously launch the download task ...
    477                 Future<?> future = task.download(main.menu.download, b, null);
     477                Future<?> future = task.download(true, b, null);
    478478                // ... and the continuation when the download is finished (this will wait for the download to finish)
    479479                Main.worker.execute(new PostDownloadHandler(task, future));
  • trunk/src/org/openstreetmap/josm/actions/DownloadAction.java

    r2327 r2328  
    3434   
    3535
    36     public DownloadDialog dialog;
     36    private DownloadDialog dialog;
    3737    private ExtendedDialog downloadDialog;
    3838
     
    7878                if (dialog.isDownloadOsmData()) {
    7979                    DownloadOsmTask task = new DownloadOsmTask();
    80                     Future<?> future = task.download(this, dialog.getSelectedDownloadArea(), null);
     80                    Future<?> future = task.download(dialog.isNewLayerRequired(), dialog.getSelectedDownloadArea(), null);
    8181                    Main.worker.submit(new PostDownloadHandler(task, future));
    8282                    finish = true;
     
    8484                if (dialog.isDownloadGpxData()) {
    8585                    DownloadGpsTask task = new DownloadGpsTask();
    86                     Future<?> future = task.download(this,dialog.getSelectedDownloadArea(), null);
     86                    Future<?> future = task.download(dialog.isNewLayerRequired(),dialog.getSelectedDownloadArea(), null);
    8787                    Main.worker.submit(new PostDownloadHandler(task, future));
    8888                    finish = true;
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java

    r2327 r2328  
    88
    99import org.openstreetmap.josm.Main;
    10 import org.openstreetmap.josm.actions.DownloadAction;
    1110import org.openstreetmap.josm.data.Bounds;
    1211import org.openstreetmap.josm.data.gpx.GpxData;
     
    2322    private DownloadTask downloadTask;
    2423
    25     public Future<?> download(DownloadAction action, Bounds downloadArea, ProgressMonitor progressMonitor) {
    26         downloadTask = new DownloadTask(action.dialog.isNewLayerRequired(),
     24    public Future<?> download(boolean newLayer, Bounds downloadArea, ProgressMonitor progressMonitor) {
     25        downloadTask = new DownloadTask(newLayer,
    2726                new BoundingBoxDownloader(downloadArea), progressMonitor);
    2827        // We need submit instead of execute so we can wait for it to finish and get the error
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r2327 r2328  
    4444    }
    4545
    46     public Future<?> download(DownloadAction action, Bounds downloadArea, ProgressMonitor progressMonitor) {
     46    public Future<?> download(boolean newLayer, Bounds downloadArea, ProgressMonitor progressMonitor) {
    4747       
    48         boolean newLayer = action != null
    49         && (action.dialog == null || action.dialog.isNewLayerRequired());
    50 
    5148        downloadTask = new DownloadTask(newLayer,
    5249                new BoundingBoxDownloader(downloadArea), progressMonitor);
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java

    r2327 r2328  
    6666            childProgress.setSilent(true);
    6767            childProgress.setCustomText(tr("Download {0} of {1} ({2} left)", i, rects.size(), rects.size() - i));
    68             Future<?> future = dt.download(null, new Bounds(td), childProgress);
     68            Future<?> future = dt.download(false, new Bounds(td), childProgress);
    6969            osmTaskFutures.add(future);
    7070            osmTasks.add(dt);
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTask.java

    r2327 r2328  
    55import java.util.concurrent.Future;
    66
    7 import org.openstreetmap.josm.actions.DownloadAction;
    87import org.openstreetmap.josm.data.Bounds;
    98import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    1514     * if no error messages should be popped up.
    1615     */
    17     Future<?> download(DownloadAction action, Bounds downloadArea, ProgressMonitor progressMonitor);
     16    Future<?> download(boolean newLayer, Bounds downloadArea, ProgressMonitor progressMonitor);
    1817
    1918    /**
Note: See TracChangeset for help on using the changeset viewer.