Changeset 5691 in josm for trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
- Timestamp:
- 2013-01-29T21:40:59+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
r5361 r5691 10 10 import java.awt.event.KeyEvent; 11 11 import java.util.ArrayList; 12 import java.util.Collection; 12 13 import java.util.Collections; 13 14 import java.util.LinkedList; … … 120 121 openUrl(layer.isSelected(), uploadAddresses.getText()); 121 122 } 122 123 123 124 /** 124 * Open the given URL. 125 * Replies the list of download tasks accepting the given url. 126 * @param url The URL to open 127 * @return The list of download tasks accepting the given url. 128 * @since 5691 125 129 */ 126 public void openUrl(boolean new_layer, final String url) { 127 PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download Data")); 128 DownloadTask task = null; 129 Future<?> future = null; 130 for (int i = 0; future == null && i < downloadTasks.size(); i++) { 130 public Collection<DownloadTask> findDownloadTasks(final String url) { 131 List<DownloadTask> result = new ArrayList<DownloadTask>(); 132 for (int i = 0; i < downloadTasks.size(); i++) { 131 133 Class<? extends DownloadTask> taskClass = downloadTasks.get(i); 132 134 if (taskClass != null) { 133 135 try { 134 task = taskClass.getConstructor().newInstance();136 DownloadTask task = taskClass.getConstructor().newInstance(); 135 137 if (task.acceptsUrl(url)) { 136 future = task.loadUrl(new_layer, url, monitor);138 result.add(task); 137 139 } 138 140 } catch (Exception e) { … … 140 142 } 141 143 } 144 } 145 return result; 146 } 147 148 /** 149 * Open the given URL. 150 * @param new_layer true if the URL needs to be opened in a new layer, false otherwise 151 * @param url The URL to open 152 */ 153 public void openUrl(boolean new_layer, final String url) { 154 PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download Data")); 155 Collection<DownloadTask> tasks = findDownloadTasks(url); 156 DownloadTask task = null; 157 Future<?> future = null; 158 if (!tasks.isEmpty()) { 159 // TODO: handle multiple suitable tasks ? 160 future = tasks.iterator().next().loadUrl(new_layer, url, monitor); 142 161 } 143 162 if (future != null) {
Note:
See TracChangeset
for help on using the changeset viewer.