Index: trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java	(revision 11278)
+++ trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java	(revision 11279)
@@ -5,5 +5,4 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.GridLayout;
@@ -15,5 +14,7 @@
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.Future;
+import java.util.stream.Collectors;
 
 import javax.swing.JCheckBox;
@@ -38,8 +39,10 @@
 import org.openstreetmap.josm.actions.downloadtasks.DownloadTask;
 import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler;
+import org.openstreetmap.josm.data.preferences.BooleanProperty;
 import org.openstreetmap.josm.gui.ExtendedDialog;
 import org.openstreetmap.josm.gui.HelpAwareOptionPane;
 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
 import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
+import org.openstreetmap.josm.tools.GBC;
 import org.openstreetmap.josm.tools.Shortcut;
 import org.openstreetmap.josm.tools.Utils;
@@ -51,5 +54,8 @@
  */
 public class OpenLocationAction extends JosmAction {
-
+    /**
+     * true if the URL needs to be opened in a new layer, false otherwise
+     */
+    private static final BooleanProperty USE_NEW_LAYER = new BooleanProperty("download.newlayer", true);
     protected final transient List<Class<? extends DownloadTask>> downloadTasks;
 
@@ -103,23 +109,19 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-
-        JCheckBox layer = new JCheckBox(tr("Separate Layer"));
-        layer.setToolTipText(tr("Select if the data should be downloaded into a new layer"));
-        layer.setSelected(Main.pref.getBoolean("download.newlayer"));
         JPanel all = new JPanel(new GridBagLayout());
-        GridBagConstraints gc = new GridBagConstraints();
-        gc.fill = GridBagConstraints.HORIZONTAL;
-        gc.weightx = 1.0;
-        gc.anchor = GridBagConstraints.FIRST_LINE_START;
-        all.add(new JLabel(tr("Enter URL to download:")), gc);
+
+        // download URL selection
+        all.add(new JLabel(tr("Enter URL to download:")), GBC.eol());
         HistoryComboBox uploadAddresses = new HistoryComboBox();
         uploadAddresses.setToolTipText(tr("Enter an URL from where data should be downloaded"));
         restoreUploadAddressHistory(uploadAddresses);
-        gc.gridy = 1;
-        all.add(uploadAddresses, gc);
-        gc.gridy = 2;
-        gc.fill = GridBagConstraints.BOTH;
-        gc.weighty = 1.0;
-        all.add(layer, gc);
+        all.add(uploadAddresses, GBC.eop().fill(GBC.BOTH));
+
+        // use separate layer
+        JCheckBox layer = new JCheckBox(tr("Separate Layer"));
+        layer.setToolTipText(tr("Select if the data should be downloaded into a new layer"));
+        layer.setSelected(USE_NEW_LAYER.get());
+        all.add(layer, GBC.eop().fill(GBC.BOTH));
+
         ExtendedDialog dialog = new ExtendedDialog(Main.parent,
                 tr("Download Location"),
@@ -134,7 +136,9 @@
         dialog.configureContextsensitiveHelp("/Action/OpenLocation", true /* show help button */);
         dialog.showDialog();
-        if (dialog.getValue() != 1) return;
-        remindUploadAddressHistory(uploadAddresses);
-        openUrl(layer.isSelected(), Utils.strip(uploadAddresses.getText()));
+        if (dialog.getValue() == 1) {
+            USE_NEW_LAYER.put(layer.isSelected());
+            remindUploadAddressHistory(uploadAddresses);
+            openUrl(Utils.strip(uploadAddresses.getText()));
+        }
     }
 
@@ -147,18 +151,17 @@
      */
     public Collection<DownloadTask> findDownloadTasks(final String url, boolean isRemotecontrol) {
-        List<DownloadTask> result = new ArrayList<>();
-        for (Class<? extends DownloadTask> taskClass : downloadTasks) {
-            if (taskClass != null) {
-                try {
-                    DownloadTask task = taskClass.getConstructor().newInstance();
-                    if (task.acceptsUrl(url, isRemotecontrol)) {
-                        result.add(task);
+        return downloadTasks.stream()
+                .filter(Objects::nonNull)
+                .map(taskClass -> {
+                    try {
+                        return taskClass.getConstructor().newInstance();
+                    } catch (ReflectiveOperationException e) {
+                        Main.error(e);
+                        return null;
                     }
-                } catch (ReflectiveOperationException e) {
-                    Main.error(e);
-                }
-            }
-        }
-        return result;
+                })
+                .filter(Objects::nonNull)
+                .filter(task -> task.acceptsUrl(url, isRemotecontrol))
+                .collect(Collectors.toList());
     }
 
@@ -189,5 +192,18 @@
      * @param url The URL to open
      */
-    public void openUrl(boolean newLayer, final String url) {
+    public void openUrl(boolean newLayer, String url) {
+        realOpenUrl(newLayer, url);
+    }
+
+    /**
+     * Open the given URL. This class checks the {@link #USE_NEW_LAYER} preference to check if a new layer should be used.
+     * @param url The URL to open
+     * @return <code>true</code> if loading the task was started successfully.
+     */
+    public boolean openUrl(String url) {
+        return realOpenUrl(USE_NEW_LAYER.get(), url);
+    }
+
+    private boolean realOpenUrl(boolean newLayer, String url) {
         Collection<DownloadTask> tasks = findDownloadTasks(url, false);
 
@@ -196,5 +212,5 @@
         } else if (tasks.isEmpty()) {
             warnNoSuitableTasks(url);
-            return;
+            return false;
         }
 
@@ -205,8 +221,10 @@
                 Future<?> future = task.loadUrl(newLayer, url, monitor);
                 Main.worker.submit(new PostDownloadHandler(task, future));
+                return true;
             } catch (IllegalArgumentException e) {
                 Main.error(e);
             }
         }
+        return false;
     }
 
@@ -235,5 +253,5 @@
      * @param url the given url
      */
-    void warnNoSuitableTasks(final String url) {
+    protected void warnNoSuitableTasks(final String url) {
         final String details = findSummaryDocumentation();    // Explain what patterns are supported
         HelpAwareOptionPane.showMessageDialogInEDT(Main.parent, "<html><p>" + tr(
Index: trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/OsmLinkPaster.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/OsmLinkPaster.java	(revision 11278)
+++ trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/OsmLinkPaster.java	(revision 11279)
@@ -6,6 +6,4 @@
 import java.awt.datatransfer.UnsupportedFlavorException;
 import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -13,13 +11,9 @@
 import javax.swing.TransferHandler.TransferSupport;
 
-import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.OpenLocationAction;
 import org.openstreetmap.josm.data.coor.EastNorth;
 import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
-import org.openstreetmap.josm.data.osm.PrimitiveId;
-import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
 import org.openstreetmap.josm.data.preferences.BooleanProperty;
 import org.openstreetmap.josm.gui.MapView;
-import org.openstreetmap.josm.gui.io.DownloadPrimitivesWithReferrersTask;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 
@@ -52,9 +46,11 @@
 
         String transferData = (String) support.getTransferable().getTransferData(df);
-        List<PrimitiveId> ids = parseIds(transferData);
-
-        if (!ids.isEmpty()) {
-            Main.worker.submit(new DownloadPrimitivesWithReferrersTask(layer == null,
-                    ids, PASTE_REFERRERS.get(), PASTE_REFERRERS.get(), null, null));
+        OpenLocationAction action = new OpenLocationAction() {
+            @Override
+            protected void warnNoSuitableTasks(String url) {
+                // ignore this.
+            }
+        };
+        if (action.openUrl(transferData)) {
             return true;
         }
@@ -82,33 +78,3 @@
         }
     }
-
-    static List<PrimitiveId> parseIds(String transferData) {
-        Matcher matcher = Pattern
-                .compile(OSM_SERVER + "(?<type>node|way|relation)/(?<id>\\d+)(\\/.*)?$")
-                .matcher(transferData);
-
-        if (!matcher.matches()) {
-            return Collections.emptyList();
-        }
-
-        OsmPrimitiveType type;
-        switch (matcher.group("type")) {
-        case "way":
-            type = OsmPrimitiveType.WAY;
-            break;
-
-        case "node":
-            type = OsmPrimitiveType.NODE;
-            break;
-
-        case "relation":
-            type = OsmPrimitiveType.RELATION;
-            break;
-
-        default:
-            throw new AssertionError();
-        }
-
-        return Collections.singletonList(new SimplePrimitiveId(Long.parseLong(matcher.group("id")), type));
-    }
 }
