Index: trunk/src/org/openstreetmap/josm/io/NoteImporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/NoteImporter.java	(revision 12623)
+++ trunk/src/org/openstreetmap/josm/io/NoteImporter.java	(revision 12630)
@@ -12,4 +12,5 @@
 import org.openstreetmap.josm.actions.ExtensionFileFilter;
 import org.openstreetmap.josm.data.notes.Note;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.layer.NoteLayer;
 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
@@ -63,5 +64,5 @@
         final List<Note> fileNotes = new NoteReader(in).parse();
         List<NoteLayer> noteLayers = null;
-        if (Main.map != null) {
+        if (MainApplication.getMap() != null) {
             noteLayers = Main.getLayerManager().getLayersOfType(NoteLayer.class);
         }
Index: trunk/src/org/openstreetmap/josm/io/OsmApi.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 12623)
+++ trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 12630)
@@ -30,4 +30,5 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.layer.ImageryLayer;
 import org.openstreetmap.josm.gui.layer.Layer;
@@ -241,5 +242,5 @@
              * to load the layers in the first place because they would have
              * been disabled! */
-            if (Main.isDisplayingMapView()) {
+            if (MainApplication.isDisplayingMapView()) {
                 for (Layer l : Main.getLayerManager().getLayersOfType(ImageryLayer.class)) {
                     if (((ImageryLayer) l).getInfo().isBlacklisted()) {
Index: trunk/src/org/openstreetmap/josm/io/WMSLayerExporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/WMSLayerExporter.java	(revision 12623)
+++ trunk/src/org/openstreetmap/josm/io/WMSLayerExporter.java	(revision 12630)
@@ -7,7 +7,7 @@
 import java.io.ObjectOutputStream;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.Preferences;
 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryPreferenceEntry;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
 import org.openstreetmap.josm.gui.layer.Layer;
@@ -40,5 +40,5 @@
             try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file))) {
                 oos.writeInt(CURRENT_FILE_VERSION); // file version
-                oos.writeObject(Main.map.mapView.getCenter());
+                oos.writeObject(MainApplication.getMap().mapView.getCenter());
                 ImageryPreferenceEntry entry = new ImageryPreferenceEntry(((AbstractTileSourceLayer) layer).getInfo());
                 oos.writeObject(Preferences.serializeStruct(entry, ImageryPreferenceEntry.class));
Index: trunk/src/org/openstreetmap/josm/io/WMSLayerImporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/WMSLayerImporter.java	(revision 12623)
+++ trunk/src/org/openstreetmap/josm/io/WMSLayerImporter.java	(revision 12630)
@@ -17,4 +17,5 @@
 import org.openstreetmap.josm.data.imagery.ImageryInfo;
 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryPreferenceEntry;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.layer.ImageryLayer;
 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
@@ -88,5 +89,5 @@
             Main.getLayerManager().addLayer(layer);
             if (zoomTo != null) {
-                Main.map.mapView.zoomTo(zoomTo);
+                MainApplication.getMap().mapView.zoomTo(zoomTo);
             }
         });
Index: trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java	(revision 12623)
+++ trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java	(revision 12630)
@@ -14,4 +14,6 @@
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.util.GuiHelper;
 import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog;
@@ -85,7 +87,8 @@
         Node node = null;
 
-        if (Main.isDisplayingMapView()) {
-            Point p = Main.map.mapView.getPoint(ll);
-            node = Main.map.mapView.getNearestNode(p, OsmPrimitive::isUsable);
+        if (MainApplication.isDisplayingMapView()) {
+            MapView mapView = MainApplication.getMap().mapView;
+            Point p = mapView.getPoint(ll);
+            node = mapView.getNearestNode(p, OsmPrimitive::isUsable);
             if (node != null && node.getCoor().greatCircleDistance(ll) > Main.pref.getDouble("remotecontrol.tolerance", 0.1)) {
                 node = null; // node is too far
@@ -103,5 +106,5 @@
             AutoScaleAction.autoScale("selection");
         } else {
-            Main.map.mapView.repaint();
+            MainApplication.getMap().mapView.repaint();
         }
         // parse parameter addtags=tag1=value1|tag2=vlaue2
Index: trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java	(revision 12623)
+++ trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java	(revision 12630)
@@ -4,5 +4,4 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import java.awt.Point;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -23,4 +22,6 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.util.GuiHelper;
 import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog;
@@ -125,7 +126,7 @@
         Node nd = null;
 
-        if (Main.isDisplayingMapView()) {
-            Point p = Main.map.mapView.getPoint(ll);
-            nd = Main.map.mapView.getNearestNode(p, OsmPrimitive::isUsable);
+        if (MainApplication.isDisplayingMapView()) {
+            MapView mapView = MainApplication.getMap().mapView;
+            nd = mapView.getNearestNode(mapView.getPoint(ll), OsmPrimitive::isUsable);
             if (nd != null && nd.getCoor().greatCircleDistance(ll) > Main.pref.getDouble("remote.tolerance", 0.1)) {
                 nd = null; // node is too far
@@ -171,5 +172,5 @@
             AutoScaleAction.autoScale("selection");
         } else {
-            Main.map.mapView.repaint();
+            MainApplication.getMap().mapView.repaint();
         }
         return way;
Index: trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java	(revision 12623)
+++ trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java	(revision 12630)
@@ -10,4 +10,5 @@
 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
 import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
+import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.layer.ImageryLayer;
 import org.openstreetmap.josm.gui.util.GuiHelper;
@@ -95,5 +96,5 @@
     protected void handleRequest() throws RequestHandlerErrorException {
         final ImageryInfo imgInfo = buildImageryInfo();
-        if (Main.isDisplayingMapView()) {
+        if (MainApplication.isDisplayingMapView()) {
             for (ImageryLayer layer : Main.getLayerManager().getLayersOfType(ImageryLayer.class)) {
                 if (layer.getInfo().equals(imgInfo)) {
Index: trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java	(revision 12623)
+++ trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java	(revision 12630)
@@ -26,4 +26,6 @@
 import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.util.GuiHelper;
 import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog;
@@ -184,8 +186,9 @@
                 ds.setSelected(newSel);
                 zoom(newSel, bbox);
-                if (Main.isDisplayingMapView() && Main.map.relationListDialog != null) {
-                    Main.map.relationListDialog.selectRelations(null); // unselect all relations to fix #7342
-                    Main.map.relationListDialog.dataChanged(null);
-                    Main.map.relationListDialog.selectRelations(Utils.filteredCollection(newSel, Relation.class));
+                MapFrame map = MainApplication.getMap();
+                if (MainApplication.isDisplayingMapView() && map.relationListDialog != null) {
+                    map.relationListDialog.selectRelations(null); // unselect all relations to fix #7342
+                    map.relationListDialog.dataChanged(null);
+                    map.relationListDialog.selectRelations(Utils.filteredCollection(newSel, Relation.class));
                 }
             });
@@ -233,10 +236,10 @@
         if (!"download".equals(args.get("zoom_mode")) && !primitives.isEmpty()) {
             AutoScaleAction.autoScale("selection");
-        } else if (Main.isDisplayingMapView()) {
+        } else if (MainApplication.isDisplayingMapView()) {
             // make sure this isn't called unless there *is* a MapView
             GuiHelper.executeByMainWorkerInEDT(() -> {
                 BoundingXYVisitor bbox1 = new BoundingXYVisitor();
                 bbox1.visit(bbox);
-                Main.map.mapView.zoomTo(bbox1);
+                MainApplication.getMap().mapView.zoomTo(bbox1);
             });
         }
Index: trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java	(revision 12623)
+++ trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java	(revision 12630)
@@ -32,4 +32,6 @@
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.projection.Projections;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.layer.GpxLayer;
 import org.openstreetmap.josm.gui.layer.Layer;
@@ -262,5 +264,6 @@
         Element centerEl = doc.createElement("center");
         viewportEl.appendChild(centerEl);
-        EastNorth center = Main.map.mapView.getCenter();
+        MapView mapView = MainApplication.getMap().mapView;
+        EastNorth center = mapView.getCenter();
         LatLon centerLL = Projections.inverseProject(center);
         centerEl.setAttribute("lat", Double.toString(centerLL.lat()));
@@ -268,5 +271,5 @@
         Element scale = doc.createElement("scale");
         viewportEl.appendChild(scale);
-        double dist100px = Main.map.mapView.getDist100Pixel();
+        double dist100px = mapView.getDist100Pixel();
         scale.setAttribute("meter-per-pixel", Double.toString(dist100px / 100));
     }
