Index: trunk/src/org/openstreetmap/josm/Main.java
===================================================================
--- trunk/src/org/openstreetmap/josm/Main.java	(revision 12631)
+++ trunk/src/org/openstreetmap/josm/Main.java	(revision 12633)
@@ -6,9 +6,6 @@
 import java.awt.Component;
 import java.awt.GraphicsEnvironment;
-import java.io.File;
 import java.io.IOException;
 import java.lang.ref.WeakReference;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.text.MessageFormat;
@@ -25,5 +22,4 @@
 import java.util.Objects;
 import java.util.Set;
-import java.util.StringTokenizer;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
@@ -35,5 +31,4 @@
 import javax.swing.InputMap;
 import javax.swing.JComponent;
-import javax.swing.JOptionPane;
 import javax.swing.KeyStroke;
 import javax.swing.LookAndFeel;
@@ -42,12 +37,5 @@
 
 import org.openstreetmap.josm.actions.JosmAction;
-import org.openstreetmap.josm.actions.OpenFileAction;
-import org.openstreetmap.josm.actions.OpenLocationAction;
-import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;
-import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
-import org.openstreetmap.josm.actions.downloadtasks.DownloadTask;
-import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler;
 import org.openstreetmap.josm.actions.mapmode.DrawAction;
-import org.openstreetmap.josm.actions.search.SearchAction;
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.Preferences;
@@ -55,5 +43,4 @@
 import org.openstreetmap.josm.data.cache.JCSCacheManager;
 import org.openstreetmap.josm.data.coor.CoordinateFormat;
-import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -65,6 +52,4 @@
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.MapFrameListener;
-import org.openstreetmap.josm.gui.ProgramArguments;
-import org.openstreetmap.josm.gui.ProgramArguments.Option;
 import org.openstreetmap.josm.gui.io.SaveLayersDialog;
 import org.openstreetmap.josm.gui.layer.MainLayerManager;
@@ -86,5 +71,4 @@
 import org.openstreetmap.josm.tools.JosmRuntimeException;
 import org.openstreetmap.josm.tools.Logging;
-import org.openstreetmap.josm.tools.OsmUrlToBounds;
 import org.openstreetmap.josm.tools.PlatformHook;
 import org.openstreetmap.josm.tools.PlatformHookOsx;
@@ -841,32 +825,4 @@
 
     /**
-     * Handle command line instructions after GUI has been initialized.
-     * @param args program arguments
-     * @return the list of submitted tasks
-     */
-    protected static List<Future<?>> postConstructorProcessCmdLine(ProgramArguments args) {
-        List<Future<?>> tasks = new ArrayList<>();
-        List<File> fileList = new ArrayList<>();
-        for (String s : args.get(Option.DOWNLOAD)) {
-            tasks.addAll(DownloadParamType.paramType(s).download(s, fileList));
-        }
-        if (!fileList.isEmpty()) {
-            tasks.add(OpenFileAction.openFiles(fileList, true));
-        }
-        for (String s : args.get(Option.DOWNLOADGPS)) {
-            tasks.addAll(DownloadParamType.paramType(s).downloadGps(s));
-        }
-        final Collection<String> selectionArguments = args.get(Option.SELECTION);
-        if (!selectionArguments.isEmpty()) {
-            tasks.add(Main.worker.submit(() -> {
-                for (String s : selectionArguments) {
-                    SearchAction.search(s, SearchAction.SearchMode.add);
-                }
-            }));
-        }
-        return tasks;
-    }
-
-    /**
      * Closes JOSM and optionally terminates the Java Virtual Machine (JVM).
      * If there are some unsaved data layers, asks first for user confirmation.
@@ -914,140 +870,4 @@
             ImageProvider.shutdown(true);
         }
-    }
-
-    /**
-     * The type of a command line parameter, to be used in switch statements.
-     * @see #paramType
-     */
-    enum DownloadParamType {
-        httpUrl {
-            @Override
-            List<Future<?>> download(String s, Collection<File> fileList) {
-                return new OpenLocationAction().openUrl(false, s);
-            }
-
-            @Override
-            List<Future<?>> downloadGps(String s) {
-                final Bounds b = OsmUrlToBounds.parse(s);
-                if (b == null) {
-                    JOptionPane.showMessageDialog(
-                            Main.parent,
-                            tr("Ignoring malformed URL: \"{0}\"", s),
-                            tr("Warning"),
-                            JOptionPane.WARNING_MESSAGE
-                    );
-                    return Collections.emptyList();
-                }
-                return downloadFromParamBounds(true, b);
-            }
-        }, fileUrl {
-            @Override
-            List<Future<?>> download(String s, Collection<File> fileList) {
-                File f = null;
-                try {
-                    f = new File(new URI(s));
-                } catch (URISyntaxException e) {
-                    Logging.warn(e);
-                    JOptionPane.showMessageDialog(
-                            Main.parent,
-                            tr("Ignoring malformed file URL: \"{0}\"", s),
-                            tr("Warning"),
-                            JOptionPane.WARNING_MESSAGE
-                    );
-                }
-                if (f != null) {
-                    fileList.add(f);
-                }
-                return Collections.emptyList();
-            }
-        }, bounds {
-
-            /**
-             * Download area specified on the command line as bounds string.
-             * @param rawGps Flag to download raw GPS tracks
-             * @param s The bounds parameter
-             * @return the complete download task (including post-download handler), or {@code null}
-             */
-            private List<Future<?>> downloadFromParamBounds(final boolean rawGps, String s) {
-                final StringTokenizer st = new StringTokenizer(s, ",");
-                if (st.countTokens() == 4) {
-                    return Main.downloadFromParamBounds(rawGps, new Bounds(
-                            new LatLon(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken())),
-                            new LatLon(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()))
-                    ));
-                }
-                return Collections.emptyList();
-            }
-
-            @Override
-            List<Future<?>> download(String param, Collection<File> fileList) {
-                return downloadFromParamBounds(false, param);
-            }
-
-            @Override
-            List<Future<?>> downloadGps(String param) {
-                return downloadFromParamBounds(true, param);
-            }
-        }, fileName {
-            @Override
-            List<Future<?>> download(String s, Collection<File> fileList) {
-                fileList.add(new File(s));
-                return Collections.emptyList();
-            }
-        };
-
-        /**
-         * Performs the download
-         * @param param represents the object to be downloaded
-         * @param fileList files which shall be opened, should be added to this collection
-         * @return the download task, or {@code null}
-         */
-        abstract List<Future<?>> download(String param, Collection<File> fileList);
-
-        /**
-         * Performs the GPS download
-         * @param param represents the object to be downloaded
-         * @return the download task, or {@code null}
-         */
-        List<Future<?>> downloadGps(String param) {
-            if (!GraphicsEnvironment.isHeadless()) {
-                JOptionPane.showMessageDialog(
-                        Main.parent,
-                        tr("Parameter \"downloadgps\" does not accept file names or file URLs"),
-                        tr("Warning"),
-                        JOptionPane.WARNING_MESSAGE
-                );
-            }
-            return Collections.emptyList();
-        }
-
-        /**
-         * Guess the type of a parameter string specified on the command line with --download= or --downloadgps.
-         *
-         * @param s A parameter string
-         * @return The guessed parameter type
-         */
-        static DownloadParamType paramType(String s) {
-            if (s.startsWith("http:") || s.startsWith("https:")) return DownloadParamType.httpUrl;
-            if (s.startsWith("file:")) return DownloadParamType.fileUrl;
-            String coorPattern = "\\s*[+-]?[0-9]+(\\.[0-9]+)?\\s*";
-            if (s.matches(coorPattern + "(," + coorPattern + "){3}")) return DownloadParamType.bounds;
-            // everything else must be a file name
-            return DownloadParamType.fileName;
-        }
-    }
-
-    /**
-     * Download area specified as Bounds value.
-     * @param rawGps Flag to download raw GPS tracks
-     * @param b The bounds value
-     * @return the complete download task (including post-download handler)
-     */
-    private static List<Future<?>> downloadFromParamBounds(final boolean rawGps, Bounds b) {
-        DownloadTask task = rawGps ? new DownloadGpsTask() : new DownloadOsmTask();
-        // asynchronously launch the download task ...
-        Future<?> future = task.download(true, b, null);
-        // ... and the continuation when the download is finished (this will wait for the download to finish)
-        return Collections.singletonList(Main.worker.submit(new PostDownloadHandler(task, future)));
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/DownloadParamType.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/DownloadParamType.java	(revision 12633)
+++ trunk/src/org/openstreetmap/josm/gui/DownloadParamType.java	(revision 12633)
@@ -0,0 +1,152 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.GraphicsEnvironment;
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.concurrent.Future;
+
+import javax.swing.JOptionPane;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.OpenLocationAction;
+import org.openstreetmap.josm.data.Bounds;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.tools.Logging;
+import org.openstreetmap.josm.tools.OsmUrlToBounds;
+
+/**
+ * The type of a command line parameter, to be used in switch statements.
+ * @since 12633 (extracted from {@code Main})
+ */
+public enum DownloadParamType {
+    /** http(s):// URL */
+    httpUrl {
+        @Override
+        public List<Future<?>> download(String s, Collection<File> fileList) {
+            return new OpenLocationAction().openUrl(false, s);
+        }
+
+        @Override
+        public List<Future<?>> downloadGps(String s) {
+            final Bounds b = OsmUrlToBounds.parse(s);
+            if (b == null) {
+                JOptionPane.showMessageDialog(
+                        Main.parent,
+                        tr("Ignoring malformed URL: \"{0}\"", s),
+                        tr("Warning"),
+                        JOptionPane.WARNING_MESSAGE
+                );
+                return Collections.emptyList();
+            }
+            return MainApplication.downloadFromParamBounds(true, b);
+        }
+    },
+    /** file:// URL */
+    fileUrl {
+        @Override
+        public List<Future<?>> download(String s, Collection<File> fileList) {
+            File f = null;
+            try {
+                f = new File(new URI(s));
+            } catch (URISyntaxException e) {
+                Logging.warn(e);
+                JOptionPane.showMessageDialog(
+                        Main.parent,
+                        tr("Ignoring malformed file URL: \"{0}\"", s),
+                        tr("Warning"),
+                        JOptionPane.WARNING_MESSAGE
+                );
+            }
+            if (f != null) {
+                fileList.add(f);
+            }
+            return Collections.emptyList();
+        }
+    },
+    /** geographic area */
+    bounds {
+
+        /**
+         * Download area specified on the command line as bounds string.
+         * @param rawGps Flag to download raw GPS tracks
+         * @param s The bounds parameter
+         * @return the complete download task (including post-download handler), or {@code null}
+         */
+        private List<Future<?>> downloadFromParamBounds(final boolean rawGps, String s) {
+            final StringTokenizer st = new StringTokenizer(s, ",");
+            if (st.countTokens() == 4) {
+                return MainApplication.downloadFromParamBounds(rawGps, new Bounds(
+                        new LatLon(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken())),
+                        new LatLon(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()))
+                ));
+            }
+            return Collections.emptyList();
+        }
+
+        @Override
+        public List<Future<?>> download(String param, Collection<File> fileList) {
+            return downloadFromParamBounds(false, param);
+        }
+
+        @Override
+        public List<Future<?>> downloadGps(String param) {
+            return downloadFromParamBounds(true, param);
+        }
+    },
+    /** local file name */
+    fileName {
+        @Override
+        public List<Future<?>> download(String s, Collection<File> fileList) {
+            fileList.add(new File(s));
+            return Collections.emptyList();
+        }
+    };
+
+    /**
+     * Performs the download
+     * @param param represents the object to be downloaded
+     * @param fileList files which shall be opened, should be added to this collection
+     * @return the download task, or {@code null}
+     */
+    public abstract List<Future<?>> download(String param, Collection<File> fileList);
+
+    /**
+     * Performs the GPS download
+     * @param param represents the object to be downloaded
+     * @return the download task, or {@code null}
+     */
+    public List<Future<?>> downloadGps(String param) {
+        if (!GraphicsEnvironment.isHeadless()) {
+            JOptionPane.showMessageDialog(
+                    Main.parent,
+                    tr("Parameter \"downloadgps\" does not accept file names or file URLs"),
+                    tr("Warning"),
+                    JOptionPane.WARNING_MESSAGE
+            );
+        }
+        return Collections.emptyList();
+    }
+
+    /**
+     * Guess the type of a parameter string specified on the command line with --download= or --downloadgps.
+     *
+     * @param s A parameter string
+     * @return The guessed parameter type
+     */
+    public static DownloadParamType paramType(String s) {
+        if (s.startsWith("http:") || s.startsWith("https:")) return DownloadParamType.httpUrl;
+        if (s.startsWith("file:")) return DownloadParamType.fileUrl;
+        String coorPattern = "\\s*[+-]?[0-9]+(\\.[0-9]+)?\\s*";
+        if (s.matches(coorPattern + "(," + coorPattern + "){3}")) return DownloadParamType.bounds;
+        // everything else must be a file name
+        return DownloadParamType.fileName;
+    }
+}
Index: trunk/src/org/openstreetmap/josm/gui/MainApplication.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 12631)
+++ trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 12633)
@@ -36,4 +36,5 @@
 import java.util.TreeSet;
 import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
 import java.util.logging.Level;
 import java.util.stream.Collectors;
@@ -49,7 +50,13 @@
 import org.openstreetmap.gui.jmapviewer.FeatureAdapter;
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.OpenFileAction;
 import org.openstreetmap.josm.actions.PreferencesAction;
 import org.openstreetmap.josm.actions.RestartAction;
+import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;
+import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
+import org.openstreetmap.josm.actions.downloadtasks.DownloadTask;
+import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler;
 import org.openstreetmap.josm.actions.mapmode.DrawAction;
+import org.openstreetmap.josm.actions.search.SearchAction;
 import org.openstreetmap.josm.data.AutosaveTask;
 import org.openstreetmap.josm.data.Bounds;
@@ -653,4 +660,46 @@
     }
 
+    /**
+     * Download area specified as Bounds value.
+     * @param rawGps Flag to download raw GPS tracks
+     * @param b The bounds value
+     * @return the complete download task (including post-download handler)
+     */
+    static List<Future<?>> downloadFromParamBounds(final boolean rawGps, Bounds b) {
+        DownloadTask task = rawGps ? new DownloadGpsTask() : new DownloadOsmTask();
+        // asynchronously launch the download task ...
+        Future<?> future = task.download(true, b, null);
+        // ... and the continuation when the download is finished (this will wait for the download to finish)
+        return Collections.singletonList(Main.worker.submit(new PostDownloadHandler(task, future)));
+    }
+
+    /**
+     * Handle command line instructions after GUI has been initialized.
+     * @param args program arguments
+     * @return the list of submitted tasks
+     */
+    static List<Future<?>> postConstructorProcessCmdLine(ProgramArguments args) {
+        List<Future<?>> tasks = new ArrayList<>();
+        List<File> fileList = new ArrayList<>();
+        for (String s : args.get(Option.DOWNLOAD)) {
+            tasks.addAll(DownloadParamType.paramType(s).download(s, fileList));
+        }
+        if (!fileList.isEmpty()) {
+            tasks.add(OpenFileAction.openFiles(fileList, true));
+        }
+        for (String s : args.get(Option.DOWNLOADGPS)) {
+            tasks.addAll(DownloadParamType.paramType(s).downloadGps(s));
+        }
+        final Collection<String> selectionArguments = args.get(Option.SELECTION);
+        if (!selectionArguments.isEmpty()) {
+            tasks.add(Main.worker.submit(() -> {
+                for (String s : selectionArguments) {
+                    SearchAction.search(s, SearchAction.SearchMode.add);
+                }
+            }));
+        }
+        return tasks;
+    }
+
     private static class GuiFinalizationWorker implements Runnable {
 
Index: trunk/src/org/openstreetmap/josm/gui/ProgramArguments.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/ProgramArguments.java	(revision 12631)
+++ trunk/src/org/openstreetmap/josm/gui/ProgramArguments.java	(revision 12633)
@@ -20,5 +20,5 @@
 
 /**
- * This class holds the arguments passed on to Main.
+ * This class holds the arguments passed on to {@link MainApplication#main}.
  * @author Michael Zangl
  * @since 10899
