Changeset 1670 in josm for trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
- Timestamp:
- 15.06.2009 20:22:46 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r1647 r1670 22 22 import org.openstreetmap.josm.io.OsmServerLocationReader; 23 23 import org.openstreetmap.josm.io.OsmServerReader; 24 import org.openstreetmap.josm.io.OsmTransferException; 24 25 import org.xml.sax.SAXException; 25 26 … … 32 33 private static Bounds currentBounds; 33 34 private Future<Task> task = null; 35 private DataSet downloadedData; 34 36 35 private staticclass Task extends PleaseWaitRunnable {37 private class Task extends PleaseWaitRunnable { 36 38 private OsmServerReader reader; 37 39 private DataSet dataSet; … … 49 51 } 50 52 51 @Override public void realRun() throws IOException, SAXException {53 @Override public void realRun() throws IOException, SAXException, OsmTransferException { 52 54 Main.pleaseWaitDlg.setCustomText(msg); 53 55 dataSet = reader.parseOsm(); … … 59 61 if (dataSet.allPrimitives().isEmpty()) { 60 62 // If silent is set to true, we don't want to see information messages 61 if(!silent) 63 if(!silent) { 62 64 errorMessage = tr("No data imported."); 65 } 63 66 // need to synthesize a download bounds lest the visual indication of downloaded 64 67 // area doesn't work 65 68 dataSet.dataSources.add(new DataSource(currentBounds, "OpenStreetMap server")); 66 69 } 67 70 rememberDownloadedData(dataSet); 68 71 OsmDataLayer layer = new OsmDataLayer(dataSet, tr("Data Layer {0}", num), null); 69 if (newLayer) 72 if (newLayer) { 70 73 Main.main.addLayer(layer); 71 else74 } else { 72 75 Main.main.editLayer().mergeFrom(layer); 76 } 73 77 74 78 Main.pleaseWaitDlg.setCustomText(""); … … 76 80 77 81 @Override protected void cancel() { 78 if (reader != null) 82 if (reader != null) { 79 83 reader.cancel(); 84 } 80 85 Main.pleaseWaitDlg.cancel.setEnabled(false); 81 86 } 82 87 } 83 88 private JCheckBox checkBox = new JCheckBox(tr("OpenStreetMap data"), true); 89 90 private void rememberDownloadedData(DataSet ds) { 91 this.downloadedData = ds; 92 } 93 94 public DataSet getDownloadedData() { 95 return downloadedData; 96 } 84 97 85 98 public void download(DownloadAction action, double minlat, double minlon, … … 96 109 97 110 boolean newLayer = action != null 98 && (action.dialog == null || action.dialog.newLayer.isSelected());111 && (action.dialog == null || action.dialog.newLayer.isSelected()); 99 112 100 113 Task t = new Task(newLayer, … … 124 137 false, 125 138 getDataLayersCount(), 126 "");139 ""); 127 140 task = Main.worker.submit(t, t); 128 141 } … … 145 158 int num = 0; 146 159 for(Layer l : Main.map.mapView.getAllLayers()) 147 if(l instanceof OsmDataLayer) 160 if(l instanceof OsmDataLayer) { 148 161 num++; 162 } 149 163 return num; 150 164 } 151 165 152 /*153 * (non-Javadoc)154 * @see org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask#getErrorMessage()155 */166 /* 167 * (non-Javadoc) 168 * @see org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask#getErrorMessage() 169 */ 156 170 public String getErrorMessage() { 157 171 if(task == null) … … 161 175 Task t = task.get(); 162 176 return t.errorMessage == null 163 ? ""164 : t.errorMessage;177 ? "" 178 : t.errorMessage; 165 179 } catch (Exception e) { 166 180 return "";
Note: See TracChangeset
for help on using the changeset viewer.
