Changeset 8927 in josm for trunk/src/org/openstreetmap/josm/actions/downloadtasks
- Timestamp:
- 2015-10-22T14:01:47+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r8908 r8927 47 47 48 48 protected String newLayerName; 49 50 /** This allows subclasses to ignore this warning */ 51 protected boolean warnAboutEmptyArea = true; 49 52 50 53 @Override … … 123 126 /** 124 127 * This allows subclasses to perform operations on the URL before {@link #loadUrl} is performed. 128 * @param url the original URL 129 * @return the modified URL 125 130 */ 126 131 protected String modifyUrlBeforeLoad(String url) { … … 130 135 /** 131 136 * Loads a given URL from the OSM Server 132 * @param new _layer True if the data should be saved to a new layer137 * @param newLayer True if the data should be saved to a new layer 133 138 * @param url The URL as String 134 139 */ 135 140 @Override 136 public Future<?> loadUrl(boolean new _layer, String url, ProgressMonitor progressMonitor) {137 url = modifyUrlBeforeLoad(url);138 downloadTask = new DownloadTask(new _layer,139 new OsmServerLocationReader( url),141 public Future<?> loadUrl(boolean newLayer, String url, ProgressMonitor progressMonitor) { 142 String newUrl = modifyUrlBeforeLoad(url); 143 downloadTask = new DownloadTask(newLayer, 144 new OsmServerLocationReader(newUrl), 140 145 progressMonitor); 141 146 currentBounds = null; 142 147 // Extract .osm filename from URL to set the new layer name 143 extractOsmFilename("https?://.*/(.*\\.osm)", url);148 extractOsmFilename("https?://.*/(.*\\.osm)", newUrl); 144 149 return Main.worker.submit(downloadTask); 145 150 } … … 169 174 170 175 protected final boolean newLayer; 176 protected final boolean zoomAfterDownload; 171 177 protected DataSet dataSet; 172 178 … … 179 185 * exception will be thrown directly in EDT. When this runnable is executed using executor framework 180 186 * then use false unless you read result of task (because exception will get lost if you don't) 187 * @param zoomAfterDownload If true, the map view will zoom to download area after download 181 188 */ 182 public AbstractInternalTask(boolean newLayer, String title, boolean ignoreException ) {189 public AbstractInternalTask(boolean newLayer, String title, boolean ignoreException, boolean zoomAfterDownload) { 183 190 super(title, ignoreException); 184 191 this.newLayer = newLayer; 192 this.zoomAfterDownload = zoomAfterDownload; 185 193 } 186 194 … … 194 202 * exception will be thrown directly in EDT. When this runnable is executed using executor framework 195 203 * then use false unless you read result of task (because exception will get lost if you don't) 204 * @param zoomAfterDownload If true, the map view will zoom to download area after download 196 205 */ 197 public AbstractInternalTask(boolean newLayer, String title, ProgressMonitor progressMonitor, boolean ignoreException) { 206 public AbstractInternalTask(boolean newLayer, String title, ProgressMonitor progressMonitor, boolean ignoreException, 207 boolean zoomAfterDownload) { 198 208 super(title, progressMonitor, ignoreException); 199 209 this.newLayer = newLayer; 210 this.zoomAfterDownload = zoomAfterDownload; 200 211 } 201 212 … … 206 217 207 218 protected int getNumDataLayers() { 219 if (!Main.isDisplayingMapView()) return 0; 208 220 int count = 0; 209 if (!Main.isDisplayingMapView()) return 0;210 221 Collection<Layer> layers = Main.map.mapView.getAllLayers(); 211 222 for (Layer layer : layers) { … … 276 287 } 277 288 layer.mergeFrom(dataSet); 278 computeBboxAndCenterScale(bounds); 289 if (zoomAfterDownload) { 290 computeBboxAndCenterScale(bounds); 291 } 279 292 layer.onPostDownloadFromServer(); 280 293 } … … 285 298 protected final OsmServerReader reader; 286 299 300 /** 301 * Constructs a new {@code DownloadTask}. 302 * @param newLayer if {@code true}, force download to a new layer 303 * @param reader OSM data reader 304 * @param progressMonitor progress monitor 305 */ 287 306 public DownloadTask(boolean newLayer, OsmServerReader reader, ProgressMonitor progressMonitor) { 288 super(newLayer, tr("Downloading data"), progressMonitor, false );307 super(newLayer, tr("Downloading data"), progressMonitor, false, true); 289 308 this.reader = reader; 290 309 } … … 324 343 return; // user canceled download or error occurred 325 344 if (dataSet.allPrimitives().isEmpty()) { 326 rememberErrorMessage(tr("No data found in this area.")); 345 if (warnAboutEmptyArea) { 346 rememberErrorMessage(tr("No data found in this area.")); 347 } 327 348 // need to synthesize a download bounds lest the visual indication of downloaded area doesn't work 328 349 dataSet.dataSources.add(new DataSource(currentBounds != null ? currentBounds :
Note:
See TracChangeset
for help on using the changeset viewer.