Changeset 1811 in josm for trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java
- Timestamp:
- 2009-07-19T17:38:55+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java
r1756 r1811 23 23 import org.openstreetmap.josm.gui.layer.Layer; 24 24 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 25 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 26 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 25 27 26 28 /** … … 33 35 public class DownloadOsmTaskList implements Runnable { 34 36 private List<DownloadTask> osmTasks = new LinkedList<DownloadTask>(); 37 private ProgressMonitor progressMonitor; 35 38 36 39 /** … … 39 42 * @param The List of Rectangle2D to download 40 43 */ 41 public void download(boolean newLayer, List<Rectangle2D> rects) { 44 public void download(boolean newLayer, List<Rectangle2D> rects, ProgressMonitor progressMonitor) { 45 this.progressMonitor = progressMonitor; 42 46 if(newLayer) { 43 47 Layer l = new OsmDataLayer(new DataSet(), OsmDataLayer.createNewName(), null); … … 46 50 } 47 51 48 int i = 0; 49 for(Rectangle2D td : rects) { 50 i++; 51 DownloadTask dt = new DownloadOsmTask(); 52 dt.download(null, td.getMinY(), td.getMinX(), td.getMaxY(), td.getMaxX(), true, 53 tr("Download {0} of {1} ({2} left)", i, rects.size(), rects.size()-i)); 54 osmTasks.add(dt); 55 } 56 57 // If we try to get the error message now the download task will never have been started 58 // and we'd be stuck in a classical dead lock. Instead attach this to the worker and once 59 // run() gets called all downloadTasks have finished and we can grab the error messages. 60 Main.worker.execute(this); 52 progressMonitor.beginTask(null, rects.size()); 53 try { 54 int i = 0; 55 for(Rectangle2D td : rects) { 56 i++; 57 DownloadTask dt = new DownloadOsmTask(); 58 ProgressMonitor childProgress = progressMonitor.createSubTaskMonitor(1, false); 59 childProgress.setSilent(true); 60 childProgress.setCustomText(tr("Download {0} of {1} ({2} left)", i, rects.size(), rects.size()-i)); 61 dt.download(null, td.getMinY(), td.getMinX(), td.getMaxY(), td.getMaxX(), childProgress); 62 osmTasks.add(dt); 63 } 64 } finally { 65 // If we try to get the error message now the download task will never have been started 66 // and we'd be stuck in a classical dead lock. Instead attach this to the worker and once 67 // run() gets called all downloadTasks have finished and we can grab the error messages. 68 Main.worker.execute(this); 69 } 61 70 } 62 71 … … 72 81 } 73 82 74 download(newLayer, rects); 83 download(newLayer, rects, NullProgressMonitor.INSTANCE); 75 84 } 76 85 … … 79 88 */ 80 89 public void run() { 90 progressMonitor.finishTask(); 81 91 String errors = ""; 82 92 … … 109 119 * Updates the local state of a set of primitives (given by a set of primitive 110 120 * ids) with the state currently held on the server. 111 * 121 * 112 122 * @param potentiallyDeleted a set of ids to check update from the server 113 123 */ … … 135 145 * the current state on the server. If yes, retrieves the current state on the server 136 146 * and checks whether the primitives are indeed deleted on the server. 137 * 147 * 138 148 * @param potentiallyDeleted a set of primitives (given by their ids) 139 149 */ … … 177 187 * replies true, if the primitive with id <code>id</code> was downloaded into the 178 188 * dataset <code>ds</code> 179 * 189 * 180 190 * @param id the id 181 191 * @param ds the dataset … … 191 201 * replies true, if the primitive with id <code>id</code> was downloaded into the 192 202 * dataset of one of the download tasks 193 * 203 * 194 204 * @param id the id 195 205 * @return true, if the primitive with id <code>id</code> was downloaded into the 196 206 * dataset of one of the download tasks 197 * 207 * 198 208 */ 199 209 public boolean wasDownloaded(long id) { … … 209 219 /** 210 220 * Replies the set of primitive ids which have been downloaded by this task list 211 * 221 * 212 222 * @return the set of primitive ids which have been downloaded by this task list 213 223 */
Note:
See TracChangeset
for help on using the changeset viewer.