Ticket #2963: dont-count-layers.patch

File dont-count-layers.patch, 1.9 KB (added by plaicy, 17 years ago)
  • src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

     
    4040        private boolean newLayer;
    4141        private String msg = "";
    4242
    43         public Task(boolean newLayer, OsmServerReader reader, boolean silent,
    44                 int numLayers, String msg) {
     43        public Task(boolean newLayer, OsmServerReader reader, boolean silent, String msg) {
    4544            super(tr("Downloading data"));
    4645            this.msg = msg;
    4746            this.reader = reader;
     
    112111        Task t = new Task(newLayer,
    113112                new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon),
    114113                silent,
    115                 getDataLayersCount(),
    116114                message);
    117115        currentBounds = new Bounds(new LatLon(minlat, minlon), new LatLon(maxlat, maxlon));
    118116        // We need submit instead of execute so we can wait for it to finish and get the error
     
    134132        Task t = new Task(new_layer,
    135133                new OsmServerLocationReader(url),
    136134                false,
    137                 getDataLayersCount(),
    138135        "");
    139136        task = Main.worker.submit(t, t);
    140137    }
     
    147144        return "osm";
    148145    }
    149146
    150     /**
    151      * Finds the number of data layers currently opened
    152      * @return Number of data layers
    153      */
    154     private int getDataLayersCount() {
    155         if(Main.map == null || Main.map.mapView == null)
    156             return 0;
    157         int num = 0;
    158         for(Layer l : Main.map.mapView.getAllLayers())
    159             if(l instanceof OsmDataLayer) {
    160                 num++;
    161             }
    162         return num;
    163     }
    164 
    165147    /*
    166148     * (non-Javadoc)
    167149     * @see org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask#getErrorMessage()