Changeset 8197 in josm for trunk/src


Ignore:
Timestamp:
2015-04-15T21:11:28+02:00 (9 years ago)
Author:
simon04
Message:

see #9907 - Remote control: let the user decide which suitable download tasks to perform

This enables downloading notes from corresponding URLs (cf. #8195)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandler.java

    r8193 r8197  
    77import java.net.URL;
    88import java.util.Collection;
     9import java.util.LinkedHashSet;
     10import java.util.Set;
    911
    1012import org.openstreetmap.josm.Main;
     13import org.openstreetmap.josm.actions.OpenLocationAction;
    1114import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
    1215import org.openstreetmap.josm.actions.downloadtasks.DownloadTask;
     
    3033    protected void handleRequest() throws RequestHandlerErrorException {
    3134        try {
    32             if (suitableDownloadTasks != null && !suitableDownloadTasks.isEmpty()) {
    33                 // TODO: handle multiple suitable download tasks ?
    34                 suitableDownloadTasks.iterator().next().loadUrl(isLoadInNewLayer(), url.toExternalForm(), null);
     35            if (Main.pref.getBoolean("remotecontrol.import.interactive", true)) {
     36                // OpenLocationAction queries the user if more than one task is suitable
     37                new OpenLocationAction().openUrl(isLoadInNewLayer(), url.toExternalForm());
     38            } else {
     39                // Otherwise perform all tasks
     40                for (DownloadTask task : suitableDownloadTasks) {
     41                    task.loadUrl(isLoadInNewLayer(), url.toExternalForm(), null);
     42                }
    3543            }
    3644        } catch (Exception ex) {
     
    6876        // (Example with OSM-FR website that makes calls to the OSM-FR API)
    6977        // For user-friendliness, let's try to decode these OSM API calls to give a better confirmation message.
    70         String taskMessage = null;
     78        Set<String> taskMessages = new LinkedHashSet<>();
    7179        if (suitableDownloadTasks != null && !suitableDownloadTasks.isEmpty()) {
    72             // TODO: handle multiple suitable download tasks ?
    73             taskMessage = suitableDownloadTasks.iterator().next().getConfirmationMessage(url);
     80            for (DownloadTask task : suitableDownloadTasks) {
     81                taskMessages.add(Utils.firstNonNull(task.getConfirmationMessage(url), url.toString()));
     82            }
    7483        }
    7584        return tr("Remote Control has been asked to import data from the following URL:")
    76                 + "<br>" + (taskMessage == null ? url.toString() : taskMessage);
     85                + Utils.joinAsHtmlUnorderedList(taskMessages);
    7786    }
    7887
Note: See TracChangeset for help on using the changeset viewer.