Changeset 1869 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2009-07-28T22:08:08+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r1811 r1869 5 5 6 6 import java.io.IOException; 7 import java.util.Collection; 7 8 import java.util.concurrent.Future; 8 9 … … 17 18 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 18 19 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask; 20 import org.openstreetmap.josm.gui.layer.Layer; 19 21 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 20 22 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; … … 57 59 } 58 60 61 protected int getNumDataLayers() { 62 int count = 0; 63 if (Main.map == null) return 0; 64 if (Main.map.mapView == null) return 0; 65 Collection<Layer> layers = Main.map.mapView.getAllLayers(); 66 for (Layer layer : layers) { 67 if (layer instanceof OsmDataLayer) { 68 count++; 69 } 70 } 71 return count; 72 } 73 74 protected OsmDataLayer getFirstDataLayer() { 75 if (Main.map == null) return null; 76 if (Main.map.mapView == null) return null; 77 Collection<Layer> layers = Main.map.mapView.getAllLayers(); 78 for (Layer layer : layers) { 79 if (layer instanceof OsmDataLayer) 80 return (OsmDataLayer) layer; 81 } 82 return null; 83 } 84 59 85 @Override protected void finish() { 60 86 if (dataSet == null) … … 67 93 } 68 94 rememberDownloadedData(dataSet); 69 if (newLayer || getEditLayer() == null) { 95 int numDataLayers = getNumDataLayers(); 96 if (newLayer || numDataLayers == 0 || (numDataLayers > 1 && getEditLayer() == null)) { 97 // the user explicitly wants a new layer, we don't have any layer at all 98 // or it is not clear which layer to merge to 99 // 70 100 OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null); 71 101 Main.main.addLayer(layer); 72 102 } else { 73 getEditLayer().mergeFrom(dataSet); 103 OsmDataLayer target; 104 target = getEditLayer(); 105 if (target == null) { 106 target = getFirstDataLayer(); 107 } 108 target.mergeFrom(dataSet); 74 109 } 75 110 }
Note:
See TracChangeset
for help on using the changeset viewer.