Ignore:
Timestamp:
27.10.2009 01:21:32 (3 years ago)
Author:
Gubaer
Message:

Cleanup in download logic (less global, more encapsulation)

File:
1 edited

Legend:

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

    r2322 r2327  
    88import java.util.concurrent.Future; 
    99import java.util.logging.Logger; 
    10  
    11 import javax.swing.JCheckBox; 
    1210 
    1311import org.openstreetmap.josm.Main; 
     
    3836    private DownloadTask downloadTask; 
    3937 
    40     private JCheckBox checkBox = new JCheckBox(tr("OpenStreetMap data"), true); 
    41  
    4238    private void rememberDownloadedData(DataSet ds) { 
    4339        this.downloadedData = ds; 
     
    4844    } 
    4945 
    50     public Future<?> download(DownloadAction action, double minlat, double minlon, 
    51             double maxlat, double maxlon, ProgressMonitor progressMonitor) { 
    52         // Swap min and max if user has specified them the wrong way round 
    53         // (easy to do if you are crossing 0, for example) 
    54         // FIXME should perhaps be done in download dialog? 
    55         if (minlat > maxlat) { 
    56             double t = minlat; minlat = maxlat; maxlat = t; 
    57         } 
    58         if (minlon > maxlon) { 
    59             double t = minlon; minlon = maxlon; maxlon = t; 
    60         } 
    61  
     46    public Future<?> download(DownloadAction action, Bounds downloadArea, ProgressMonitor progressMonitor) { 
     47        
    6248        boolean newLayer = action != null 
    63         && (action.dialog == null || action.dialog.newLayer.isSelected()); 
     49        && (action.dialog == null || action.dialog.isNewLayerRequired()); 
    6450 
    6551        downloadTask = new DownloadTask(newLayer, 
    66                 new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon), progressMonitor); 
    67         currentBounds = new Bounds(new LatLon(minlat, minlon), new LatLon(maxlat, maxlon)); 
     52                new BoundingBoxDownloader(downloadArea), progressMonitor); 
     53        currentBounds = new Bounds(downloadArea); 
    6854        // We need submit instead of execute so we can wait for it to finish and get the error 
    6955        // message if necessary. If no one calls getErrorMessage() it just behaves like execute. 
     
    8268        currentBounds = new Bounds(new LatLon(0,0), new LatLon(0,0)); 
    8369        return Main.worker.submit(downloadTask); 
    84     } 
    85  
    86     public JCheckBox getCheckBox() { 
    87         return checkBox; 
    88     } 
    89  
    90     public String getPreferencesSuffix() { 
    91         return "osm"; 
    9270    } 
    9371 
Note: See TracChangeset for help on using the changeset viewer.