Changeset 5369 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2012-07-26T19:54:44+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r5345 r5369 5 5 6 6 import java.io.IOException; 7 import java.util.ArrayList; 7 8 import java.util.Collection; 9 import java.util.HashSet; 10 import java.util.List; 11 import java.util.Set; 8 12 import java.util.concurrent.Future; 9 13 import java.util.regex.Matcher; 10 14 import java.util.regex.Pattern; 11 15 16 import javax.swing.JOptionPane; 12 17 import org.openstreetmap.josm.Main; 13 18 import org.openstreetmap.josm.data.Bounds; 14 19 import org.openstreetmap.josm.data.coor.LatLon; 20 import org.openstreetmap.josm.data.imagery.ImageryInfo; 21 import org.openstreetmap.josm.data.imagery.ImageryLayerInfo; 15 22 import org.openstreetmap.josm.data.osm.DataSet; 16 23 import org.openstreetmap.josm.data.osm.DataSource; 17 24 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 25 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 18 26 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 19 27 import org.openstreetmap.josm.gui.layer.Layer; … … 25 33 import org.openstreetmap.josm.io.OsmTransferCanceledException; 26 34 import org.openstreetmap.josm.io.OsmTransferException; 35 import org.openstreetmap.josm.tools.Utils; 27 36 import org.xml.sax.SAXException; 28 37 … … 67 76 /** 68 77 * Loads a given URL from the OSM Server 69 * @param True if the data should be saved to a new layer70 * @param The URL as String78 * @param new_layer True if the data should be saved to a new layer 79 * @param url The URL as String 71 80 */ 72 81 public Future<?> loadUrl(boolean new_layer, String url, ProgressMonitor progressMonitor) { … … 216 225 targetLayer.onPostDownloadFromServer(); 217 226 } 227 228 suggestImageryLayers(); 218 229 } 219 230 … … 234 245 } 235 246 } 247 248 protected void suggestImageryLayers() { 249 final LatLon center = currentBounds.getCenter(); 250 final Set<ImageryInfo> layers = new HashSet<ImageryInfo>(); 251 252 for (ImageryInfo i : ImageryLayerInfo.instance.getDefaultLayers()) { 253 if (i.getBounds() != null && i.getBounds().contains(center)) { 254 layers.add(i); 255 } 256 } 257 layers.removeAll(ImageryLayerInfo.instance.getLayers()); 258 if (layers.isEmpty()) { 259 return; 260 } 261 262 final List<String> layerNames = new ArrayList<String>(); 263 for (ImageryInfo i : layers) { 264 layerNames.add(i.getName()); 265 } 266 267 if (!ConditionalOptionPaneUtil.showConfirmationDialog( 268 "download.suggest-imagery-layer", 269 Main.parent, 270 tr("<html>For the downloaded area, the following additional imagery layers are available: {0}" + 271 "Do you want to add those layers to the <em>Imagery</em> menu?" + 272 "<br>(If needed, you can remove those entries in the <em>Preferences</em>.)", 273 Utils.joinAsHtmlUnorderedList(layerNames)), 274 tr("Add imagery layers?"), 275 JOptionPane.YES_NO_OPTION, 276 JOptionPane.QUESTION_MESSAGE, 277 JOptionPane.YES_OPTION)) { 278 return; 279 } 280 281 ImageryLayerInfo.addLayers(layers); 282 } 283 236 284 } 237 285 }
Note:
See TracChangeset
for help on using the changeset viewer.