Changeset 11986 in josm for trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
- Timestamp:
- 2017-04-23T19:14:12+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
r11531 r11986 57 57 */ 58 58 private static final BooleanProperty USE_NEW_LAYER = new BooleanProperty("download.newlayer", false); 59 /** 60 * the list of download tasks 61 */ 59 62 protected final transient List<Class<? extends DownloadTask>> downloadTasks; 60 63 … … 200 203 * @param newLayer true if the URL needs to be opened in a new layer, false otherwise 201 204 * @param url The URL to open 202 */ 203 public void openUrl(boolean newLayer, String url) { 204 realOpenUrl(newLayer, url); 205 * @return the list of tasks that have been started successfully (can be empty). 206 * @since 11986 (return type) 207 */ 208 public List<Future<?>> openUrl(boolean newLayer, String url) { 209 return realOpenUrl(newLayer, url); 205 210 } 206 211 … … 208 213 * Open the given URL. This class checks the {@link #USE_NEW_LAYER} preference to check if a new layer should be used. 209 214 * @param url The URL to open 210 * @return <code>true</code> if at least one task was started successfully.211 * @since 11 279212 */ 213 public booleanopenUrl(String url) {215 * @return the list of tasks that have been started successfully (can be empty). 216 * @since 11986 (return type) 217 */ 218 public List<Future<?>> openUrl(String url) { 214 219 return realOpenUrl(USE_NEW_LAYER.get(), url); 215 220 } 216 221 217 private booleanrealOpenUrl(boolean newLayer, String url) {222 private List<Future<?>> realOpenUrl(boolean newLayer, String url) { 218 223 Collection<DownloadTask> tasks = findDownloadTasks(url, false); 219 224 … … 222 227 } else if (tasks.isEmpty()) { 223 228 warnNoSuitableTasks(url); 224 return false;229 return Collections.emptyList(); 225 230 } 226 231 227 232 PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download Data")); 228 233 229 boolean hadAnySuccess = false;234 List<Future<?>> result = new ArrayList<>(); 230 235 for (final DownloadTask task : tasks) { 231 236 try { 232 Future<?> future = task.loadUrl(newLayer, url, monitor); 233 Main.worker.submit(new PostDownloadHandler(task, future)); 234 hadAnySuccess = true; 237 result.add(Main.worker.submit(new PostDownloadHandler(task, task.loadUrl(newLayer, url, monitor)))); 235 238 } catch (IllegalArgumentException e) { 236 239 Main.error(e); 237 240 } 238 241 } 239 return hadAnySuccess;242 return result; 240 243 } 241 244
Note:
See TracChangeset
for help on using the changeset viewer.