Changeset 12636 in josm


Ignore:
Timestamp:
2017-08-24T22:53:50+02:00 (8 weeks ago)
Author:
Don-vip
Message:

see #15182 - deprecate Main.getLayerManager(). Replacement: gui.MainApplication.getLayerManager()

Location:
trunk
Files:
215 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r12634 r12636  
    3737
    3838import org.openstreetmap.josm.actions.JosmAction;
    39 import org.openstreetmap.josm.actions.mapmode.DrawAction;
    4039import org.openstreetmap.josm.data.Bounds;
    4140import org.openstreetmap.josm.data.Preferences;
     
    5251import org.openstreetmap.josm.gui.MapFrame;
    5352import org.openstreetmap.josm.gui.MapFrameListener;
    54 import org.openstreetmap.josm.gui.io.SaveLayersDialog;
    5553import org.openstreetmap.josm.gui.layer.MainLayerManager;
    5654import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener;
     
    5957import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
    6058import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
    61 import org.openstreetmap.josm.gui.util.GuiHelper;
    62 import org.openstreetmap.josm.gui.util.RedirectInputMap;
    6359import org.openstreetmap.josm.io.FileWatcher;
    6460import org.openstreetmap.josm.io.OnlineResource;
     
    145141
    146142    /**
    147      * Provides access to the layers displayed in the main view.
    148      * @since 10271
    149      */
    150     private static final MainLayerManager layerManager = new MainLayerManager();
    151 
    152     /**
    153143     * The toolbar preference control to register new actions.
    154144     */
     
    650640     * @return The layer manager. The value returned will never change.
    651641     * @since 10279
    652      */
     642     * @deprecated use {@link MainApplication#getLayerManager} instead
     643     */
     644    @Deprecated
    653645    public static MainLayerManager getLayerManager() {
    654         return layerManager;
     646        return MainApplication.getLayerManager();
    655647    }
    656648
     
    658650     * Replies the current selected primitives, from a end-user point of view.
    659651     * It is not always technically the same collection of primitives than {@link DataSet#getSelected()}.
    660      * Indeed, if the user is currently in drawing mode, only the way currently being drawn is returned,
    661      * see {@link DrawAction#getInProgressSelection()}.
    662      *
    663652     * @return The current selected primitives, from a end-user point of view. Can be {@code null}.
    664653     * @since 6546
    665654     */
    666655    public Collection<OsmPrimitive> getInProgressSelection() {
    667         DataSet ds = getLayerManager().getEditDataSet();
    668         if (ds == null) return null;
    669         return ds.getSelected();
    670     }
    671 
    672     public static void redirectToMainContentPane(JComponent source) {
    673         RedirectInputMap.redirect(source, contentPanePrivate);
     656        return Collections.emptyList();
    674657    }
    675658
     
    826809    /**
    827810     * Closes JOSM and optionally terminates the Java Virtual Machine (JVM).
    828      * If there are some unsaved data layers, asks first for user confirmation.
    829811     * @param exit If {@code true}, the JVM is terminated by running {@link System#exit} with a given return code.
    830812     * @param exitCode The return code
    831      * @param reason the reason for exiting
    832      * @return {@code true} if JOSM has been closed, {@code false} if the user has cancelled the operation.
    833      * @since 11093 (3378 with a different function signature)
    834      */
    835     public static boolean exitJosm(boolean exit, int exitCode, SaveLayersDialog.Reason reason) {
    836         final boolean proceed = Boolean.TRUE.equals(GuiHelper.runInEDTAndWaitAndReturn(() ->
    837                 SaveLayersDialog.saveUnsavedModifications(getLayerManager().getLayers(),
    838                         reason != null ? reason : SaveLayersDialog.Reason.EXIT)));
    839         if (proceed) {
    840             if (Main.main != null) {
    841                 Main.main.shutdown();
    842             }
    843 
    844             if (exit) {
    845                 System.exit(exitCode);
    846             }
    847             return true;
    848         }
    849         return false;
     813     * @return {@code true}
     814     * @since 12636
     815     */
     816    public static boolean exitJosm(boolean exit, int exitCode) {
     817        if (Main.main != null) {
     818            Main.main.shutdown();
     819        }
     820
     821        if (exit) {
     822            System.exit(exitCode);
     823        }
     824        return true;
    850825    }
    851826
     
    858833            JCSCacheManager.shutdown();
    859834        }
    860         // Remove all layers because somebody may rely on layerRemoved events (like AutosaveTask)
    861         getLayerManager().resetState();
    862835        try {
    863836            pref.saveDefaults();
  • trunk/src/org/openstreetmap/josm/actions/AbstractPasteAction.java

    r12630 r12636  
    99import java.awt.event.ActionEvent;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.data.coor.EastNorth;
    1312import org.openstreetmap.josm.gui.MainApplication;
     
    9291
    9392    protected void doPaste(ActionEvent e, Transferable contents) {
    94         transferHandler.pasteOn(Main.getLayerManager().getEditLayer(), computePastePosition(e), contents);
     93        transferHandler.pasteOn(getLayerManager().getEditLayer(), computePastePosition(e), contents);
    9594    }
    9695
  • trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java

    r12620 r12636  
    139139            final ImageryInfo infoToAdd = convertImagery(info);
    140140            if (infoToAdd != null) {
    141                 Main.getLayerManager().addLayer(ImageryLayer.create(infoToAdd));
     141                getLayerManager().addLayer(ImageryLayer.create(infoToAdd));
    142142                AlignImageryPanel.addNagPanelIfNeeded(infoToAdd);
    143143            }
  • trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java

    r12630 r12636  
    7171    /**
    7272     * Zooms the current map view to the currently selected primitives.
    73      * Does nothing if there either isn't a current map view or if there isn't a current data
    74      * layer.
     73     * Does nothing if there either isn't a current map view or if there isn't a current data layer.
    7574     *
    7675     */
    7776    public static void zoomToSelection() {
    78         DataSet dataSet = Main.getLayerManager().getEditDataSet();
     77        DataSet dataSet = MainApplication.getLayerManager().getEditDataSet();
    7978        if (dataSet == null) {
    8079            return;
     
    225224     */
    226225    protected Layer getFirstSelectedLayer() {
    227         if (Main.getLayerManager().getActiveLayer() == null) {
     226        if (getLayerManager().getActiveLayer() == null) {
    228227            return null;
    229228        }
     
    268267
    269268    private static BoundingXYVisitor modeData(BoundingXYVisitor v) {
    270         for (Layer l : Main.getLayerManager().getLayers()) {
     269        for (Layer l : MainApplication.getLayerManager().getLayers()) {
    271270            l.visitBoundingBox(v);
    272271        }
     
    337336                } else {
    338337                    lastZoomArea = -1;
    339                     Area sourceArea = Main.getLayerManager().getEditDataSet().getDataSourceArea();
     338                    Area sourceArea = getLayerManager().getEditDataSet().getDataSourceArea();
    340339                    if (sourceArea != null) {
    341340                        v.visit(new Bounds(sourceArea.getBounds2D()));
  • trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java

    r12635 r12636  
    117117                            if (Main.pref.getBoolean("multipoly.show-relation-editor", false)) {
    118118                                //Open relation edit window, if set up in preferences
    119                                 RelationEditor editor = RelationEditor.getEditor(Main.getLayerManager().getEditLayer(), relation, null);
     119                                RelationEditor editor = RelationEditor.getEditor(
     120                                        MainApplication.getLayerManager().getEditLayer(), relation, null);
    120121                                editor.setModal(true);
    121122                                editor.setVisible(true);
    122123                            } else {
    123                                 Main.getLayerManager().getEditLayer().setRecentRelation(relation);
     124                                MainApplication.getLayerManager().getEditLayer().setRecentRelation(relation);
    124125                            }
    125126                    });
     
    130131    @Override
    131132    public void actionPerformed(ActionEvent e) {
    132         DataSet dataSet = Main.getLayerManager().getEditDataSet();
     133        DataSet dataSet = getLayerManager().getEditDataSet();
    133134        if (dataSet == null) {
    134135            new Notification(
     
    162163            if (!multipolygonRelation.isNew() && multipolygonRelation.isIncomplete()) {
    163164                MainApplication.worker.submit(
    164                         new DownloadRelationTask(Collections.singleton(multipolygonRelation), Main.getLayerManager().getEditLayer()));
     165                        new DownloadRelationTask(Collections.singleton(multipolygonRelation), getLayerManager().getEditLayer()));
    165166            } else if (multipolygonRelation.hasIncompleteMembers()) {
    166167                MainApplication.worker.submit(new DownloadRelationMemberTask(multipolygonRelation,
    167168                        DownloadSelectedIncompleteMembersAction.buildSetOfIncompleteMembers(Collections.singleton(multipolygonRelation)),
    168                         Main.getLayerManager().getEditLayer()));
     169                        getLayerManager().getEditLayer()));
    169170            }
    170171        }
  • trunk/src/org/openstreetmap/josm/actions/DeleteLayerAction.java

    r11093 r12636  
    99import java.util.Collections;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.gui.io.SaveLayersDialog;
    1312import org.openstreetmap.josm.gui.layer.Layer;
     
    3130    @Override
    3231    public void actionPerformed(ActionEvent e) {
    33         Layer activeLayer = Main.getLayerManager().getActiveLayer();
     32        Layer activeLayer = getLayerManager().getActiveLayer();
    3433        if (activeLayer == null) {
    3534            return;
     
    3837            return;
    3938        }
    40         Main.getLayerManager().removeLayer(activeLayer);
     39        getLayerManager().removeLayer(activeLayer);
    4140    }
    4241
    4342    @Override
    4443    protected void updateEnabledState() {
    45         setEnabled(Main.getLayerManager().getActiveLayer() != null);
     44        setEnabled(getLayerManager().getActiveLayer() != null);
    4645    }
    4746}
  • trunk/src/org/openstreetmap/josm/actions/DownloadNotesInViewAction.java

    r12634 r12636  
    5353    @Override
    5454    protected void updateEnabledState() {
    55         setEnabled(Main.getLayerManager().getActiveLayer() != null
     55        setEnabled(getLayerManager().getActiveLayer() != null
    5656                && !Main.isOffline(OnlineResource.OSM_API));
    5757    }
  • trunk/src/org/openstreetmap/josm/actions/DownloadOsmInViewAction.java

    r12634 r12636  
    4141    @Override
    4242    protected void updateEnabledState() {
    43         setEnabled(Main.getLayerManager().getActiveLayer() != null
     43        setEnabled(getLayerManager().getActiveLayer() != null
    4444                && !Main.isOffline(OnlineResource.OSM_API));
    4545    }
  • trunk/src/org/openstreetmap/josm/actions/DownloadPrimitiveAction.java

    r12634 r12636  
    99import java.util.List;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.data.osm.PrimitiveId;
    1312import org.openstreetmap.josm.gui.MainApplication;
     
    5958                final List<PrimitiveId> downloaded = task.getDownloadedId();
    6059                if (downloaded != null) {
    61                     GuiHelper.runInEDT(() -> Main.getLayerManager().getEditDataSet().setSelected(downloaded));
     60                    GuiHelper.runInEDT(() -> MainApplication.getLayerManager().getEditDataSet().setSelected(downloaded));
    6261                }
    6362        });
  • trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java

    r12634 r12636  
    99import java.util.Collection;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.actions.downloadtasks.DownloadReferrersTask;
    1312import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    5352        if (!isEnabled())
    5453            return;
    55         OsmDataLayer layer = Main.getLayerManager().getEditLayer();
     54        OsmDataLayer layer = getLayerManager().getEditLayer();
    5655        if (layer == null)
    5756            return;
  • trunk/src/org/openstreetmap/josm/actions/ExitAction.java

    r11093 r12636  
    88import java.awt.event.KeyEvent;
    99
    10 import org.openstreetmap.josm.Main;
     10import org.openstreetmap.josm.gui.MainApplication;
    1111import org.openstreetmap.josm.tools.Shortcut;
    1212
     
    2828    @Override
    2929    public void actionPerformed(ActionEvent e) {
    30         Main.exitJosm(true, 0, null);
     30        MainApplication.exitJosm(true, 0, null);
    3131    }
    3232}
  • trunk/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java

    r12620 r12636  
    1616import javax.swing.filechooser.FileFilter;
    1717
    18 import org.openstreetmap.josm.Main;
     18import org.openstreetmap.josm.gui.MainApplication;
    1919import org.openstreetmap.josm.gui.widgets.AbstractFileChooser;
    2020import org.openstreetmap.josm.io.AllFormatsImporter;
     
    112112                FileExporter exporter = exporterClass.getConstructor().newInstance();
    113113                exporters.add(exporter);
    114                 Main.getLayerManager().addAndFireActiveLayerChangeListener(exporter);
     114                MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(exporter);
    115115            } catch (ReflectiveOperationException e) {
    116116                Logging.debug(e);
  • trunk/src/org/openstreetmap/josm/actions/FollowLineAction.java

    r12630 r12636  
    6262    @Override
    6363    public void actionPerformed(ActionEvent evt) {
    64         OsmDataLayer osmLayer = Main.getLayerManager().getEditLayer();
     64        OsmDataLayer osmLayer = getLayerManager().getEditLayer();
    6565        if (osmLayer == null)
    6666            return;
  • trunk/src/org/openstreetmap/josm/actions/GpxExportAction.java

    r12620 r12636  
    4444     */
    4545    protected Layer getLayer() {
    46         Layer layer = Main.getLayerManager().getActiveLayer();
     46        Layer layer = getLayerManager().getActiveLayer();
    4747        return (layer instanceof GpxLayer || layer instanceof OsmDataLayer) ? layer : null;
    4848    }
  • trunk/src/org/openstreetmap/josm/actions/InfoAction.java

    r10548 r12636  
    99import java.util.Collection;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.data.osm.DataSet;
    1312import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    3736        DataSet set = getLayerManager().getEditDataSet();
    3837        if (set != null) {
    39             new InspectPrimitiveDialog(set.getAllSelected(), Main.getLayerManager().getEditLayer()).showDialog();
     38            new InspectPrimitiveDialog(set.getAllSelected(), getLayerManager().getEditLayer()).showDialog();
    4039        }
    4140    }
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r12620 r12636  
    470470    @Override
    471471    public void actionPerformed(ActionEvent e) {
    472         join(Main.getLayerManager().getEditDataSet().getSelectedWays());
     472        join(getLayerManager().getEditDataSet().getSelectedWays());
    473473    }
    474474
     
    692692        // Delete the discarded inner ways
    693693        if (!discardedWays.isEmpty()) {
    694             Command deleteCmd = DeleteCommand.delete(Main.getLayerManager().getEditLayer(), discardedWays, true);
     694            Command deleteCmd = DeleteCommand.delete(getLayerManager().getEditLayer(), discardedWays, true);
    695695            if (deleteCmd != null) {
    696696                cmds.add(deleteCmd);
     
    14591459    private RelationRole addOwnMultipolygonRelation(Collection<Way> inner) {
    14601460        if (inner.isEmpty()) return null;
    1461         OsmDataLayer layer = Main.getLayerManager().getEditLayer();
     1461        OsmDataLayer layer = getLayerManager().getEditLayer();
    14621462        // Create new multipolygon relation and add all inner ways to it
    14631463        Relation newRel = new Relation();
     
    15371537        }
    15381538
    1539         OsmDataLayer layer = Main.getLayerManager().getEditLayer();
     1539        OsmDataLayer layer = getLayerManager().getEditLayer();
    15401540        Relation newRel;
    15411541        switch (multiouters.size()) {
  • trunk/src/org/openstreetmap/josm/actions/JosmAction.java

    r12634 r12636  
    270270     */
    271271    public MainLayerManager getLayerManager() {
    272         return Main.getLayerManager();
     272        return MainApplication.getLayerManager();
    273273    }
    274274
  • trunk/src/org/openstreetmap/josm/actions/MapRectifierWMSmenuAction.java

    r12620 r12636  
    2525import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
    2626import org.openstreetmap.josm.gui.ExtendedDialog;
     27import org.openstreetmap.josm.gui.MainApplication;
    2728import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
    2829import org.openstreetmap.josm.gui.layer.WMSLayer;
     
    246247            }
    247248        }
    248         Main.getLayerManager().addLayer(new WMSLayer(info));
     249        MainApplication.getLayerManager().addLayer(new WMSLayer(info));
    249250    }
    250251
    251252    @Override
    252253    protected void updateEnabledState() {
    253         setEnabled(!Main.getLayerManager().getLayers().isEmpty());
     254        setEnabled(!getLayerManager().getLayers().isEmpty());
    254255    }
    255256}
  • trunk/src/org/openstreetmap/josm/actions/MergeLayerAction.java

    r12634 r12636  
    1212import java.util.concurrent.Future;
    1313
    14 import org.openstreetmap.josm.Main;
    1514import org.openstreetmap.josm.gui.MainApplication;
    1615import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
     
    6564                        }
    6665                        targetLayer.mergeFrom(sourceLayer);
    67                         GuiHelper.runInEDTAndWait(() -> Main.getLayerManager().removeLayer(sourceLayer));
     66                        GuiHelper.runInEDTAndWait(() -> getLayerManager().removeLayer(sourceLayer));
    6867                        layerMerged = true;
    6968                    }
    7069                }
    7170                if (layerMerged) {
    72                     Main.getLayerManager().setActiveLayer(targetLayer);
     71                    getLayerManager().setActiveLayer(targetLayer);
    7372                    Logging.info(tr("{0} completed in {1}", actionName, Utils.getDurationString(System.currentTimeMillis() - start)));
    7473                }
     
    131130     */
    132131    protected Layer getSourceLayer() {
    133         return Main.getLayerManager().getActiveLayer();
     132        return getLayerManager().getActiveLayer();
    134133    }
    135134
  • trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java

    r12630 r12636  
    9393        if (targetNode != null) {
    9494            Node targetLocationNode = selectTargetLocationNode(selectedNodes);
    95             Command cmd = mergeNodes(Main.getLayerManager().getEditLayer(), selectedNodes, targetNode, targetLocationNode);
     95            Command cmd = mergeNodes(getLayerManager().getEditLayer(), selectedNodes, targetNode, targetLocationNode);
    9696            if (cmd != null) {
    9797                Main.main.undoRedo.add(cmd);
    98                 Main.getLayerManager().getEditLayer().data.setSelected(targetNode);
     98                getLayerManager().getEditLayer().data.setSelected(targetNode);
    9999            }
    100100        }
  • trunk/src/org/openstreetmap/josm/actions/NewAction.java

    r10436 r12636  
    22package org.openstreetmap.josm.actions;
    33
     4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    66
    77import java.awt.event.ActionEvent;
    88import java.awt.event.KeyEvent;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.osm.DataSet;
    1211import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    3029    @Override
    3130    public void actionPerformed(ActionEvent e) {
    32         Main.getLayerManager().addLayer(new OsmDataLayer(new DataSet(), OsmDataLayer.createNewName(), null));
     31        getLayerManager().addLayer(new OsmDataLayer(new DataSet(), OsmDataLayer.createNewName(), null));
    3332    }
    3433}
  • trunk/src/org/openstreetmap/josm/actions/PurgeAction.java

    r12602 r12636  
    139139     */
    140140    public PurgeCommand getPurgeCommand(Collection<OsmPrimitive> sel) {
    141         layer = Main.getLayerManager().getEditLayer();
     141        layer = getLayerManager().getEditLayer();
    142142
    143143        toPurge = new HashSet<>(sel);
  • trunk/src/org/openstreetmap/josm/actions/RestartAction.java

    r12620 r12636  
    8383        String scriptRestart = System.getProperty("josm.restart");
    8484        if ("true".equals(scriptRestart)) {
    85             Main.exitJosm(true, 9, SaveLayersDialog.Reason.RESTART);
    86         }
    87 
    88         if (isRestartSupported() && !Main.exitJosm(false, 0, SaveLayersDialog.Reason.RESTART)) return;
     85            MainApplication.exitJosm(true, 9, SaveLayersDialog.Reason.RESTART);
     86        }
     87
     88        if (isRestartSupported() && !MainApplication.exitJosm(false, 0, SaveLayersDialog.Reason.RESTART)) return;
    8989        final List<String> cmd;
    9090        // special handling for OSX .app package
  • trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java

    r12620 r12636  
    5353     */
    5454    public boolean doSave() {
    55         Layer layer = Main.getLayerManager().getActiveLayer();
     55        Layer layer = getLayerManager().getActiveLayer();
    5656        if (layer != null && layer.isSavable()) {
    5757            return doSave(layer);
     
    133133    @Override
    134134    protected void updateEnabledState() {
    135         Layer activeLayer = Main.getLayerManager().getActiveLayer();
     135        Layer activeLayer = getLayerManager().getActiveLayer();
    136136        setEnabled(activeLayer != null && activeLayer.isSavable());
    137137    }
  • trunk/src/org/openstreetmap/josm/actions/SelectByInternalPointAction.java

    r12630 r12636  
    88import java.util.TreeMap;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.coor.EastNorth;
    1211import org.openstreetmap.josm.data.osm.BBox;
     
    3938     */
    4039    public static Collection<OsmPrimitive> getSurroundingObjects(EastNorth internalPoint) {
    41         return getSurroundingObjects(Main.getLayerManager().getEditDataSet(), internalPoint, false);
     40        return getSurroundingObjects(MainApplication.getLayerManager().getEditDataSet(), internalPoint, false);
    4241    }
    4342
     
    104103    public static void performSelection(EastNorth internalPoint, boolean doAdd, boolean doRemove) {
    105104        final Collection<OsmPrimitive> surroundingObjects = getSurroundingObjects(internalPoint);
    106         final DataSet ds = Main.getLayerManager().getEditDataSet();
     105        final DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    107106        if (surroundingObjects.isEmpty()) {
    108107            return;
  • trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequencesAction.java

    r10446 r12636  
    22package org.openstreetmap.josm.actions;
    33
    4 import org.openstreetmap.josm.Main;
    5 import org.openstreetmap.josm.data.osm.DataSet;
    6 import org.openstreetmap.josm.tools.Shortcut;
     4import static org.openstreetmap.josm.tools.I18n.tr;
    75
    86import java.awt.event.ActionEvent;
    97import java.awt.event.KeyEvent;
    108
    11 import static org.openstreetmap.josm.tools.I18n.tr;
     9import org.openstreetmap.josm.data.osm.DataSet;
     10import org.openstreetmap.josm.tools.Shortcut;
    1211
    1312/**
     
    2019    /**
    2120     * Creates a new {@link SelectNonBranchingWaySequencesAction}
    22      *
    2321     */
    2422    public SelectNonBranchingWaySequencesAction() {
     
    3230    @Override
    3331    public void actionPerformed(ActionEvent ev) {
    34         DataSet ds = Main.getLayerManager().getEditDataSet();
     32        DataSet ds = getLayerManager().getEditDataSet();
    3533        SelectNonBranchingWaySequences ws = new SelectNonBranchingWaySequences(ds.getSelectedWays());
    3634        ws.extend(ds);
     
    3937    /**
    4038     * Update the enabled state of the action when something in
    41      * the JOSM state changes, i.e. when a layer is removed or
    42      * added.
     39     * the JOSM state changes, i.e. when a layer is removed or added.
    4340     */
    4441    @Override
    4542    protected void updateEnabledState() {
    46         setEnabled(Main.getLayerManager().getEditDataSet() != null);
     43        setEnabled(getLayerManager().getEditDataSet() != null);
    4744    }
    4845}
  • trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java

    r12634 r12636  
    138138                    if (canceled)
    139139                        return;
    140                     Main.getLayerManager().addLayer(l);
     140                    MainApplication.getLayerManager().addLayer(l);
    141141                }
    142142                if (active != null) {
    143                     Main.getLayerManager().setActiveLayer(active);
     143                    MainApplication.getLayerManager().setActiveLayer(active);
    144144                }
    145145                if (noMap && viewport != null) {
  • trunk/src/org/openstreetmap/josm/actions/SessionSaveAsAction.java

    r12630 r12636  
    159159
    160160        int active = -1;
    161         Layer activeLayer = Main.getLayerManager().getActiveLayer();
     161        Layer activeLayer = getLayerManager().getActiveLayer();
    162162        if (activeLayer != null) {
    163163            active = layersOut.indexOf(activeLayer);
     
    203203         */
    204204        public final void initialize() {
    205             layers = new ArrayList<>(Main.getLayerManager().getLayers());
     205            layers = new ArrayList<>(getLayerManager().getLayers());
    206206            exporters = new HashMap<>();
    207207            dependencies = new MultiMap<>();
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r12620 r12636  
    177177        }
    178178        if (Main.main != null) {
    179             DataSet dataset = Main.getLayerManager().getEditDataSet();
     179            DataSet dataset = MainApplication.getLayerManager().getEditDataSet();
    180180            if (dataset != null) {
    181181                String result = DatasetConsistencyTest.runTests(dataset);
  • trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java

    r12630 r12636  
    294294            toggleSaveState(); // necessary since #showDialog() does not handle it due to the non-modal dialog
    295295            if (getValue() == 1) {
    296                 SplitWayResult result = doSplitWay(Main.getLayerManager().getEditLayer(),
     296                SplitWayResult result = doSplitWay(MainApplication.getLayerManager().getEditLayer(),
    297297                        selectedWay, list.getSelectedValue(), newWays, selection);
    298298                Main.main.undoRedo.add(result.getCommand());
    299299                if (!result.getNewSelection().isEmpty()) {
    300                     Main.getLayerManager().getEditDataSet().setSelected(result.getNewSelection());
     300                    MainApplication.getLayerManager().getEditDataSet().setSelected(result.getNewSelection());
    301301                }
    302302            }
  • trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java

    r12634 r12636  
    4343    public static void handlePrimitiveGoneException(long id, OsmPrimitiveType type) {
    4444        MultiFetchServerObjectReader reader = MultiFetchServerObjectReader.create();
    45         reader.append(Main.getLayerManager().getEditDataSet(), id, type);
     45        reader.append(MainApplication.getLayerManager().getEditDataSet(), id, type);
    4646        try {
    4747            DataSet ds = reader.parseOsm(NullProgressMonitor.INSTANCE);
    48             Main.getLayerManager().getEditLayer().mergeFrom(ds);
     48            MainApplication.getLayerManager().getEditLayer().mergeFrom(ds);
    4949        } catch (OsmTransferException e) {
    5050            ExceptionDialogUtil.explainException(e);
     
    6060     */
    6161    public static void updatePrimitives(final Collection<OsmPrimitive> selection) {
    62         MainApplication.worker.submit(new UpdatePrimitivesTask(Main.getLayerManager().getEditLayer(), selection));
     62        MainApplication.worker.submit(new UpdatePrimitivesTask(MainApplication.getLayerManager().getEditLayer(), selection));
    6363    }
    6464
     
    7575        ensureParameterNotNull(id, "id");
    7676        updatePrimitives(Collections.<OsmPrimitive>singleton(Optional.ofNullable(Optional.ofNullable(
    77                 Main.getLayerManager().getEditLayer()).orElseThrow(
     77                MainApplication.getLayerManager().getEditLayer()).orElseThrow(
    7878                        () -> new IllegalStateException(tr("No current dataset found")))
    7979                .data.getPrimitiveById(id)).orElseThrow(
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r12634 r12636  
    269269            return;
    270270        }
    271         APIDataSet apiData = new APIDataSet(Main.getLayerManager().getEditDataSet());
    272         uploadData(Main.getLayerManager().getEditLayer(), apiData);
     271        APIDataSet apiData = new APIDataSet(getLayerManager().getEditDataSet());
     272        uploadData(getLayerManager().getEditLayer(), apiData);
    273273    }
    274274}
  • trunk/src/org/openstreetmap/josm/actions/UploadNotesAction.java

    r12620 r12636  
    77import java.util.List;
    88
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.actions.upload.UploadNotesTask;
    1110import org.openstreetmap.josm.data.osm.NoteData;
     
    3231    @Override
    3332    public void actionPerformed(ActionEvent e) {
    34         List<NoteLayer> noteLayers = Main.getLayerManager().getLayersOfType(NoteLayer.class);
     33        List<NoteLayer> noteLayers = getLayerManager().getLayersOfType(NoteLayer.class);
    3534        NoteLayer layer;
    3635        if (!noteLayers.isEmpty()) {
  • trunk/src/org/openstreetmap/josm/actions/ValidateAction.java

    r12634 r12636  
    1212import java.util.Optional;
    1313
    14 import org.openstreetmap.josm.Main;
    1514import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1615import org.openstreetmap.josm.data.validation.OsmValidator;
     
    7776        Collection<OsmPrimitive> selection;
    7877        if (getSelectedItems) {
    79             selection = Main.getLayerManager().getEditDataSet().getAllSelected();
     78            selection = getLayerManager().getEditDataSet().getAllSelected();
    8079            if (selection.isEmpty()) {
    81                 selection = Main.getLayerManager().getEditDataSet().allNonDeletedPrimitives();
     80                selection = getLayerManager().getEditDataSet().allNonDeletedPrimitives();
    8281                lastSelection = null;
    8382            } else {
     
    8887        } else {
    8988            selection = Optional.ofNullable(lastSelection).orElseGet(
    90                     () -> Main.getLayerManager().getEditDataSet().allNonDeletedPrimitives());
     89                    () -> getLayerManager().getEditDataSet().allNonDeletedPrimitives());
    9190        }
    9291
     
    147146                map.validatorDialog.unfurlDialog();
    148147                //FIXME: nicer way to find / invalidate the corresponding error layer
    149                 Main.getLayerManager().getLayersOfType(ValidatorLayer.class).forEach(ValidatorLayer::invalidate);
     148                MainApplication.getLayerManager().getLayersOfType(ValidatorLayer.class).forEach(ValidatorLayer::invalidate);
    150149            });
    151150        }
  • trunk/src/org/openstreetmap/josm/actions/ViewportFollowToggleAction.java

    r12182 r12636  
    88import java.awt.event.KeyEvent;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.actions.mapmode.DrawAction;
    1211import org.openstreetmap.josm.tools.Shortcut;
     
    4342    @Override
    4443    protected void updateEnabledState() {
    45         setEnabled(Main.getLayerManager().getEditDataSet() != null);
     44        setEnabled(getLayerManager().getEditDataSet() != null);
    4645    }
    4746}
  • trunk/src/org/openstreetmap/josm/actions/WireframeToggleAction.java

    r12354 r12636  
    3838    @Override
    3939    protected void updateEnabledState() {
    40         setEnabled(Main.getLayerManager().getEditLayer() != null);
     40        setEnabled(getLayerManager().getEditLayer() != null);
    4141    }
    4242
     
    5151
    5252        notifySelectedState();
    53         Main.getLayerManager().getLayersOfType(OsmDataLayer.class).forEach(OsmDataLayer::invalidate);
     53        getLayerManager().getLayersOfType(OsmDataLayer.class).forEach(OsmDataLayer::invalidate);
    5454    }
    5555}
  • trunk/src/org/openstreetmap/josm/actions/ZoomInAction.java

    r12630 r12636  
    5353    @Override
    5454    protected void updateEnabledState() {
    55         setEnabled(!Main.getLayerManager().getLayers().isEmpty());
     55        setEnabled(!getLayerManager().getLayers().isEmpty());
    5656    }
    5757
  • trunk/src/org/openstreetmap/josm/actions/ZoomOutAction.java

    r12630 r12636  
    3939    @Override
    4040    protected void updateEnabledState() {
    41         setEnabled(!Main.getLayerManager().getLayers().isEmpty());
     41        setEnabled(!getLayerManager().getLayers().isEmpty());
    4242    }
    4343}
  • trunk/src/org/openstreetmap/josm/actions/ZoomToAction.java

    r12581 r12636  
    1212import org.openstreetmap.josm.Main;
    1313import org.openstreetmap.josm.data.osm.OsmPrimitive;
     14import org.openstreetmap.josm.gui.MainApplication;
    1415import org.openstreetmap.josm.gui.conflict.pair.nodes.NodeListTable;
    1516import org.openstreetmap.josm.gui.conflict.pair.relation.RelationMemberTable;
     
    104105
    105106    protected final void updateEnabledState() {
    106         if (Main.main == null || Main.getLayerManager().getEditLayer() != this.table.getLayer()) {
     107        if (Main.main == null || MainApplication.getLayerManager().getEditLayer() != this.table.getLayer()) {
    107108            setEnabled(false);
    108109            putValue(SHORT_DESCRIPTION, descriptionInactiveLayer);
  • trunk/src/org/openstreetmap/josm/actions/audio/AbstractAudioAction.java

    r12565 r12636  
    22package org.openstreetmap.josm.actions.audio;
    33
    4 import org.openstreetmap.josm.Main;
    54import org.openstreetmap.josm.actions.JosmAction;
     5import org.openstreetmap.josm.gui.MainApplication;
    66import org.openstreetmap.josm.gui.layer.markerlayer.AudioMarker;
    77import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
     
    3333     */
    3434    protected static boolean isAudioMarkerPresent() {
    35         return Main.getLayerManager().getLayersOfType(MarkerLayer.class).stream()
     35        return MainApplication.getLayerManager().getLayersOfType(MarkerLayer.class).stream()
    3636                .flatMap(ml -> ml.data.stream())
    3737                .anyMatch(m -> m instanceof AudioMarker);
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java

    r12634 r12636  
    167167            if (layer == null) return null;
    168168            if (newLayer || mergeLayer == null) {
    169                 Main.getLayerManager().addLayer(layer, zoomAfterDownload);
     169                MainApplication.getLayerManager().addLayer(layer, zoomAfterDownload);
    170170                return layer;
    171171            } else {
     
    182182        private GpxLayer findGpxMergeLayer() {
    183183            boolean merge = Main.pref.getBoolean("download.gps.mergeWithLocal", false);
    184             Layer active = Main.getLayerManager().getActiveLayer();
     184            Layer active = MainApplication.getLayerManager().getActiveLayer();
    185185            if (active instanceof GpxLayer && (merge || ((GpxLayer) active).data.fromServer))
    186186                return (GpxLayer) active;
    187             for (GpxLayer l : Main.getLayerManager().getLayersOfType(GpxLayer.class)) {
     187            for (GpxLayer l : MainApplication.getLayerManager().getLayersOfType(GpxLayer.class)) {
    188188                if (merge || l.data.fromServer)
    189189                    return l;
     
    193193
    194194        private MarkerLayer findMarkerMergeLayer(GpxLayer fromLayer) {
    195             for (MarkerLayer l : Main.getLayerManager().getLayersOfType(MarkerLayer.class)) {
     195            for (MarkerLayer l : MainApplication.getLayerManager().getLayersOfType(MarkerLayer.class)) {
    196196                if (fromLayer != null && l.fromLayer == fromLayer)
    197197                    return l;
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTask.java

    r12634 r12636  
    131131
    132132            noteLayer = new NoteLayer(notesData, tr("Notes"));
    133             List<NoteLayer> noteLayers = Main.getLayerManager().getLayersOfType(NoteLayer.class);
     133            List<NoteLayer> noteLayers = MainApplication.getLayerManager().getLayersOfType(NoteLayer.class);
    134134            if (!noteLayers.isEmpty()) {
    135135                noteLayers.get(0).getNoteData().addNotes(notesData);
     
    139139                }
    140140            } else {
    141                 Main.getLayerManager().addLayer(noteLayer, zoomAfterDownload);
     141                MainApplication.getLayerManager().addLayer(noteLayer, zoomAfterDownload);
    142142            }
    143143        }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r12634 r12636  
    1616import java.util.regex.Pattern;
    1717
    18 import org.openstreetmap.josm.Main;
    1918import org.openstreetmap.josm.data.Bounds;
    2019import org.openstreetmap.josm.data.DataSource;
     
    231230        protected OsmDataLayer getEditLayer() {
    232231            if (!MainApplication.isDisplayingMapView()) return null;
    233             return Main.getLayerManager().getEditLayer();
     232            return MainApplication.getLayerManager().getEditLayer();
    234233        }
    235234
    236235        protected int getNumDataLayers() {
    237             return Main.getLayerManager().getLayersOfType(OsmDataLayer.class).size();
     236            return MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class).size();
    238237        }
    239238
    240239        protected OsmDataLayer getFirstDataLayer() {
    241             return Utils.find(Main.getLayerManager().getLayers(), OsmDataLayer.class);
     240            return Utils.find(MainApplication.getLayerManager().getLayers(), OsmDataLayer.class);
    242241        }
    243242
     
    270269                //
    271270                final OsmDataLayer layer = createNewLayer(newLayerName);
    272                 Main.getLayerManager().addLayer(layer, zoomAfterDownload);
     271                MainApplication.getLayerManager().addLayer(layer, zoomAfterDownload);
    273272                return layer;
    274273            }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java

    r12634 r12636  
    7373        if (newLayer) {
    7474            Layer l = new OsmDataLayer(new DataSet(), OsmDataLayer.createNewName(), null);
    75             Main.getLayerManager().addLayer(l);
    76             Main.getLayerManager().setActiveLayer(l);
     75            MainApplication.getLayerManager().addLayer(l);
     76            MainApplication.getLayerManager().setActiveLayer(l);
    7777        }
    7878
     
    288288                }
    289289            }
    290             final OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     290            final OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    291291            if (editLayer != null && osmData) {
    292292                final Set<OsmPrimitive> myPrimitives = getCompletePrimitives(editLayer.data);
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java

    r12630 r12636  
    141141     */
    142142    public void doActionPerformed(ActionEvent e) {
    143         MainLayerManager lm = Main.getLayerManager();
     143        MainLayerManager lm = MainApplication.getLayerManager();
    144144        OsmDataLayer editLayer = lm.getEditLayer();
    145145        if (editLayer == null) {
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r12630 r12636  
    951951    @Override
    952952    public void mouseExited(MouseEvent e) {
    953         OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     953        OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    954954        if (editLayer == null)
    955955            return;
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java

    r12630 r12636  
    722722        Node targetNode = MergeNodesAction.selectTargetNode(changedNodes);
    723723        Node locNode = MergeNodesAction.selectTargetLocationNode(changedNodes);
    724         Command mergeCmd = MergeNodesAction.mergeNodes(Main.getLayerManager().getEditLayer(), changedNodes, targetNode, locNode);
     724        Command mergeCmd = MergeNodesAction.mergeNodes(MainApplication.getLayerManager().getEditLayer(), changedNodes, targetNode, locNode);
    725725        if (mergeCmd != null) {
    726726            Main.main.undoRedo.add(mergeCmd);
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r12634 r12636  
    920920        Collection<Node> nodesToMerge = new LinkedList<>(selNodes);
    921921        nodesToMerge.add(target);
    922         mergeNodes(Main.getLayerManager().getEditLayer(), nodesToMerge, target);
     922        mergeNodes(MainApplication.getLayerManager().getEditLayer(), nodesToMerge, target);
    923923    }
    924924
  • trunk/src/org/openstreetmap/josm/actions/relation/AddSelectionToRelations.java

    r10601 r12636  
    1717import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1818import org.openstreetmap.josm.data.osm.Relation;
     19import org.openstreetmap.josm.gui.MainApplication;
    1920import org.openstreetmap.josm.gui.Notification;
    2021import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor;
     
    3940        Collection<Command> cmds = new LinkedList<>();
    4041        for (Relation orig : relations) {
    41             Command c = GenericRelationEditor.addPrimitivesToRelation(orig, Main.getLayerManager().getEditDataSet().getSelected());
     42            Command c = GenericRelationEditor.addPrimitivesToRelation(orig, MainApplication.getLayerManager().getEditDataSet().getSelected());
    4243            if (c != null) {
    4344                cmds.add(c);
  • trunk/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java

    r12630 r12636  
    77import java.util.Collection;
    88
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.actions.mapmode.DeleteAction;
    1110import org.openstreetmap.josm.data.osm.Relation;
     
    3130
    3231    protected void deleteRelation(Collection<Relation> toDelete) {
    33         OsmDataLayer layer = Main.getLayerManager().getEditLayer();
     32        OsmDataLayer layer = MainApplication.getLayerManager().getEditLayer();
    3433        if (toDelete == null || layer == null)
    3534            return;
  • trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java

    r12634 r12636  
    3535    public void actionPerformed(ActionEvent e) {
    3636        if (!isEnabled() || relations.isEmpty() || !MainApplication.isDisplayingMapView()) return;
    37         MainApplication.worker.submit(new DownloadRelationTask(relations, Main.getLayerManager().getEditLayer()));
     37        MainApplication.worker.submit(new DownloadRelationTask(relations, MainApplication.getLayerManager().getEditLayer()));
    3838    }
    3939
  • trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java

    r12634 r12636  
    5454                relations,
    5555                incompleteMembers,
    56                 Main.getLayerManager().getEditLayer()));
     56                MainApplication.getLayerManager().getEditLayer()));
    5757    }
    5858
  • trunk/src/org/openstreetmap/josm/actions/relation/DuplicateRelationAction.java

    r10428 r12636  
    66import java.awt.event.ActionEvent;
    77
    8 import org.openstreetmap.josm.Main;
    98import org.openstreetmap.josm.data.osm.Relation;
     9import org.openstreetmap.josm.gui.MainApplication;
    1010import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
    1111import org.openstreetmap.josm.tools.ImageProvider;
     
    3434        copy.setModified(true);
    3535        RelationEditor editor = RelationEditor.getEditor(
    36                 Main.getLayerManager().getEditLayer(),
     36                MainApplication.getLayerManager().getEditLayer(),
    3737                copy,
    3838                null /* no selected members */
  • trunk/src/org/openstreetmap/josm/actions/relation/EditRelationAction.java

    r12630 r12636  
    4444        Set<RelationMember> members = new HashSet<>();
    4545        if (MainApplication.isDisplayingMapView()) {
    46             OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     46            OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    4747            if (editLayer != null && editLayer.data != null) {
    4848                Collection<OsmPrimitive> selection = editLayer.data.getSelected();
     
    6363    public static void launchEditor(Relation toEdit) {
    6464        if (toEdit == null || toEdit.isDeleted() || !MainApplication.isDisplayingMapView()) return;
    65         RelationEditor.getEditor(Main.getLayerManager().getEditLayer(), toEdit,
     65        RelationEditor.getEditor(MainApplication.getLayerManager().getEditLayer(), toEdit,
    6666                getMembersForCurrentSelection(toEdit)).setVisible(true);
    6767    }
  • trunk/src/org/openstreetmap/josm/actions/relation/RecentRelationsAction.java

    r12630 r12636  
    9595        return relation != null &&
    9696            !relation.isDeleted() &&
    97             Main.getLayerManager().getEditDataSet().containsRelation(relation);
     97            MainApplication.getLayerManager().getEditDataSet().containsRelation(relation);
    9898    }
    9999
     
    126126        if (!MainApplication.isDisplayingMapView())
    127127            return Collections.emptyList();
    128         Layer activeLayer = Main.getLayerManager().getActiveLayer();
     128        Layer activeLayer = MainApplication.getLayerManager().getActiveLayer();
    129129        if (!(activeLayer instanceof OsmDataLayer)) {
    130130            return Collections.emptyList();
  • trunk/src/org/openstreetmap/josm/actions/relation/SelectMembersAction.java

    r12630 r12636  
    88import java.util.Set;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1211import org.openstreetmap.josm.data.osm.Relation;
     
    4443        }
    4544        if (add) {
    46             Main.getLayerManager().getEditLayer().data.addSelected(members);
     45            MainApplication.getLayerManager().getEditLayer().data.addSelected(members);
    4746        } else {
    48             Main.getLayerManager().getEditLayer().data.setSelected(members);
     47            MainApplication.getLayerManager().getEditLayer().data.setSelected(members);
    4948        }
    5049    }
  • trunk/src/org/openstreetmap/josm/actions/relation/SelectRelationAction.java

    r10428 r12636  
    66import java.awt.event.ActionEvent;
    77
    8 import org.openstreetmap.josm.Main;
     8import org.openstreetmap.josm.gui.MainApplication;
    99import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1010import org.openstreetmap.josm.tools.ImageProvider;
     
    3434    public void actionPerformed(ActionEvent e) {
    3535        if (!isEnabled() || relations.isEmpty()) return;
    36         OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     36        OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    3737        if (editLayer == null || editLayer.data == null) return;
    3838        if (add) {
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r12630 r12636  
    764764
    765765        static SearchTask newSearchTask(SearchSetting setting, SearchReceiver resultReceiver) {
    766             final DataSet ds = Main.getLayerManager().getEditDataSet();
     766            final DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    767767            return newSearchTask(setting, ds, resultReceiver);
    768768        }
  • trunk/src/org/openstreetmap/josm/actions/upload/ApiPreconditionCheckerHook.java

    r12620 r12636  
    1414import org.openstreetmap.josm.data.osm.Way;
    1515import org.openstreetmap.josm.gui.ExceptionDialogUtil;
     16import org.openstreetmap.josm.gui.MainApplication;
    1617import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1718import org.openstreetmap.josm.io.OnlineResource;
     
    7980                            JOptionPane.ERROR_MESSAGE
    8081                    );
    81                     Main.getLayerManager().getEditDataSet().setSelected(Collections.singleton(osmPrimitive));
     82                    MainApplication.getLayerManager().getEditDataSet().setSelected(Collections.singleton(osmPrimitive));
    8283                    return false;
    8384                }
     
    9697                        JOptionPane.ERROR_MESSAGE
    9798                );
    98                 Main.getLayerManager().getEditDataSet().setSelected(Collections.singleton(osmPrimitive));
     99                MainApplication.getLayerManager().getEditDataSet().setSelected(Collections.singleton(osmPrimitive));
    99100                return false;
    100101            }
  • trunk/src/org/openstreetmap/josm/actions/upload/ValidateUploadHook.java

    r12630 r12636  
    7474            }
    7575        }
    76         OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     76        OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    7777        if (editLayer != null) {
    7878            editLayer.validationErrors.clear();
     
    152152            OsmValidator.initializeErrorLayer();
    153153            MainApplication.getMap().validatorDialog.unfurlDialog();
    154             Main.getLayerManager().getLayersOfType(ValidatorLayer.class).forEach(ValidatorLayer::invalidate);
     154            MainApplication.getLayerManager().getLayersOfType(ValidatorLayer.class).forEach(ValidatorLayer::invalidate);
    155155            return false;
    156156        }
  • trunk/src/org/openstreetmap/josm/command/Command.java

    r12348 r12636  
    2525import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
    2626import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
     27import org.openstreetmap.josm.gui.MainApplication;
    2728import org.openstreetmap.josm.gui.layer.Layer;
    2829import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    144145     */
    145146    public Command() {
    146         this.layer = Main.getLayerManager().getEditLayer();
     147        this.layer = MainApplication.getLayerManager().getEditLayer();
    147148        this.data = layer != null ? layer.data : null;
    148149    }
  • trunk/src/org/openstreetmap/josm/command/conflict/ConflictAddCommand.java

    r12630 r12636  
    6565    @Override
    6666    public void undoCommand() {
    67         if (MainApplication.isDisplayingMapView() && !Main.getLayerManager().containsLayer(getLayer())) {
     67        if (MainApplication.isDisplayingMapView() && !MainApplication.getLayerManager().containsLayer(getLayer())) {
    6868            Logging.warn(tr("Layer ''{0}'' does not exist any more. Cannot remove conflict for object ''{1}''.",
    6969                    getLayer().getName(),
  • trunk/src/org/openstreetmap/josm/command/conflict/ConflictResolveCommand.java

    r12630 r12636  
    66import java.util.Objects;
    77
    8 import org.openstreetmap.josm.Main;
    98import org.openstreetmap.josm.command.Command;
    109import org.openstreetmap.josm.data.conflict.Conflict;
     
    7372
    7473        if (MainApplication.isDisplayingMapView()) {
    75             if (!Main.getLayerManager().containsLayer(getLayer())) {
     74            if (!MainApplication.getLayerManager().containsLayer(getLayer())) {
    7675                Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more",
    7776                        this.toString(),
     
    8180            }
    8281
    83             Main.getLayerManager().setActiveLayer(getLayer());
     82            MainApplication.getLayerManager().setActiveLayer(getLayer());
    8483        }
    8584        reconstituteConflicts();
  • trunk/src/org/openstreetmap/josm/command/conflict/RelationMemberConflictResolverCommand.java

    r12620 r12636  
    1010import javax.swing.Icon;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.conflict.Conflict;
    1413import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1514import org.openstreetmap.josm.data.osm.Relation;
    1615import org.openstreetmap.josm.data.osm.RelationMember;
     16import org.openstreetmap.josm.gui.MainApplication;
    1717import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1818import org.openstreetmap.josm.tools.ImageProvider;
     
    7272    public void undoCommand() {
    7373        OsmDataLayer layer = getLayer();
    74         if (!Main.getLayerManager().containsLayer(layer)) {
     74        if (!MainApplication.getLayerManager().containsLayer(layer)) {
    7575            Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more",
    7676                    this.toString(),
     
    8080        }
    8181
    82         Main.getLayerManager().setActiveLayer(layer);
    83         OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     82        MainApplication.getLayerManager().setActiveLayer(layer);
     83        OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    8484
    8585        // restore the former state
  • trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java

    r12316 r12636  
    1111import org.openstreetmap.josm.data.osm.DataSet;
    1212import org.openstreetmap.josm.data.osm.OsmPrimitive;
     13import org.openstreetmap.josm.gui.MainApplication;
    1314import org.openstreetmap.josm.gui.layer.Layer;
    1415import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     
    4445     */
    4546    public UndoRedoHandler() {
    46         Main.getLayerManager().addLayerChangeListener(this);
     47        MainApplication.getLayerManager().addLayerChangeListener(this);
    4748    }
    4849
     
    8586     */
    8687    public synchronized void add(final Command c) {
    87         DataSet ds = Optional.ofNullable(c.getAffectedDataSet()).orElseGet(() -> Main.getLayerManager().getEditDataSet());
     88        DataSet ds = Optional.ofNullable(c.getAffectedDataSet()).orElseGet(() -> MainApplication.getLayerManager().getEditDataSet());
    8889        Collection<? extends OsmPrimitive> oldSelection = null;
    8990        if (ds != null) {
     
    114115        if (commands.isEmpty())
    115116            return;
    116         DataSet ds = Main.getLayerManager().getEditDataSet();
     117        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    117118        Collection<? extends OsmPrimitive> oldSelection = null;
    118119        if (ds != null) {
     
    155156        if (redoCommands.isEmpty())
    156157            return;
    157         DataSet ds = Main.getLayerManager().getEditDataSet();
     158        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    158159        Collection<? extends OsmPrimitive> oldSelection = ds.getSelected();
    159160        for (int i = 0; i < num; ++i) {
  • trunk/src/org/openstreetmap/josm/data/osm/FilterModel.java

    r12630 r12636  
    9696     */
    9797    public void executeFilters() {
    98         DataSet ds = Main.getLayerManager().getEditDataSet();
     98        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    9999        changed = false;
    100100        if (ds == null) {
     
    145145     */
    146146    public void executeFilters(Collection<? extends OsmPrimitive> primitives) {
    147         DataSet ds = Main.getLayerManager().getEditDataSet();
     147        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    148148        if (ds == null)
    149149            return;
     
    197197
    198198    private static void updateMap() {
    199         OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     199        OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    200200        if (editLayer != null) {
    201201            editLayer.invalidate();
     
    207207     */
    208208    public void clearFilterFlags() {
    209         DataSet ds = Main.getLayerManager().getEditDataSet();
     209        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    210210        if (ds != null) {
    211211            FilterWorker.clearFilterFlags(ds.allPrimitives());
  • trunk/src/org/openstreetmap/josm/data/osm/event/DatasetEventManager.java

    r12537 r12636  
    1212import javax.swing.SwingUtilities;
    1313
    14 import org.openstreetmap.josm.Main;
    1514import org.openstreetmap.josm.data.osm.DataSet;
    1615import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter.Listener;
     16import org.openstreetmap.josm.gui.MainApplication;
    1717import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
    1818import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
     
    152152     */
    153153    public DatasetEventManager() {
    154         Main.getLayerManager().addActiveLayerChangeListener(this);
     154        MainApplication.getLayerManager().addActiveLayerChangeListener(this);
    155155    }
    156156
  • trunk/src/org/openstreetmap/josm/data/osm/event/SelectionEventManager.java

    r12537 r12636  
    1111import javax.swing.SwingUtilities;
    1212
    13 import org.openstreetmap.josm.Main;
    1413import org.openstreetmap.josm.data.SelectionChangedListener;
    1514import org.openstreetmap.josm.data.osm.DataSelectionListener;
    1615import org.openstreetmap.josm.data.osm.DataSet;
    1716import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
     17import org.openstreetmap.josm.gui.MainApplication;
    1818import org.openstreetmap.josm.gui.layer.MainLayerManager;
    1919import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     
    105105     */
    106106    protected SelectionEventManager() {
    107         MainLayerManager layerManager = Main.getLayerManager();
     107        MainLayerManager layerManager = MainApplication.getLayerManager();
    108108        // We do not allow for destructing this object.
    109109        // Currently, this is a singleton class, so this is not required.
     
    212212        inEDTListeners.clear();
    213213        immedatelyListeners.clear();
    214         Main.getLayerManager().addAndFireActiveLayerChangeListener(this);
     214        MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(this);
    215215    }
    216216}
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryDataSet.java

    r12630 r12636  
    1212import java.util.concurrent.CopyOnWriteArrayList;
    1313
    14 import org.openstreetmap.josm.Main;
    1514import org.openstreetmap.josm.data.osm.Changeset;
    1615import org.openstreetmap.josm.data.osm.IPrimitive;
     
    4241        if (historyDataSet == null) {
    4342            historyDataSet = new HistoryDataSet();
    44             Main.getLayerManager().addLayerChangeListener(historyDataSet);
     43            MainApplication.getLayerManager().addLayerChangeListener(historyDataSet);
    4544        }
    4645        return historyDataSet;
     
    228227    public void layerRemoving(LayerRemoveEvent e) {
    229228        if (!MainApplication.isDisplayingMapView()) return;
    230         if (Main.getLayerManager().getLayers().isEmpty()) {
     229        if (MainApplication.getLayerManager().getLayers().isEmpty()) {
    231230            data.clear();
    232231            fireCacheCleared();
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/MultipolygonCache.java

    r11779 r12636  
    2828import org.openstreetmap.josm.data.projection.Projection;
    2929import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
     30import org.openstreetmap.josm.gui.MainApplication;
    3031import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
    3132import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     
    5152        Main.addProjectionChangeListener(this);
    5253        DataSet.addSelectionListener(this);
    53         Main.getLayerManager().addLayerChangeListener(this);
     54        MainApplication.getLayerManager().addLayerChangeListener(this);
    5455    }
    5556
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r12620 r12636  
    5858import org.openstreetmap.josm.data.validation.tests.WayConnectedToArea;
    5959import org.openstreetmap.josm.data.validation.tests.WronglyOrderedWays;
     60import org.openstreetmap.josm.gui.MainApplication;
    6061import org.openstreetmap.josm.gui.layer.ValidatorLayer;
    6162import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
     
    238239        if (errorLayer == null) {
    239240            errorLayer = new ValidatorLayer();
    240             Main.getLayerManager().addLayer(errorLayer);
     241            MainApplication.getLayerManager().addLayer(errorLayer);
    241242        }
    242243    }
  • trunk/src/org/openstreetmap/josm/data/validation/Test.java

    r12620 r12636  
    1515import javax.swing.JPanel;
    1616
    17 import org.openstreetmap.josm.Main;
    1817import org.openstreetmap.josm.actions.search.SearchCompiler.NotOutsideDataSourceArea;
    1918import org.openstreetmap.josm.command.Command;
     
    2423import org.openstreetmap.josm.data.osm.Way;
    2524import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
     25import org.openstreetmap.josm.gui.MainApplication;
    2626import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2727import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    331331        }
    332332        if (!primitivesToDelete.isEmpty()) {
    333             return DeleteCommand.delete(Main.getLayerManager().getEditLayer(), primitivesToDelete);
     333            return DeleteCommand.delete(MainApplication.getLayerManager().getEditLayer(), primitivesToDelete);
    334334        } else {
    335335            return null;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java

    r11913 r12636  
    3434import org.openstreetmap.josm.data.validation.Test;
    3535import org.openstreetmap.josm.data.validation.TestError;
     36import org.openstreetmap.josm.gui.MainApplication;
    3637import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    3738import org.openstreetmap.josm.tools.MultiMap;
     
    333334
    334335            if (Command.checkOutlyingOrIncompleteOperation(nodes, Collections.singleton(target)) == Command.IS_OK)
    335                 return MergeNodesAction.mergeNodes(Main.getLayerManager().getEditLayer(), nodes, target);
     336                return MergeNodesAction.mergeNodes(MainApplication.getLayerManager().getEditLayer(), nodes, target);
    336337        }
    337338
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r12620 r12636  
    3131import org.openstreetmap.josm.data.validation.Test;
    3232import org.openstreetmap.josm.data.validation.TestError;
     33import org.openstreetmap.josm.gui.MainApplication;
    3334import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference;
    3435import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    168169        mindist = Main.pref.getDouble(PREFIX + ".node_way_distance", 10.0);
    169170        minmiddledist = Main.pref.getDouble(PREFIX + ".way_way_distance", 0.0);
    170         DataSet dataSet = Main.getLayerManager().getEditDataSet();
     171        DataSet dataSet = MainApplication.getLayerManager().getEditDataSet();
    171172        dsArea = dataSet == null ? null : dataSet.getDataSourceArea();
    172173    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java

    r11913 r12636  
    99import java.util.Set;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.command.Command;
    1312import org.openstreetmap.josm.data.osm.DataSet;
     
    1918import org.openstreetmap.josm.data.validation.Test;
    2019import org.openstreetmap.josm.data.validation.TestError;
     20import org.openstreetmap.josm.gui.MainApplication;
    2121import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    2222
     
    142142    public void startTest(ProgressMonitor monitor) {
    143143        super.startTest(monitor);
    144         DataSet ds = Main.getLayerManager().getEditDataSet();
     144        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    145145        if (ds == null)
    146146            return;
  • trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java

    r12630 r12636  
    5858        @Override
    5959        public void actionPerformed(ActionEvent e) {
    60             Collection<ImageryLayer> layers = Main.getLayerManager().getLayersOfType(ImageryLayer.class);
     60            Collection<ImageryLayer> layers = MainApplication.getLayerManager().getLayersOfType(ImageryLayer.class);
    6161            if (layers.isEmpty()) {
    6262                setEnabled(false);
     
    112112        super(trc("menu", "Imagery"));
    113113        setupMenuScroller();
    114         Main.getLayerManager().addLayerChangeListener(this);
     114        MainApplication.getLayerManager().addLayerChangeListener(this);
    115115        // build dynamically
    116116        addMenuListener(new MenuListener() {
     
    211211
    212212    private JMenuItem getNewOffsetMenu() {
    213         Collection<ImageryLayer> layers = Main.getLayerManager().getLayersOfType(ImageryLayer.class);
     213        Collection<ImageryLayer> layers = MainApplication.getLayerManager().getLayersOfType(ImageryLayer.class);
    214214        if (layers.isEmpty()) {
    215215            offsetAction.setEnabled(false);
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r12634 r12636  
    6363import org.openstreetmap.josm.data.Bounds;
    6464import org.openstreetmap.josm.data.Version;
     65import org.openstreetmap.josm.data.osm.DataSet;
    6566import org.openstreetmap.josm.data.osm.OsmPrimitive;
    6667import org.openstreetmap.josm.data.validation.OsmValidator;
     
    6970import org.openstreetmap.josm.gui.download.DownloadDialog;
    7071import org.openstreetmap.josm.gui.io.CustomConfigurator.XMLCommandProcessor;
     72import org.openstreetmap.josm.gui.io.SaveLayersDialog;
    7173import org.openstreetmap.josm.gui.layer.AutosaveTask;
     74import org.openstreetmap.josm.gui.layer.MainLayerManager;
    7275import org.openstreetmap.josm.gui.layer.TMSLayer;
    7376import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference;
     
    7881import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    7982import org.openstreetmap.josm.gui.util.GuiHelper;
     83import org.openstreetmap.josm.gui.util.RedirectInputMap;
    8084import org.openstreetmap.josm.io.CertificateAmendment;
    8185import org.openstreetmap.josm.io.DefaultProxySelector;
     
    134138
    135139    /**
     140     * Provides access to the layers displayed in the main view.
     141     */
     142    private static final MainLayerManager layerManager = new MainLayerManager();
     143
     144    /**
    136145     * Constructs a new {@code MainApplication} without a window.
    137146     */
     
    228237        } else {
    229238            // required for running some tests.
    230             panel = new MainPanel(Main.getLayerManager());
     239            panel = new MainPanel(MainApplication.getLayerManager());
    231240            menu = new MainMenu();
    232241        }
     
    246255            map.rememberToggleDialogWidth();
    247256        }
     257        // Remove all layers because somebody may rely on layerRemoved events (like AutosaveTask)
     258        getLayerManager().resetState();
    248259        super.shutdown();
    249260        if (!GraphicsEnvironment.isHeadless()) {
     
    264275    }
    265276
     277    /**
     278     * Replies the current selected primitives, from a end-user point of view.
     279     * It is not always technically the same collection of primitives than {@link DataSet#getSelected()}.
     280     * Indeed, if the user is currently in drawing mode, only the way currently being drawn is returned,
     281     * see {@link DrawAction#getInProgressSelection()}.
     282     *
     283     * @return The current selected primitives, from a end-user point of view. Can be {@code null}.
     284     * @since 6546
     285     */
    266286    @Override
    267287    public Collection<OsmPrimitive> getInProgressSelection() {
     
    269289            return ((DrawAction) map.mapMode).getInProgressSelection();
    270290        } else {
    271             return super.getInProgressSelection();
     291            DataSet ds = getLayerManager().getEditDataSet();
     292            if (ds == null) return null;
     293            return ds.getSelected();
    272294        }
    273295    }
     
    280302    public static List<String> getCommandLineArgs() {
    281303        return Collections.unmodifiableList(COMMAND_LINE_ARGS);
     304    }
     305
     306    /**
     307     * Returns the main layer manager that is used by the map view.
     308     * @return The layer manager. The value returned will never change.
     309     * @since 12636 (as a replacement to {@code MainApplication.getLayerManager()})
     310     */
     311    @SuppressWarnings("deprecation")
     312    public static MainLayerManager getLayerManager() {
     313        return layerManager;
    282314    }
    283315
     
    306338    public static boolean isDisplayingMapView() {
    307339        return map != null && map.mapView != null;
     340    }
     341
     342    /**
     343     * Closes JOSM and optionally terminates the Java Virtual Machine (JVM).
     344     * If there are some unsaved data layers, asks first for user confirmation.
     345     * @param exit If {@code true}, the JVM is terminated by running {@link System#exit} with a given return code.
     346     * @param exitCode The return code
     347     * @param reason the reason for exiting
     348     * @return {@code true} if JOSM has been closed, {@code false} if the user has cancelled the operation.
     349     * @since 12636 (specialized version of {@link Main#exitJosm})
     350     */
     351    public static boolean exitJosm(boolean exit, int exitCode, SaveLayersDialog.Reason reason) {
     352        final boolean proceed = Boolean.TRUE.equals(GuiHelper.runInEDTAndWaitAndReturn(() ->
     353                SaveLayersDialog.saveUnsavedModifications(MainApplication.getLayerManager().getLayers(),
     354                        reason != null ? reason : SaveLayersDialog.Reason.EXIT)));
     355        if (proceed) {
     356            return Main.exitJosm(exit, exitCode);
     357        }
     358        return false;
     359    }
     360
     361    public static void redirectToMainContentPane(JComponent source) {
     362        RedirectInputMap.redirect(source, contentPanePrivate);
    308363    }
    309364
  • trunk/src/org/openstreetmap/josm/gui/MainFrame.java

    r12620 r12636  
    6767        super();
    6868        this.geometry = geometry;
    69         this.panel = new MainPanel(Main.getLayerManager());
     69        this.panel = new MainPanel(MainApplication.getLayerManager());
    7070        setContentPane(new JPanel(new BorderLayout()));
    7171    }
     
    9494
    9595        // This listener is never removed, since the main frame exists forever.
    96         Main.getLayerManager().addActiveLayerChangeListener(e -> refreshTitle());
    97         Main.getLayerManager().addAndFireLayerChangeListener(new ManageLayerListeners());
     96        MainApplication.getLayerManager().addActiveLayerChangeListener(e -> refreshTitle());
     97        MainApplication.getLayerManager().addAndFireLayerChangeListener(new ManageLayerListeners());
    9898
    9999        refreshTitle();
     
    156156     */
    157157    public void refreshTitle() {
    158         OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     158        OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    159159        boolean dirty = editLayer != null && (editLayer.requiresSaveToFile()
    160160                || (editLayer.requiresUploadToServer() && !editLayer.isUploadDiscouraged()));
     
    164164
    165165    private void onLayerChange(OsmDataLayer layer) {
    166         if (layer == Main.getLayerManager().getEditLayer()) {
     166        if (layer == MainApplication.getLayerManager().getEditLayer()) {
    167167            refreshTitle();
    168168        }
     
    172172        @Override
    173173        public void windowClosing(final WindowEvent evt) {
    174             Main.exitJosm(true, 0, null);
     174            MainApplication.exitJosm(true, 0, null);
    175175        }
    176176    }
  • trunk/src/org/openstreetmap/josm/gui/MainMenu.java

    r12361 r12636  
    893893        PresetsMenuEnabler(JMenu presetsMenu) {
    894894            this.presetsMenu = presetsMenu;
    895             Main.getLayerManager().addAndFireActiveLayerChangeListener(this);
     895            MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(this);
    896896        }
    897897
  • trunk/src/org/openstreetmap/josm/gui/MainPanel.java

    r12630 r12636  
    9595
    9696        //TODO: Move this to some better place
    97         List<Layer> layers = Main.getLayerManager().getLayers();
     97        List<Layer> layers = MainApplication.getLayerManager().getLayers();
    9898        if (!layers.isEmpty()) {
    9999            mapFrame.selectMapMode((MapMode) mapFrame.getDefaultButtonAction(), layers.get(0));
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r12504 r12636  
    202202        setLayout(new BorderLayout());
    203203
    204         mapView = new MapView(Main.getLayerManager(), viewportData);
     204        mapView = new MapView(MainApplication.getLayerManager(), viewportData);
    205205
    206206        splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
     
    282282        // status line below the map
    283283        statusLine = new MapStatus(this);
    284         Main.getLayerManager().addLayerChangeListener(this);
    285         Main.getLayerManager().addActiveLayerChangeListener(this);
     284        MainApplication.getLayerManager().addLayerChangeListener(this);
     285        MainApplication.getLayerManager().addActiveLayerChangeListener(this);
    286286
    287287        boolean unregisterTab = Shortcut.findShortcut(KeyEvent.VK_TAB, 0).isPresent();
     
    342342    @Override
    343343    public void destroy() {
    344         Main.getLayerManager().removeLayerChangeListener(this);
    345         Main.getLayerManager().removeActiveLayerChangeListener(this);
     344        MainApplication.getLayerManager().removeLayerChangeListener(this);
     345        MainApplication.getLayerManager().removeActiveLayerChangeListener(this);
    346346        dialogsPanel.destroy();
    347347        Main.pref.removePreferenceChangeListener(sidetoolbarPreferencesChangedListener);
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r12630 r12636  
    486486         */
    487487        private void popupCycleSelection(Collection<OsmPrimitive> osms, int mods) {
    488             DataSet ds = Main.getLayerManager().getEditDataSet();
     488            DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    489489            // Find some items that are required for cycling through
    490490            OsmPrimitive firstItem = null;
     
    577577         */
    578578        private void popupSetLabelColors(JLabel lbl, OsmPrimitive osm) {
    579             DataSet ds = Main.getLayerManager().getEditDataSet();
     579            DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    580580            if (ds.isSelected(osm)) {
    581581                lbl.setBackground(SystemColor.textHighlight);
     
    650650                @Override
    651651                public void mouseClicked(MouseEvent e) {
    652                     DataSet ds = Main.getLayerManager().getEditDataSet();
     652                    DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    653653                    // Let the user toggle the selection
    654654                    ds.toggleSelected(osm);
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r12620 r12636  
    902902    private Map<Double, List<Node>> getNearestNodesImpl(Point p, Predicate<OsmPrimitive> predicate) {
    903903        Map<Double, List<Node>> nearestMap = new TreeMap<>();
    904         DataSet ds = Main.getLayerManager().getEditDataSet();
     904        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    905905
    906906        if (ds != null) {
     
    11111111    private Map<Double, List<WaySegment>> getNearestWaySegmentsImpl(Point p, Predicate<OsmPrimitive> predicate) {
    11121112        Map<Double, List<WaySegment>> nearestMap = new TreeMap<>();
    1113         DataSet ds = Main.getLayerManager().getEditDataSet();
     1113        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    11141114
    11151115        if (ds != null) {
     
    14721472    public final OsmPrimitive getNearestNodeOrWay(Point p, Predicate<OsmPrimitive> predicate, boolean useSelected) {
    14731473        Collection<OsmPrimitive> sel;
    1474         DataSet ds = Main.getLayerManager().getEditDataSet();
     1474        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    14751475        if (useSelected && ds != null) {
    14761476            sel = ds.getSelected();
  • trunk/src/org/openstreetmap/josm/gui/SelectionManager.java

    r12630 r12636  
    1818import javax.swing.Action;
    1919
    20 import org.openstreetmap.josm.Main;
    2120import org.openstreetmap.josm.actions.SelectByInternalPointAction;
    2221import org.openstreetmap.josm.data.Bounds;
     
    183182    @Override
    184183    public void mousePressed(MouseEvent e) {
    185         if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1 && Main.getLayerManager().getEditDataSet() != null) {
     184        if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1 && MainApplication.getLayerManager().getEditDataSet() != null) {
    186185            SelectByInternalPointAction.performSelection(MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY()),
    187186                    (e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0,
     
    382381        } else {
    383382            // nodes
    384             for (Node n : Main.getLayerManager().getEditDataSet().getNodes()) {
     383            for (Node n : MainApplication.getLayerManager().getEditDataSet().getNodes()) {
    385384                if (n.isSelectable() && selectionResult.contains(nc.getPoint2D(n))) {
    386385                    selection.add(n);
     
    389388
    390389            // ways
    391             for (Way w : Main.getLayerManager().getEditDataSet().getWays()) {
     390            for (Way w : MainApplication.getLayerManager().getEditDataSet().getWays()) {
    392391                if (!w.isSelectable() || w.getNodesCount() == 0) {
    393392                    continue;
  • trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java

    r12630 r12636  
    126126        Main.pref.addPreferenceChangeListener(this);
    127127        NavigatableComponent.addZoomChangeListener(this);
    128         Main.getLayerManager().addLayerChangeListener(this);
     128        MainApplication.getLayerManager().addLayerChangeListener(this);
    129129        DatasetEventManager.getInstance().addDatasetListener(this, FireMode.IN_EDT_CONSOLIDATED);
    130130        registerAutoFilterRules(AutoFilterRule.defaultRules());
     
    194194
    195195    private static Set<String> getTagValues(String key) {
    196         DataSet ds = Main.getLayerManager().getEditDataSet();
     196        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    197197        Set<String> values = new TreeSet<>();
    198198        if (ds != null) {
     
    371371            model.executeFilters();
    372372            if (model.isChanged()) {
    373                 OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     373                OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    374374                if (editLayer != null) {
    375375                    editLayer.invalidate();
     
    422422    @Override
    423423    public void layerRemoving(LayerRemoveEvent e) {
    424         if (Main.getLayerManager().getEditLayer() == null) {
     424        if (MainApplication.getLayerManager().getEditLayer() == null) {
    425425            resetCurrentAutoFilter();
    426426        }
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/AbstractListMerger.java

    r11604 r12636  
    3131import javax.swing.event.ListSelectionListener;
    3232
    33 import org.openstreetmap.josm.Main;
    3433import org.openstreetmap.josm.command.conflict.ConflictResolveCommand;
    3534import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    3736import org.openstreetmap.josm.data.osm.Relation;
    3837import org.openstreetmap.josm.data.osm.Way;
     38import org.openstreetmap.josm.gui.MainApplication;
    3939import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    4040import org.openstreetmap.josm.gui.util.AdjustmentSynchronizer;
     
    901901    protected final <P extends OsmPrimitive> OsmDataLayer findLayerFor(P primitive) {
    902902        if (primitive != null) {
    903             Iterable<OsmDataLayer> layers = Main.getLayerManager().getLayersOfType(OsmDataLayer.class);
     903            Iterable<OsmDataLayer> layers = MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class);
    904904            // Find layer with same dataset
    905905            for (OsmDataLayer layer : layers) {
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java

    r11354 r12636  
    2828import javax.swing.event.ChangeListener;
    2929
    30 import org.openstreetmap.josm.Main;
    3130import org.openstreetmap.josm.command.ChangePropertyCommand;
    3231import org.openstreetmap.josm.command.Command;
    3332import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3433import org.openstreetmap.josm.data.osm.Tag;
     34import org.openstreetmap.josm.gui.MainApplication;
    3535import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3636import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
     
    197197    public void prepareForEditing() {
    198198        AutoCompletionList acList = new AutoCompletionList();
    199         OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     199        OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    200200        if (editLayer != null) {
    201201            editLayer.data.getAutoCompletionManager().populateWithMemberRoles(acList);
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/AbstractStackTransferHandler.java

    r12620 r12636  
    1010import javax.swing.TransferHandler;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.coor.EastNorth;
     13import org.openstreetmap.josm.gui.MainApplication;
    1414import org.openstreetmap.josm.gui.datatransfer.importers.AbstractOsmDataPaster;
    1515import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    4545    @Override
    4646    public boolean importData(TransferSupport support) {
    47         return importData(support, Main.getLayerManager().getEditLayer(), null);
     47        return importData(support, MainApplication.getLayerManager().getEditLayer(), null);
    4848    }
    4949
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java

    r12634 r12636  
    121121        // events and bootstrap it's content
    122122        ChangesetCache.getInstance().addChangesetCacheListener(inActiveDataLayerModel);
    123         Main.getLayerManager().addActiveLayerChangeListener(inActiveDataLayerModel);
    124         OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     123        MainApplication.getLayerManager().addActiveLayerChangeListener(inActiveDataLayerModel);
     124        OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    125125        if (editLayer != null) {
    126126            editLayer.data.addDataSetListener(inActiveDataLayerModel);
     
    134134        //
    135135        ChangesetCache.getInstance().removeChangesetCacheListener(inActiveDataLayerModel);
    136         Main.getLayerManager().removeActiveLayerChangeListener(inActiveDataLayerModel);
    137         OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     136        MainApplication.getLayerManager().removeActiveLayerChangeListener(inActiveDataLayerModel);
     137        OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    138138        if (editLayer != null) {
    139139            editLayer.data.removeDataSetListener(inActiveDataLayerModel);
     
    234234
    235235    protected void initWithCurrentData() {
    236         OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     236        OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    237237        if (editLayer != null) {
    238238            inSelectionModel.initFromPrimitives(editLayer.data.getAllSelected());
     
    265265            if (sel.isEmpty())
    266266                return;
    267             if (Main.getLayerManager().getEditDataSet() == null)
    268                 return;
    269             new SelectObjectsAction().selectObjectsByChangesetIds(Main.getLayerManager().getEditDataSet(), sel);
     267            if (MainApplication.getLayerManager().getEditDataSet() == null)
     268                return;
     269            new SelectObjectsAction().selectObjectsByChangesetIds(MainApplication.getLayerManager().getEditDataSet(), sel);
    270270        }
    271271
     
    313313        @Override
    314314        public void actionPerformed(ActionEvent e) {
    315             if (Main.getLayerManager().getEditLayer() == null)
     315            if (MainApplication.getLayerManager().getEditLayer() == null)
    316316                return;
    317317            ChangesetListModel model = getCurrentChangesetListModel();
     
    320320                return;
    321321
    322             DataSet ds = Main.getLayerManager().getEditLayer().data;
     322            DataSet ds = MainApplication.getLayerManager().getEditLayer().data;
    323323            selectObjectsByChangesetIds(ds, sel);
    324324        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java

    r12630 r12636  
    258258    private void buildTrees() {
    259259        setTitle(tr("Command Stack"));
    260         if (Main.getLayerManager().getEditLayer() == null)
     260        if (MainApplication.getLayerManager().getEditLayer() == null)
    261261            return;
    262262
     
    335335    protected static Collection<? extends OsmPrimitive> getAffectedPrimitives(TreePath path) {
    336336        PseudoCommand c = ((CommandListMutableTreeNode) path.getLastPathComponent()).getCommand();
    337         final OsmDataLayer currentLayer = Main.getLayerManager().getEditLayer();
     337        final OsmDataLayer currentLayer = MainApplication.getLayerManager().getEditLayer();
    338338        return new SubclassFilteredCollection<>(
    339339                c.getParticipatingPrimitives(),
     
    376376                throw new IllegalStateException();
    377377
    378             DataSet dataSet = Main.getLayerManager().getEditDataSet();
     378            DataSet dataSet = MainApplication.getLayerManager().getEditDataSet();
    379379            if (dataSet == null) return;
    380380            dataSet.setSelected(getAffectedPrimitives(path));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java

    r12630 r12636  
    155155    @Override
    156156    public void showNotify() {
    157         Main.getLayerManager().addAndFireActiveLayerChangeListener(this);
     157        MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(this);
    158158    }
    159159
    160160    @Override
    161161    public void hideNotify() {
    162         Main.getLayerManager().removeActiveLayerChangeListener(this);
    163         removeEditLayerListeners(Main.getLayerManager().getEditLayer());
     162        MainApplication.getLayerManager().removeActiveLayerChangeListener(this);
     163        removeEditLayerListeners(MainApplication.getLayerManager().getEditLayer());
    164164    }
    165165
     
    218218     */
    219219    public void refreshView() {
    220         OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     220        OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    221221        synchronized (this) {
    222222            conflicts = editLayer == null ? new ConflictCollection() : editLayer.getConflicts();
     
    483483                }
    484484            }
    485             DataSet ds = Main.getLayerManager().getEditDataSet();
     485            DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    486486            if (ds != null) { // Can't see how it is possible but it happened in #7942
    487487                ds.setSelected(sel);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java

    r12630 r12636  
    115115
    116116    protected static String buildMapPaintText() {
    117         final Collection<OsmPrimitive> sel = Main.getLayerManager().getEditDataSet().getAllSelected();
     117        final Collection<OsmPrimitive> sel = MainApplication.getLayerManager().getEditDataSet().getAllSelected();
    118118        ElemStyles elemstyles = MapPaintStyles.getStyles();
    119119        NavigatableComponent nc = MainApplication.getMap().mapView;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r12630 r12636  
    11611161     */
    11621162    public static Layer getLayerForIndex(int index) {
    1163         List<Layer> layers = Main.getLayerManager().getLayers();
     1163        List<Layer> layers = MainApplication.getLayerManager().getLayers();
    11641164
    11651165        if (index < layers.size() && index >= 0)
     
    11781178        List<MultikeyInfo> result = new ArrayList<>();
    11791179
    1180         List<Layer> layers = Main.getLayerManager().getLayers();
     1180        List<Layer> layers = MainApplication.getLayerManager().getLayers();
    11811181
    11821182        int index = 0;
     
    12001200            return false;
    12011201
    1202         return Main.getLayerManager().containsLayer(l);
     1202        return MainApplication.getLayerManager().containsLayer(l);
    12031203    }
    12041204
     
    12121212            return null;
    12131213
    1214         int index = Main.getLayerManager().getLayers().indexOf(l);
     1214        int index = MainApplication.getLayerManager().getLayers().indexOf(l);
    12151215        if (index < 0)
    12161216            return null;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java

    r12630 r12636  
    8282        uploadAction = new UploadNotesAction();
    8383        buildDialog();
    84         Main.getLayerManager().addLayerChangeListener(this);
     84        MainApplication.getLayerManager().addLayerChangeListener(this);
    8585    }
    8686
     
    356356        public void actionPerformed(ActionEvent e) {
    357357            if (noteData == null) { //there is no notes layer. Create one first
    358                 Main.getLayerManager().addLayer(new NoteLayer());
     358                MainApplication.getLayerManager().addLayer(new NoteLayer());
    359359            }
    360360            MainApplication.getMap().selectMapMode(new AddNoteAction(noteData));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r12630 r12636  
    217217    @Override
    218218    public void showNotify() {
    219         Main.getLayerManager().addLayerChangeListener(newAction);
    220         Main.getLayerManager().addActiveLayerChangeListener(newAction);
     219        MainApplication.getLayerManager().addLayerChangeListener(newAction);
     220        MainApplication.getLayerManager().addActiveLayerChangeListener(newAction);
    221221        MapView.addZoomChangeListener(this);
    222222        newAction.updateEnabledState();
     
    230230    @Override
    231231    public void hideNotify() {
    232         Main.getLayerManager().removeActiveLayerChangeListener(newAction);
    233         Main.getLayerManager().removeLayerChangeListener(newAction);
     232        MainApplication.getLayerManager().removeActiveLayerChangeListener(newAction);
     233        MainApplication.getLayerManager().removeLayerChangeListener(newAction);
    234234        MapView.removeZoomChangeListener(this);
    235235        DatasetEventManager.getInstance().removeDatasetListener(this);
     
    326326
    327327        protected void setCurrentRelationAsSelection() {
    328             Main.getLayerManager().getEditDataSet().setSelected(displaylist.getSelectedValue());
     328            MainApplication.getLayerManager().getEditDataSet().setSelected(displaylist.getSelectedValue());
    329329        }
    330330
     
    335335        @Override
    336336        public void mouseClicked(MouseEvent e) {
    337             if (Main.getLayerManager().getEditLayer() == null) return;
     337            if (MainApplication.getLayerManager().getEditLayer() == null) return;
    338338            if (isDoubleClick(e)) {
    339339                if (e.isControlDown()) {
     
    358358
    359359        public void run() {
    360             RelationEditor.getEditor(Main.getLayerManager().getEditLayer(), null, null).setVisible(true);
     360            RelationEditor.getEditor(MainApplication.getLayerManager().getEditLayer(), null, null).setVisible(true);
    361361        }
    362362
     
    367367
    368368        protected void updateEnabledState() {
    369             setEnabled(Main.getLayerManager().getEditLayer() != null);
     369            setEnabled(MainApplication.getLayerManager().getEditLayer() != null);
    370370        }
    371371
     
    696696    @Override
    697697    public void dataChanged(DataChangedEvent event) {
    698         initFromLayer(Main.getLayerManager().getEditLayer());
     698        initFromLayer(MainApplication.getLayerManager().getEditLayer());
    699699    }
    700700
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r12630 r12636  
    172172        SelectionEventManager.getInstance().addSelectionListener(model, FireMode.IN_EDT_CONSOLIDATED);
    173173        DatasetEventManager.getInstance().addDatasetListener(model, FireMode.IN_EDT);
    174         Main.getLayerManager().addActiveLayerChangeListener(actSearch);
     174        MainApplication.getLayerManager().addActiveLayerChangeListener(actSearch);
    175175        // editLayerChanged also gets the selection history of the level. Listener calls setJOSMSelection when fired.
    176         Main.getLayerManager().addAndFireActiveLayerChangeListener(model);
     176        MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(model);
    177177        actSearch.updateEnabledState();
    178178    }
     
    180180    @Override
    181181    public void hideNotify() {
    182         Main.getLayerManager().removeActiveLayerChangeListener(actSearch);
    183         Main.getLayerManager().removeActiveLayerChangeListener(model);
     182        MainApplication.getLayerManager().removeActiveLayerChangeListener(actSearch);
     183        MainApplication.getLayerManager().removeActiveLayerChangeListener(model);
    184184        SelectionEventManager.getInstance().removeSelectionListener(actShowHistory);
    185185        SelectionEventManager.getInstance().removeSelectionListener(model);
     
    203203            if (idx < 0) return;
    204204            if (isDoubleClick(e)) {
    205                 OsmDataLayer layer = Main.getLayerManager().getEditLayer();
     205                OsmDataLayer layer = MainApplication.getLayerManager().getEditLayer();
    206206                if (layer == null) return;
    207207                OsmPrimitive osm = model.getElementAt(idx);
     
    299299
    300300        protected void updateEnabledState() {
    301             setEnabled(Main.getLayerManager().getEditLayer() != null);
     301            setEnabled(MainApplication.getLayerManager().getEditLayer() != null);
    302302        }
    303303
     
    324324            Collection<OsmPrimitive> sel = model.getSelected();
    325325            if (sel.isEmpty()) return;
    326             OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     326            OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    327327            if (editLayer == null) return;
    328328            editLayer.data.setSelected(sel);
     
    845845        @Override
    846846        public void actionPerformed(ActionEvent e) {
    847             Main.getLayerManager().getEditDataSet().setSelected(sel);
     847            MainApplication.getLayerManager().getEditDataSet().setSelected(sel);
    848848        }
    849849    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r12620 r12636  
    5454import org.openstreetmap.josm.data.preferences.BooleanProperty;
    5555import org.openstreetmap.josm.data.preferences.ParametrizedEnumProperty;
     56import org.openstreetmap.josm.gui.MainApplication;
    5657import org.openstreetmap.josm.gui.MainMenu;
    5758import org.openstreetmap.josm.gui.ShowHideButtonListener;
     
    255256        setBorder(BorderFactory.createEtchedBorder());
    256257
    257         Main.redirectToMainContentPane(this);
     258        MainApplication.redirectToMainContentPane(this);
    258259        Main.pref.addPreferenceChangeListener(this);
    259260
  • trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java

    r12620 r12636  
    3535import org.openstreetmap.josm.data.osm.User;
    3636import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
     37import org.openstreetmap.josm.gui.MainApplication;
    3738import org.openstreetmap.josm.gui.SideButton;
    3839import org.openstreetmap.josm.gui.layer.Layer;
     
    7374    public void showNotify() {
    7475        SelectionEventManager.getInstance().addSelectionListenerForEdt(this);
    75         Main.getLayerManager().addActiveLayerChangeListener(this);
     76        MainApplication.getLayerManager().addActiveLayerChangeListener(this);
    7677    }
    7778
    7879    @Override
    7980    public void hideNotify() {
    80         Main.getLayerManager().removeActiveLayerChangeListener(this);
     81        MainApplication.getLayerManager().removeActiveLayerChangeListener(this);
    8182        SelectionEventManager.getInstance().removeSelectionListener(this);
    8283    }
     
    141142    public void showDialog() {
    142143        super.showDialog();
    143         refreshForActiveLayer(Main.getLayerManager().getActiveLayer());
     144        refreshForActiveLayer(MainApplication.getLayerManager().getActiveLayer());
    144145    }
    145146
     
    346347                users.add(data.get(index).user);
    347348            }
    348             Collection<OsmPrimitive> selected = Main.getLayerManager().getEditDataSet().getAllSelected();
     349            Collection<OsmPrimitive> selected = MainApplication.getLayerManager().getEditDataSet().getAllSelected();
    349350            Collection<OsmPrimitive> byUser = new LinkedList<>();
    350351            for (OsmPrimitive p : selected) {
     
    353354                }
    354355            }
    355             Main.getLayerManager().getEditDataSet().setSelected(byUser);
     356            MainApplication.getLayerManager().getEditDataSet().setSelected(byUser);
    356357        }
    357358
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java

    r12634 r12636  
    131131            @Override
    132132            public void actionPerformed(ActionEvent e) {
    133                 final DataSet ds = Main.getLayerManager().getEditDataSet();
     133                final DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    134134                if (ds == null) {
    135135                    return;
     
    180180    public void showNotify() {
    181181        DataSet.addSelectionListener(this);
    182         DataSet ds = Main.getLayerManager().getEditDataSet();
     182        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    183183        if (ds != null) {
    184184            updateSelection(ds.getAllSelected());
    185185        }
    186         Main.getLayerManager().addAndFireActiveLayerChangeListener(this);
     186        MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(this);
    187187    }
    188188
    189189    @Override
    190190    public void hideNotify() {
    191         Main.getLayerManager().removeActiveLayerChangeListener(this);
     191        MainApplication.getLayerManager().removeActiveLayerChangeListener(this);
    192192        DataSet.removeSelectionListener(this);
    193193    }
     
    349349            }
    350350        }
    351         DataSet ds = Main.getLayerManager().getEditDataSet();
     351        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    352352        if (ds != null) {
    353353            ds.setSelected(sel);
     
    488488
    489489            if (isDblClick) {
    490                 DataSet ds = Main.getLayerManager().getEditDataSet();
     490                DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    491491                if (ds != null) {
    492492                    ds.setSelected(sel);
     
    627627            try {
    628628                monitor.setTicksCount(testErrors.size());
    629                 final DataSet ds = Main.getLayerManager().getEditDataSet();
     629                final DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    630630                int i = 0;
    631631                SwingUtilities.invokeAndWait(ds::beginUpdate);
     
    645645                SwingUtilities.invokeAndWait(() -> {
    646646                    Main.main.undoRedo.afterAdd();
    647                     Main.getLayerManager().getLayersOfType(ValidatorLayer.class).forEach(ValidatorLayer::invalidate);
     647                    MainApplication.getLayerManager().getLayersOfType(ValidatorLayer.class).forEach(ValidatorLayer::invalidate);
    648648                    tree.resetErrors();
    649649                });
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java

    r12634 r12636  
    3333import javax.swing.event.ListSelectionListener;
    3434
    35 import org.openstreetmap.josm.Main;
    3635import org.openstreetmap.josm.actions.AutoScaleAction;
    3736import org.openstreetmap.josm.actions.downloadtasks.ChangesetContentDownloadTask;
     
    9392        actSelectInCurrentLayerAction = new SelectInCurrentLayerAction();
    9493        model.getSelectionModel().addListSelectionListener(actSelectInCurrentLayerAction);
    95         Main.getLayerManager().addActiveLayerChangeListener(actSelectInCurrentLayerAction);
     94        MainApplication.getLayerManager().addActiveLayerChangeListener(actSelectInCurrentLayerAction);
    9695
    9796        actZoomInCurrentLayerAction = new ZoomInCurrentLayerAction();
    9897        model.getSelectionModel().addListSelectionListener(actZoomInCurrentLayerAction);
    99         Main.getLayerManager().addActiveLayerChangeListener(actZoomInCurrentLayerAction);
     98        MainApplication.getLayerManager().addActiveLayerChangeListener(actZoomInCurrentLayerAction);
    10099
    101100        addComponentListener(
     
    103102                    @Override
    104103                    public void componentShown(ComponentEvent e) {
    105                         Main.getLayerManager().addAndFireActiveLayerChangeListener(actSelectInCurrentLayerAction);
    106                         Main.getLayerManager().addAndFireActiveLayerChangeListener(actZoomInCurrentLayerAction);
     104                        MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(actSelectInCurrentLayerAction);
     105                        MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(actZoomInCurrentLayerAction);
    107106                    }
    108107
     
    110109                    public void componentHidden(ComponentEvent e) {
    111110                        // make sure the listener is unregistered when the panel becomes invisible
    112                         Main.getLayerManager().removeActiveLayerChangeListener(actSelectInCurrentLayerAction);
    113                         Main.getLayerManager().removeActiveLayerChangeListener(actZoomInCurrentLayerAction);
     111                        MainApplication.getLayerManager().removeActiveLayerChangeListener(actSelectInCurrentLayerAction);
     112                        MainApplication.getLayerManager().removeActiveLayerChangeListener(actZoomInCurrentLayerAction);
    114113                    }
    115114                }
     
    201200                        + "edit layer ''{0}''.</html>",
    202201                        primitives.size(),
    203                         Utils.escapeReservedCharactersHTML(Main.getLayerManager().getEditLayer().getName())
     202                        Utils.escapeReservedCharactersHTML(MainApplication.getLayerManager().getEditLayer().getName())
    204203                ),
    205204                title, JOptionPane.WARNING_MESSAGE, helpTopic
     
    324323                return null;
    325324            }
    326             OsmDataLayer layer = Main.getLayerManager().getEditLayer();
     325            OsmDataLayer layer = MainApplication.getLayerManager().getEditLayer();
    327326            if (layer == null) {
    328327                return null;
     
    339338
    340339        public final void updateEnabledState() {
    341             setEnabled(Main.getLayerManager().getEditLayer() != null && model.hasSelectedPrimitives());
     340            setEnabled(MainApplication.getLayerManager().getEditLayer() != null && model.hasSelectedPrimitives());
    342341        }
    343342
     
    373372                return;
    374373            }
    375             Main.getLayerManager().getEditLayer().data.setSelected(target);
     374            MainApplication.getLayerManager().getEditLayer().data.setSelected(target);
    376375        }
    377376    }
     
    396395                return;
    397396            }
    398             Main.getLayerManager().getEditLayer().data.setSelected(target);
     397            MainApplication.getLayerManager().getEditLayer().data.setSelected(target);
    399398            AutoScaleAction.zoomToSelection();
    400399        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDetailPanel.java

    r12634 r12636  
    9191
    9292        tb.add(actSelectInCurrentLayer);
    93         Main.getLayerManager().addActiveLayerChangeListener(actSelectInCurrentLayer);
     93        MainApplication.getLayerManager().addActiveLayerChangeListener(actSelectInCurrentLayer);
    9494
    9595        tb.add(actZoomInCurrentLayerAction);
    96         Main.getLayerManager().addActiveLayerChangeListener(actZoomInCurrentLayerAction);
     96        MainApplication.getLayerManager().addActiveLayerChangeListener(actZoomInCurrentLayerAction);
    9797
    9898        addComponentListener(
     
    100100                    @Override
    101101                    public void componentShown(ComponentEvent e) {
    102                         Main.getLayerManager().addAndFireActiveLayerChangeListener(actSelectInCurrentLayer);
    103                         Main.getLayerManager().addAndFireActiveLayerChangeListener(actZoomInCurrentLayerAction);
     102                        MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(actSelectInCurrentLayer);
     103                        MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(actZoomInCurrentLayerAction);
    104104                    }
    105105
     
    107107                    public void componentHidden(ComponentEvent e) {
    108108                        // make sure the listener is unregistered when the panel becomes invisible
    109                         Main.getLayerManager().removeActiveLayerChangeListener(actSelectInCurrentLayer);
    110                         Main.getLayerManager().removeActiveLayerChangeListener(actZoomInCurrentLayerAction);
     109                        MainApplication.getLayerManager().removeActiveLayerChangeListener(actSelectInCurrentLayer);
     110                        MainApplication.getLayerManager().removeActiveLayerChangeListener(actZoomInCurrentLayerAction);
    111111                    }
    112112                }
     
    344344                            + "edit layer ''{1}''.</html>",
    345345                            currentChangeset.getId(),
    346                             Utils.escapeReservedCharactersHTML(Main.getLayerManager().getEditLayer().getName())
     346                            Utils.escapeReservedCharactersHTML(MainApplication.getLayerManager().getEditLayer().getName())
    347347                    ),
    348348                    tr("Nothing to select"),
     
    356356            if (!isEnabled())
    357357                return;
    358             OsmDataLayer layer = Main.getLayerManager().getEditLayer();
     358            OsmDataLayer layer = MainApplication.getLayerManager().getEditLayer();
    359359            if (layer == null) {
    360360                return;
     
    374374
    375375        public void updateEnabledState() {
    376             setEnabled(Main.getLayerManager().getEditLayer() != null && currentChangeset != null);
     376            setEnabled(MainApplication.getLayerManager().getEditLayer() != null && currentChangeset != null);
    377377        }
    378378
     
    403403                            + "edit layer ''{1}''.</html>",
    404404                            currentChangeset.getId(),
    405                             Main.getLayerManager().getEditLayer().getName()
     405                            MainApplication.getLayerManager().getEditLayer().getName()
    406406                    ),
    407407                    tr("Nothing to zoom to"),
     
    415415            if (!isEnabled())
    416416                return;
    417             OsmDataLayer layer = Main.getLayerManager().getEditLayer();
     417            OsmDataLayer layer = MainApplication.getLayerManager().getEditLayer();
    418418            if (layer == null) {
    419419                return;
     
    434434
    435435        public void updateEnabledState() {
    436             setEnabled(Main.getLayerManager().getEditLayer() != null && currentChangeset != null);
     436            setEnabled(MainApplication.getLayerManager().getEditLayer() != null && currentChangeset != null);
    437437        }
    438438
  • trunk/src/org/openstreetmap/josm/gui/dialogs/layer/DuplicateAction.java

    r11505 r12636  
    88import javax.swing.AbstractAction;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.osm.DataSet;
     11import org.openstreetmap.josm.gui.MainApplication;
    1212import org.openstreetmap.josm.gui.dialogs.IEnabledStateUpdating;
    1313import org.openstreetmap.josm.gui.dialogs.LayerListDialog.LayerListModel;
     
    5353    private static void duplicate(Layer layer) {
    5454        if (layer instanceof OsmDataLayer) {
    55             String newName = LayerListTransferHandler.suggestNewLayerName(layer.getName(), Main.getLayerManager().getLayers());
     55            String newName = LayerListTransferHandler.suggestNewLayerName(layer.getName(), MainApplication.getLayerManager().getLayers());
    5656            OsmDataLayer oldLayer = (OsmDataLayer) layer;
    57             Main.getLayerManager().addLayer(new OsmDataLayer(new DataSet(oldLayer.data), newName, null));
     57            MainApplication.getLayerManager().addLayer(new OsmDataLayer(new DataSet(oldLayer.data), newName, null));
    5858        }
    5959    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r12634 r12636  
    230230
    231231    private final PreferenceChangedListener preferenceListener = e -> {
    232                 if (Main.getLayerManager().getEditDataSet() != null) {
     232                if (MainApplication.getLayerManager().getEditDataSet() != null) {
    233233                    // Re-load data when display preference change
    234234                    updateSelection();
     
    487487        MainApplication.getMap().relationListDialog.selectRelation(relation);
    488488        RelationEditor.getEditor(
    489                 Main.getLayerManager().getEditLayer(),
     489                MainApplication.getLayerManager().getEditLayer(),
    490490                relation,
    491491                ((MemberInfo) membershipData.getValueAt(row, 1)).role
     
    513513        DatasetEventManager.getInstance().addDatasetListener(dataChangedAdapter, FireMode.IN_EDT_CONSOLIDATED);
    514514        SelectionEventManager.getInstance().addSelectionListener(this, FireMode.IN_EDT_CONSOLIDATED);
    515         Main.getLayerManager().addActiveLayerChangeListener(this);
     515        MainApplication.getLayerManager().addActiveLayerChangeListener(this);
    516516        for (JosmAction action : josmActions) {
    517517            Main.registerActionShortcut(action);
     
    524524        DatasetEventManager.getInstance().removeDatasetListener(dataChangedAdapter);
    525525        SelectionEventManager.getInstance().removeSelectionListener(this);
    526         Main.getLayerManager().removeActiveLayerChangeListener(this);
     526        MainApplication.getLayerManager().removeActiveLayerChangeListener(this);
    527527        for (JosmAction action : josmActions) {
    528528            Main.unregisterActionShortcut(action);
     
    533533    public void setVisible(boolean b) {
    534534        super.setVisible(b);
    535         if (b && Main.getLayerManager().getEditDataSet() != null) {
     535        if (b && MainApplication.getLayerManager().getEditDataSet() != null) {
    536536            updateSelection();
    537537        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java

    r12620 r12636  
    7777import org.openstreetmap.josm.gui.ExtendedDialog;
    7878import org.openstreetmap.josm.gui.IExtendedDialog;
     79import org.openstreetmap.josm.gui.MainApplication;
    7980import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
    8081import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     
    443444            mainPanel.add(p, BorderLayout.CENTER);
    444445
    445             AutoCompletionManager autocomplete = Main.getLayerManager().getEditLayer().data.getAutoCompletionManager();
     446            AutoCompletionManager autocomplete = MainApplication.getLayerManager().getEditLayer().data.getAutoCompletionManager();
    446447            List<AutoCompletionListItem> keyList = autocomplete.getKeys();
    447448            keyList.sort(DEFAULT_AC_ITEM_COMPARATOR);
     
    689690
    690691            cacheRecentTags();
    691             AutoCompletionManager autocomplete = Main.getLayerManager().getEditLayer().data.getAutoCompletionManager();
     692            AutoCompletionManager autocomplete = MainApplication.getLayerManager().getEditLayer().data.getAutoCompletionManager();
    692693            List<AutoCompletionListItem> keyList = autocomplete.getKeys();
    693694
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java

    r12630 r12636  
    137137    @Override
    138138    public void registerListeners() {
    139         Main.getLayerManager().addLayerChangeListener(zoomToGap);
    140         Main.getLayerManager().addActiveLayerChangeListener(zoomToGap);
     139        MainApplication.getLayerManager().addLayerChangeListener(zoomToGap);
     140        MainApplication.getLayerManager().addActiveLayerChangeListener(zoomToGap);
    141141        super.registerListeners();
    142142    }
     
    145145    public void unregisterListeners() {
    146146        super.unregisterListeners();
    147         Main.getLayerManager().removeLayerChangeListener(zoomToGap);
    148         Main.getLayerManager().removeActiveLayerChangeListener(zoomToGap);
     147        MainApplication.getLayerManager().removeLayerChangeListener(zoomToGap);
     148        MainApplication.getLayerManager().removeActiveLayerChangeListener(zoomToGap);
    149149    }
    150150
     
    239239        private void updateEnabledState() {
    240240            setEnabled(Main.main != null
    241                     && Main.getLayerManager().getEditLayer() == getLayer()
     241                    && MainApplication.getLayerManager().getEditLayer() == getLayer()
    242242                    && getSelectedRowCount() == 1
    243243                    && hasGap());
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java

    r11893 r12636  
    2121import javax.swing.table.AbstractTableModel;
    2222
    23 import org.openstreetmap.josm.Main;
    2423import org.openstreetmap.josm.data.SelectionChangedListener;
    2524import org.openstreetmap.josm.data.osm.DataSet;
     
    3635import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
    3736import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
     37import org.openstreetmap.josm.gui.MainApplication;
    3838import org.openstreetmap.josm.gui.dialogs.relation.sort.RelationSorter;
    3939import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType;
     
    111111    @Override
    112112    public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    113         if (Main.getLayerManager().getEditLayer() != this.layer) return;
     113        if (MainApplication.getLayerManager().getEditLayer() != this.layer) return;
    114114        // just trigger a repaint
    115115        Collection<RelationMember> sel = getSelectedMembers();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java

    r12634 r12636  
    3333 *  final ParentRelationLoadingTask task = new ParentRelationLoadingTask(
    3434 *                   child,   // the child relation
    35  *                   Main.getLayerManager().getEditLayer(), // the edit layer
     35 *                   MainApplication.getLayerManager().getEditLayer(), // the edit layer
    3636 *                   true,  // load fully
    3737 *                   new PleaseWaitProgressMonitor()  // a progress monitor
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java

    r11881 r12636  
    1313import java.util.Optional;
    1414
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.data.osm.Relation;
     16import org.openstreetmap.josm.gui.MainApplication;
    1717import org.openstreetmap.josm.gui.layer.Layer;
    1818import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     
    3939        if (RelationDialogManager.relationDialogManager == null) {
    4040            RelationDialogManager.relationDialogManager = new RelationDialogManager();
    41             Main.getLayerManager().addLayerChangeListener(RelationDialogManager.relationDialogManager);
     41            MainApplication.getLayerManager().addLayerChangeListener(RelationDialogManager.relationDialogManager);
    4242        }
    4343        return RelationDialogManager.relationDialogManager;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationTree.java

    r12634 r12636  
    1515import javax.swing.tree.TreePath;
    1616
    17 import org.openstreetmap.josm.Main;
    1817import org.openstreetmap.josm.data.osm.DataSet;
    1918import org.openstreetmap.josm.data.osm.DataSetMerger;
     
    137136                return;
    138137            }
    139             DataSetMerger visitor = new DataSetMerger(Main.getLayerManager().getEditLayer().data, ds);
     138            DataSetMerger visitor = new DataSetMerger(MainApplication.getLayerManager().getEditLayer().data, ds);
    140139            visitor.merge();
    141140            if (!visitor.getConflicts().isEmpty()) {
    142                 Main.getLayerManager().getEditLayer().getConflicts().add(visitor.getConflicts());
     141                MainApplication.getLayerManager().getEditLayer().getConflicts().add(visitor.getConflicts());
    143142            }
    144143            final RelationTreeModel model = (RelationTreeModel) getModel();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTableModel.java

    r10413 r12636  
    77import javax.swing.table.AbstractTableModel;
    88
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.data.SelectionChangedListener;
    1110import org.openstreetmap.josm.data.osm.DataSet;
    1211import org.openstreetmap.josm.data.osm.OsmPrimitive;
     12import org.openstreetmap.josm.gui.MainApplication;
    1313import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
    1414import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     
    4444    public void register() {
    4545        DataSet.addSelectionListener(this);
    46         Main.getLayerManager().addActiveLayerChangeListener(this);
     46        MainApplication.getLayerManager().addActiveLayerChangeListener(this);
    4747    }
    4848
     
    5252    public void unregister() {
    5353        DataSet.removeSelectionListener(this);
    54         Main.getLayerManager().removeActiveLayerChangeListener(this);
     54        MainApplication.getLayerManager().removeActiveLayerChangeListener(this);
    5555    }
    5656
     
    6262    @Override
    6363    public int getRowCount() {
    64         if (Main.getLayerManager().getEditLayer() != layer)
     64        if (MainApplication.getLayerManager().getEditLayer() != layer)
    6565            return 0;
    6666        return cache.size();
     
    104104    @Override
    105105    public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    106         if (layer == Main.getLayerManager().getEditLayer()) {
     106        if (layer == MainApplication.getLayerManager().getEditLayer()) {
    107107            cache.clear();
    108108            cache.addAll(newSelection);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java

    r11381 r12636  
    2727import javax.swing.tree.TreeSelectionModel;
    2828
    29 import org.openstreetmap.josm.Main;
    3029import org.openstreetmap.josm.data.osm.DataSet;
    3130import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    4342import org.openstreetmap.josm.data.validation.TestError;
    4443import org.openstreetmap.josm.data.validation.util.MultipleNameVisitor;
     44import org.openstreetmap.josm.gui.MainApplication;
    4545import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference;
    4646import org.openstreetmap.josm.gui.util.GuiHelper;
     
    425425    @Override
    426426    public void destroy() {
    427         DataSet ds = Main.getLayerManager().getEditDataSet();
     427        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    428428        if (ds != null) {
    429429            ds.removeDataSetListener(this);
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java

    r12634 r12636  
    6666    protected HistoryBrowserDialogManager() {
    6767        dialogs = new HashMap<>();
    68         Main.getLayerManager().addLayerChangeListener(this);
     68        MainApplication.getLayerManager().addLayerChangeListener(this);
    6969    }
    7070
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r12620 r12636  
    3636import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
    3737import org.openstreetmap.josm.gui.JosmUserIdentityManager;
     38import org.openstreetmap.josm.gui.MainApplication;
    3839import org.openstreetmap.josm.gui.layer.Layer;
    3940import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     
    101102
    102103        if (Main.main != null) {
    103             OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     104            OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    104105            if (editLayer != null) {
    105106                editLayer.data.addDataSetListener(this);
    106107            }
    107108        }
    108         Main.getLayerManager().addActiveLayerChangeListener(this);
     109        MainApplication.getLayerManager().addActiveLayerChangeListener(this);
    109110    }
    110111
     
    170171        if (history.getNumVersions() > 0) {
    171172            HistoryOsmPrimitive newLatest = null;
    172             OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     173            OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    173174            if (editLayer != null) {
    174175                OsmPrimitive p = editLayer.data.getPrimitiveById(history.getId(), history.getType());
     
    531532     */
    532533    public void unlinkAsListener() {
    533         OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     534        OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    534535        if (editLayer != null) {
    535536            editLayer.data.removeDataSetListener(this);
    536537        }
    537         Main.getLayerManager().removeActiveLayerChangeListener(this);
     538        MainApplication.getLayerManager().removeActiveLayerChangeListener(this);
    538539    }
    539540
  • trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java

    r12634 r12636  
    2121import javax.swing.event.TableModelListener;
    2222
    23 import org.openstreetmap.josm.Main;
    2423import org.openstreetmap.josm.actions.AutoScaleAction;
    2524import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    250249            OsmPrimitive p = getPrimitiveToZoom();
    251250            if (p != null) {
    252                 OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     251                OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    253252                if (editLayer != null) {
    254253                    editLayer.data.setSelected(p.getPrimitiveId());
     
    266265            if (primitiveId == null)
    267266                return null;
    268             OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     267            OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    269268            if (editLayer == null)
    270269                return null;
     
    273272
    274273        public void updateEnabledState() {
    275             setEnabled(Main.getLayerManager().getEditLayer() != null && getPrimitiveToZoom() != null);
     274            setEnabled(MainApplication.getLayerManager().getEditLayer() != null && getPrimitiveToZoom() != null);
    276275        }
    277276    }
  • trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java

    r12043 r12636  
    3030import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
    3131import org.openstreetmap.josm.gui.JosmUserIdentityManager;
     32import org.openstreetmap.josm.gui.MainApplication;
    3233import org.openstreetmap.josm.gui.dialogs.ChangesetDialog;
    3334import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager;
     
    155156        String text;
    156157        if (isLatest) {
    157             OsmDataLayer editLayer = Main.getLayerManager().getEditLayer();
     158            OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    158159            text = tr("<html>Version <strong>{0}</strong> currently edited in layer ''{1}''</html>",
    159160                    Long.toString(version),
  • trunk/src/org/openstreetmap/josm/gui/io/AbstractUploadTask.java

    r12634 r12636  
    8686        // FIXME: should now about the layer this task is running for. might
    8787        // be different from the current edit layer
    88         OsmDataLayer layer = Main.getLayerManager().getEditLayer();
     88        OsmDataLayer layer = MainApplication.getLayerManager().getEditLayer();
    8989        if (layer == null)
    9090            throw new IllegalStateException(tr("Failed to update primitive with id {0} because current edit layer is null", id));
     
    275275        );
    276276        if (ret == 0) {
    277             DownloadReferrersAction.downloadReferrers(Main.getLayerManager().getEditLayer(), Arrays.asList(conflict.a));
     277            DownloadReferrersAction.downloadReferrers(MainApplication.getLayerManager().getEditLayer(), Arrays.asList(conflict.a));
    278278        }
    279279    }
  • trunk/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesWithReferrersTask.java

    r12279 r12636  
    2424import org.openstreetmap.josm.data.osm.PrimitiveId;
    2525import org.openstreetmap.josm.gui.ExtendedDialog;
     26import org.openstreetmap.josm.gui.MainApplication;
    2627import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    2728import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    129130
    130131        // Append downloaded data to JOSM
    131         OsmDataLayer layer = Main.getLayerManager().getEditLayer();
     132        OsmDataLayer layer = MainApplication.getLayerManager().getEditLayer();
    132133        if (layer == null || this.newLayer)
    133             Main.getLayerManager().addLayer(tmpLayer);
     134            MainApplication.getLayerManager().addLayer(tmpLayer);
    134135        else
    135136            layer.mergeFrom(tmpLayer);
     
    152153        // Warm about deleted primitives
    153154        final Set<PrimitiveId> del = new HashSet<>();
    154         DataSet ds = Main.getLayerManager().getEditDataSet();
     155        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    155156        for (PrimitiveId id : ids) {
    156157            OsmPrimitive osm = ds.getPrimitiveById(id);
  • trunk/src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java

    r12265 r12636  
    1212import javax.swing.event.TableModelListener;
    1313
    14 import org.openstreetmap.josm.Main;
    1514import org.openstreetmap.josm.data.osm.Changeset;
     15import org.openstreetmap.josm.gui.MainApplication;
    1616import org.openstreetmap.josm.gui.tagging.TagEditorPanel;
    1717import org.openstreetmap.josm.gui.tagging.TagModel;
     
    9999     */
    100100    public void startUserInput() {
    101         pnlTagEditor.initAutoCompletion(Main.getLayerManager().getEditLayer());
     101        pnlTagEditor.initAutoCompletion(MainApplication.getLayerManager().getEditLayer());
    102102    }
    103103
  • trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java

    r12634 r12636  
    151151
    152152            new Timer(true).schedule(this, TimeUnit.SECONDS.toMillis(1), TimeUnit.SECONDS.toMillis(PROP_INTERVAL.get()));
    153             Main.getLayerManager().addAndFireLayerChangeListener(this);
     153            MainApplication.getLayerManager().addAndFireLayerChangeListener(this);
    154154        }
    155155    }
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r12630 r12636  
    889889                gpxLayer.setAssociatedFile(new File(getAssociatedFile().getParentFile(), filename));
    890890            }
    891             Main.getLayerManager().addLayer(gpxLayer);
     891            MainApplication.getLayerManager().addLayer(gpxLayer);
    892892            if (Main.pref.getBoolean("marker.makeautomarkers", true) && !gpxData.waypoints.isEmpty()) {
    893                 Main.getLayerManager().addLayer(new MarkerLayer(gpxData, tr("Converted from: {0}", getName()), null, gpxLayer));
    894             }
    895             Main.getLayerManager().removeLayer(OsmDataLayer.this);
     893                MainApplication.getLayerManager().addLayer(new MarkerLayer(gpxData, tr("Converted from: {0}", getName()), null, gpxLayer));
     894            }
     895            MainApplication.getLayerManager().removeLayer(OsmDataLayer.this);
    896896        }
    897897    }
  • trunk/src/org/openstreetmap/josm/gui/layer/ValidatorLayer.java

    r12630 r12636  
    1414import javax.swing.tree.TreeNode;
    1515
    16 import org.openstreetmap.josm.Main;
    1716import org.openstreetmap.josm.actions.RenameLayerAction;
    1817import org.openstreetmap.josm.data.Bounds;
     
    4948    public ValidatorLayer() {
    5049        super(tr("Validation errors"));
    51         Main.getLayerManager().addLayerChangeListener(this);
     50        MainApplication.getLayerManager().addLayerChangeListener(this);
    5251        MainApplication.getMap().validatorDialog.tree.addInvalidationListener(invalidator);
    5352    }
     
    175174    public synchronized void destroy() {
    176175        MainApplication.getMap().validatorDialog.tree.removeInvalidationListener(invalidator);
    177         Main.getLayerManager().removeLayerChangeListener(this);
     176        MainApplication.getLayerManager().removeLayerChangeListener(this);
    178177        super.destroy();
    179178    }
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r12630 r12636  
    182182                // If none, we'll zoom to the bounding box of the layer with the photos.
    183183                boolean boundingBoxedLayerFound = false;
    184                 for (Layer l: Main.getLayerManager().getLayers()) {
     184                for (Layer l: MainApplication.getLayerManager().getLayers()) {
    185185                    if (l != yLayer) {
    186186                        BoundingXYVisitor bbox = new BoundingXYVisitor();
     
    544544    public void actionPerformed(ActionEvent ae) {
    545545        // Construct the list of loaded GPX tracks
    546         Collection<Layer> layerLst = Main.getLayerManager().getLayers();
     546        Collection<Layer> layerLst = MainApplication.getLayerManager().getLayers();
    547547        GpxDataWrapper defaultItem = null;
    548548        for (Layer cur : layerLst) {
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r12634 r12636  
    294294            }
    295295            if (layer != null) {
    296                 Main.getLayerManager().addLayer(layer);
     296                MainApplication.getLayerManager().addLayer(layer);
    297297
    298298                if (!canceled && layer.data != null && !layer.data.isEmpty()) {
     
    888888    private void clearOtherCurrentPhotos() {
    889889        for (GeoImageLayer layer:
    890                  Main.getLayerManager().getLayersOfType(GeoImageLayer.class)) {
     890                 MainApplication.getLayerManager().getLayersOfType(GeoImageLayer.class)) {
    891891            if (layer != this) {
    892892                layer.clearCurrentPhoto(false);
     
    992992        mapModeListener.mapModeChange(null, MainApplication.getMap().mapMode);
    993993
    994         Main.getLayerManager().addActiveLayerChangeListener(e -> {
    995             if (Main.getLayerManager().getActiveLayer() == this) {
     994        MainApplication.getLayerManager().addActiveLayerChangeListener(e -> {
     995            if (MainApplication.getLayerManager().getActiveLayer() == this) {
    996996                // only in select mode it is possible to click the images
    997997                MainApplication.getMap().selectSelectTool(false);
     
    999999        });
    10001000
    1001         Main.getLayerManager().addLayerChangeListener(new LayerChangeListener() {
     1001        MainApplication.getLayerManager().addLayerChangeListener(new LayerChangeListener() {
    10021002            @Override
    10031003            public void layerAdded(LayerAddEvent e) {
     
    10191019                    data = null;
    10201020                    // stop listening to layer change events
    1021                     Main.getLayerManager().removeLayerChangeListener(this);
     1021                    MainApplication.getLayerManager().removeLayerChangeListener(this);
    10221022                }
    10231023            }
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java

    r12630 r12636  
    8484        tr("Tool: {0}", tr("Display geotagged images")), KeyEvent.VK_Y, Shortcut.DIRECT), 200);
    8585        build();
    86         Main.getLayerManager().addActiveLayerChangeListener(this);
    87         Main.getLayerManager().addLayerChangeListener(this);
     86        MainApplication.getLayerManager().addActiveLayerChangeListener(this);
     87        MainApplication.getLayerManager().addLayerChangeListener(this);
    8888    }
    8989
     
    205205    @Override
    206206    public void destroy() {
    207         Main.getLayerManager().removeActiveLayerChangeListener(this);
    208         Main.getLayerManager().removeLayerChangeListener(this);
     207        MainApplication.getLayerManager().removeActiveLayerChangeListener(this);
     208        MainApplication.getLayerManager().removeLayerChangeListener(this);
    209209        super.destroy();
    210210    }
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerAction.java

    r12620 r12636  
    2929import org.openstreetmap.josm.data.osm.Way;
    3030import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
     31import org.openstreetmap.josm.gui.MainApplication;
    3132import org.openstreetmap.josm.gui.layer.GpxLayer;
    3233import org.openstreetmap.josm.gui.layer.Layer;
     
    166167        }
    167168        osmLayer.setUploadDiscouraged(true);
    168         Main.getLayerManager().addLayer(osmLayer);
    169         Main.getLayerManager().removeLayer(layer);
     169        MainApplication.getLayerManager().addLayer(osmLayer);
     170        MainApplication.getLayerManager().removeLayer(layer);
    170171    }
    171172}
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackAction.java

    r12634 r12636  
    116116    @SuppressWarnings({ "rawtypes", "unchecked" })
    117117    protected AbstractTileSourceLayer<? extends AbstractTMSTileSource> askedLayer() {
    118         List<AbstractTileSourceLayer> targetLayers = Main.getLayerManager().getLayersOfType(AbstractTileSourceLayer.class);
     118        List<AbstractTileSourceLayer> targetLayers = MainApplication.getLayerManager().getLayersOfType(AbstractTileSourceLayer.class);
    119119        if (targetLayers.isEmpty()) {
    120120            if (!GraphicsEnvironment.isHeadless()) {
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java

    r12630 r12636  
    115115                importAudio(file, ml, firstStartTime, m);
    116116            }
    117             Main.getLayerManager().addLayer(ml);
     117            MainApplication.getLayerManager().addLayer(ml);
    118118            MainApplication.getMap().repaint();
    119119        }
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/MarkersFromNamedPointsAction.java

    r12377 r12636  
    99import javax.swing.AbstractAction;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.data.gpx.GpxData;
     12import org.openstreetmap.josm.gui.MainApplication;
    1313import org.openstreetmap.josm.gui.layer.GpxLayer;
    1414import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
     
    3939        MarkerLayer ml = new MarkerLayer(namedTrackPoints, tr("Named Trackpoints from {0}", layer.getName()), layer.getAssociatedFile(), layer);
    4040        if (!ml.data.isEmpty()) {
    41             Main.getLayerManager().addLayer(ml);
     41            MainApplication.getLayerManager().addLayer(ml);
    4242        }
    4343    }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r12630 r12636  
    417417            return;
    418418        Marker m = null;
    419         Layer l = Main.getLayerManager().getActiveLayer();
     419        Layer l = MainApplication.getLayerManager().getActiveLayer();
    420420        if (l != null) {
    421421            m = getAdjacentMarker(startMarker, next, l);
    422422        }
    423423        if (m == null) {
    424             for (Layer layer : Main.getLayerManager().getLayers()) {
     424            for (Layer layer : MainApplication.getLayerManager().getLayers()) {
    425425                m = getAdjacentMarker(startMarker, next, layer);
    426426                if (m != null) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintMenu.java

    r12630 r12636  
    1212import javax.swing.JMenu;
    1313
    14 import org.openstreetmap.josm.Main;
    1514import org.openstreetmap.josm.actions.JosmAction;
    1615import org.openstreetmap.josm.gui.MainApplication;
     
    6766        @Override
    6867        public void updateEnabledState() {
    69             setEnabled(MainApplication.isDisplayingMapView() && (Main.getLayerManager().getEditLayer() != null || mapHasGpxorMarkerLayer()));
     68            setEnabled(MainApplication.isDisplayingMapView()
     69                    && (MainApplication.getLayerManager().getEditLayer() != null || mapHasGpxorMarkerLayer()));
    7070        }
    7171
    7272        private static boolean mapHasGpxorMarkerLayer() {
    73             for (Layer layer : Main.getLayerManager().getLayers()) {
     73            for (Layer layer : MainApplication.getLayerManager().getLayers()) {
    7474                if (layer instanceof GpxLayer || layer instanceof MarkerLayer) {
    7575                    return true;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r12634 r12636  
    426426
    427427            // Trigger a repaint of all data layers
    428             Main.getLayerManager().getLayers()
     428            MainApplication.getLayerManager().getLayers()
    429429                .stream()
    430430                .filter(layer -> layer instanceof OsmDataLayer)
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r12620 r12636  
    4545import org.openstreetmap.josm.data.osm.Tag;
    4646import org.openstreetmap.josm.gui.ExtendedDialog;
     47import org.openstreetmap.josm.gui.MainApplication;
    4748import org.openstreetmap.josm.gui.Notification;
    4849import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
     
    128129     */
    129130    public TaggingPreset() {
    130         Main.getLayerManager().addActiveLayerChangeListener(this);
     131        MainApplication.getLayerManager().addActiveLayerChangeListener(this);
    131132        updateEnabledState();
    132133    }
     
    380381            return;
    381382        }
    382         DataSet ds = Main.getLayerManager().getEditDataSet();
     383        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    383384        Collection<OsmPrimitive> participants = Collections.emptyList();
    384385        if (Main.main != null && ds != null) {
     
    411412                members.add(rm);
    412413            }
    413             SwingUtilities.invokeLater(() -> RelationEditor.getEditor(Main.getLayerManager().getEditLayer(), r, members).setVisible(true));
     414            SwingUtilities.invokeLater(() -> RelationEditor.getEditor(
     415                    MainApplication.getLayerManager().getEditLayer(), r, members).setVisible(true));
    414416        }
    415417        ds.setSelected(ds.getSelected()); // force update
     
    553555
    554556    protected final void updateEnabledState() {
    555         setEnabled(Main.main != null && Main.getLayerManager().getEditDataSet() != null);
     557        setEnabled(Main.main != null && MainApplication.getLayerManager().getEditDataSet() != null);
    556558    }
    557559
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java

    r12620 r12636  
    2020import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2121import org.openstreetmap.josm.data.osm.Tag;
     22import org.openstreetmap.josm.gui.MainApplication;
    2223import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2324import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
     
    4243    protected void initAutoCompletionField(AutoCompletingTextField field, List<String> keys) {
    4344        if (Main.main == null) return;
    44         OsmDataLayer layer = Main.getLayerManager().getEditLayer();
     45        OsmDataLayer layer = MainApplication.getLayerManager().getEditLayer();
    4546        if (layer == null) {
    4647            return;
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSearchAction.java

    r10453 r12636  
    99import org.openstreetmap.josm.Main;
    1010import org.openstreetmap.josm.actions.JosmAction;
     11import org.openstreetmap.josm.gui.MainApplication;
    1112import org.openstreetmap.josm.tools.Shortcut;
    1213
     
    3031    public void actionPerformed(ActionEvent e) {
    3132
    32         if (Main.getLayerManager().getEditLayer() == null)
     33        if (MainApplication.getLayerManager().getEditLayer() == null)
    3334            return;
    3435
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSearchPrimitiveDialog.java

    r12279 r12636  
    1313import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1414import org.openstreetmap.josm.gui.ExtendedDialog;
     15import org.openstreetmap.josm.gui.MainApplication;
    1516import org.openstreetmap.josm.tools.Shortcut;
    1617
     
    4344        @Override
    4445        public void actionPerformed(ActionEvent e) {
    45             if (Main.getLayerManager().getEditLayer() != null) {
     46            if (MainApplication.getLayerManager().getEditLayer() != null) {
    4647                TaggingPresetSearchPrimitiveDialog.getInstance().showDialog();
    4748            }
     
    8687            TaggingPreset preset = selector.getSelectedPresetAndUpdateClassification();
    8788            if (preset != null) {
    88                 final Set<OsmPrimitive> matching = new HashSet<>(Main.getLayerManager().getEditDataSet().getPrimitives(preset));
    89                 Main.getLayerManager().getEditDataSet().setSelected(matching);
     89                final Set<OsmPrimitive> matching = new HashSet<>(MainApplication.getLayerManager().getEditDataSet().getPrimitives(preset));
     90                MainApplication.getLayerManager().getEditDataSet().setSelected(matching);
    9091            }
    9192        }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java

    r11747 r12636  
    3838import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3939import org.openstreetmap.josm.data.preferences.BooleanProperty;
     40import org.openstreetmap.josm.gui.MainApplication;
    4041import org.openstreetmap.josm.gui.tagging.presets.items.ComboMultiSelect;
    4142import org.openstreetmap.josm.gui.tagging.presets.items.Key;
     
    235236        boolean inTags = ckSearchInTags != null && ckSearchInTags.isSelected();
    236237
    237         DataSet ds = Main.getLayerManager().getEditDataSet();
     238        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    238239        Collection<OsmPrimitive> selected = (ds == null) ? Collections.<OsmPrimitive>emptyList() : ds.getSelected();
    239240        final List<PresetClassification> result = classifications.getMatchingPresets(
     
    355356                typesInSelectionDirty = false;
    356357                typesInSelection.clear();
    357                 if (Main.main == null || Main.getLayerManager().getEditDataSet() == null) return typesInSelection;
    358                 for (OsmPrimitive primitive : Main.getLayerManager().getEditDataSet().getSelected()) {
     358                if (Main.main == null || MainApplication.getLayerManager().getEditDataSet() == null) return typesInSelection;
     359                for (OsmPrimitive primitive : MainApplication.getLayerManager().getEditDataSet().getSelected()) {
    359360                    typesInSelection.add(TaggingPresetType.forPrimitive(primitive));
    360361                }
  • trunk/src/org/openstreetmap/josm/gui/util/HighlightHelper.java

    r11038 r12636  
    88import java.util.Set;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.osm.DataSet;
    1211import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1312import org.openstreetmap.josm.data.osm.Relation;
     13import org.openstreetmap.josm.gui.MainApplication;
    1414
    1515/**
     
    122122     */
    123123    public void findAllHighlighted() {
    124         DataSet ds = Main.getLayerManager().getEditDataSet();
     124        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    125125        if (ds != null) {
    126126            highlightedPrimitives.addAll(ds.allNonDeletedPrimitives());
     
    132132     */
    133133    public static void clearAllHighlighted() {
    134         DataSet ds = Main.getLayerManager().getEditDataSet();
     134        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    135135        if (ds != null) {
    136136            for (OsmPrimitive p: ds.allNonDeletedPrimitives()) {
  • trunk/src/org/openstreetmap/josm/gui/widgets/OsmPrimitivesTable.java

    r10454 r12636  
    1010import javax.swing.table.TableColumnModel;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.actions.ZoomToAction;
    1413import org.openstreetmap.josm.data.osm.OsmPrimitive;
     14import org.openstreetmap.josm.gui.MainApplication;
    1515import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1616
     
    9494     */
    9595    public void registerListeners() {
    96         Main.getLayerManager().addLayerChangeListener(zoomToAction);
    97         Main.getLayerManager().addActiveLayerChangeListener(zoomToAction);
     96        MainApplication.getLayerManager().addLayerChangeListener(zoomToAction);
     97        MainApplication.getLayerManager().addActiveLayerChangeListener(zoomToAction);
    9898    }
    9999
     
    103103     */
    104104    public void unregisterListeners() {
    105         Main.getLayerManager().removeLayerChangeListener(zoomToAction);
    106         Main.getLayerManager().removeActiveLayerChangeListener(zoomToAction);
     105        MainApplication.getLayerManager().removeLayerChangeListener(zoomToAction);
     106        MainApplication.getLayerManager().removeActiveLayerChangeListener(zoomToAction);
    107107    }
    108108
  • trunk/src/org/openstreetmap/josm/io/GpxExporter.java

    r12620 r12636  
    2828import org.openstreetmap.josm.data.gpx.GpxData;
    2929import org.openstreetmap.josm.gui.ExtendedDialog;
     30import org.openstreetmap.josm.gui.MainApplication;
    3031import org.openstreetmap.josm.gui.layer.GpxLayer;
    3132import org.openstreetmap.josm.gui.layer.Layer;
     
    172173            gpxData = ((GpxLayer) layer).data;
    173174        } else {
    174             gpxData = OsmDataLayer.toGpxData(Main.getLayerManager().getEditDataSet(), file);
     175            gpxData = OsmDataLayer.toGpxData(MainApplication.getLayerManager().getEditDataSet(), file);
    175176        }
    176177
  • trunk/src/org/openstreetmap/josm/io/GpxImporter.java

    r12620 r12636  
    1313import org.openstreetmap.josm.actions.ExtensionFileFilter;
    1414import org.openstreetmap.josm.data.gpx.GpxData;
     15import org.openstreetmap.josm.gui.MainApplication;
    1516import org.openstreetmap.josm.gui.layer.GpxLayer;
    1617import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
     
    120121        GuiHelper.runInEDT(() -> {
    121122            if (data.markerLayer != null) {
    122                 Main.getLayerManager().addLayer(data.markerLayer);
     123                MainApplication.getLayerManager().addLayer(data.markerLayer);
    123124            }
    124125            if (data.gpxLayer != null) {
    125                 Main.getLayerManager().addLayer(data.gpxLayer);
     126                MainApplication.getLayerManager().addLayer(data.gpxLayer);
    126127            }
    127128            data.postLayerTask.run();
  • trunk/src/org/openstreetmap/josm/io/NMEAImporter.java

    r12421 r12636  
    1414import org.openstreetmap.josm.actions.ExtensionFileFilter;
    1515import org.openstreetmap.josm.gui.HelpAwareOptionPane;
     16import org.openstreetmap.josm.gui.MainApplication;
    1617import org.openstreetmap.josm.gui.Notification;
    1718import org.openstreetmap.josm.gui.layer.GpxLayer;
     
    5253
    5354                GuiHelper.runInEDT(() -> {
    54                     Main.getLayerManager().addLayer(gpxLayer);
     55                    MainApplication.getLayerManager().addLayer(gpxLayer);
    5556                    if (Main.pref.getBoolean("marker.makeautomarkers", true)) {
    5657                        MarkerLayer ml = new MarkerLayer(r.data, tr("Markers from {0}", fn), fileFinal, gpxLayer);
    5758                        if (!ml.data.isEmpty()) {
    58                             Main.getLayerManager().addLayer(ml);
     59                            MainApplication.getLayerManager().addLayer(ml);
    5960                        }
    6061                    }
  • trunk/src/org/openstreetmap/josm/io/NoteImporter.java

    r12630 r12636  
    99import java.util.List;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.actions.ExtensionFileFilter;
    1312import org.openstreetmap.josm.data.notes.Note;
     
    3938        try (InputStream is = Compression.getUncompressedFileInputStream(file)) {
    4039            final NoteLayer layer = loadLayer(is, file, file.getName(), progressMonitor);
    41             if (!Main.getLayerManager().containsLayer(layer)) {
    42                 Main.getLayerManager().addLayer(layer);
     40            if (!MainApplication.getLayerManager().containsLayer(layer)) {
     41                MainApplication.getLayerManager().addLayer(layer);
    4342            }
    4443        } catch (SAXException e) {
     
    6564        List<NoteLayer> noteLayers = null;
    6665        if (MainApplication.getMap() != null) {
    67             noteLayers = Main.getLayerManager().getLayersOfType(NoteLayer.class);
     66            noteLayers = MainApplication.getLayerManager().getLayersOfType(NoteLayer.class);
    6867        }
    6968        final NoteLayer layer;
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r12630 r12636  
    243243             * been disabled! */
    244244            if (MainApplication.isDisplayingMapView()) {
    245                 for (Layer l : Main.getLayerManager().getLayersOfType(ImageryLayer.class)) {
     245                for (Layer l : MainApplication.getLayerManager().getLayersOfType(ImageryLayer.class)) {
    246246                    if (((ImageryLayer) l).getInfo().isBlacklisted()) {
    247247                        Logging.info(tr("Removed layer {0} because it is not allowed by the configured API.", l.getName()));
    248                         Main.getLayerManager().removeLayer(l);
     248                        MainApplication.getLayerManager().removeLayer(l);
    249249                    }
    250250                }
  • trunk/src/org/openstreetmap/josm/io/OsmChangeImporter.java

    r12620 r12636  
    1414import org.openstreetmap.josm.actions.ExtensionFileFilter;
    1515import org.openstreetmap.josm.data.osm.DataSet;
     16import org.openstreetmap.josm.gui.MainApplication;
    1617import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1718import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    6667                        JOptionPane.INFORMATION_MESSAGE);
    6768            }
    68             Main.getLayerManager().addLayer(layer);
     69            MainApplication.getLayerManager().addLayer(layer);
    6970            layer.onPostLoadFromFile();
    7071        });
  • trunk/src/org/openstreetmap/josm/io/OsmImporter.java

    r12620 r12636  
    1515import org.openstreetmap.josm.actions.ExtensionFileFilter;
    1616import org.openstreetmap.josm.data.osm.DataSet;
     17import org.openstreetmap.josm.gui.MainApplication;
    1718import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1819import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    99100        GuiHelper.runInEDT(() -> {
    100101            OsmDataLayer layer = data.getLayer();
    101             Main.getLayerManager().addLayer(layer);
     102            MainApplication.getLayerManager().addLayer(layer);
    102103            data.getPostLayerTask().run();
    103104            data.getLayer().onPostLoadFromFile();
  • trunk/src/org/openstreetmap/josm/io/WMSLayerImporter.java

    r12630 r12636  
    1111import java.util.Map;
    1212
    13 import org.openstreetmap.josm.Main;
    1413import org.openstreetmap.josm.actions.ExtensionFileFilter;
    1514import org.openstreetmap.josm.data.Preferences;
     
    8786        // FIXME: remove UI stuff from IO subsystem
    8887        GuiHelper.runInEDT(() -> {
    89             Main.getLayerManager().addLayer(layer);
     88            MainApplication.getLayerManager().addLayer(layer);
    9089            if (zoomTo != null) {
    9190                MainApplication.getMap().mapView.zoomTo(zoomTo);
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java

    r12542 r12636  
    3232import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3333import org.openstreetmap.josm.gui.ExtendedDialog;
     34import org.openstreetmap.josm.gui.MainApplication;
    3435import org.openstreetmap.josm.gui.util.GuiHelper;
    3536import org.openstreetmap.josm.gui.util.TableHelper;
     
    251252    protected void buttonAction(int buttonIndex, ActionEvent evt) {
    252253        // if layer all layers were closed, ignore all actions
    253         if (buttonIndex != 2 && Main.getLayerManager().getEditDataSet() != null) {
     254        if (buttonIndex != 2 && MainApplication.getLayerManager().getEditDataSet() != null) {
    254255            TableModel tm = propertyTable.getModel();
    255256            for (int i = 0; i < tm.getRowCount(); i++) {
     
    309310    public static void addTags(String[][] keyValue, String sender, Collection<? extends OsmPrimitive> primitives) {
    310311        if (trustedSenders.contains(sender)) {
    311             if (Main.getLayerManager().getEditDataSet() != null) {
     312            if (MainApplication.getLayerManager().getEditDataSet() != null) {
    312313                for (String[] row : keyValue) {
    313314                    Main.main.undoRedo.add(new ChangePropertyCommand(primitives, row[0], row[1]));
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java

    r12630 r12636  
    102102        }
    103103
    104         Main.getLayerManager().getEditDataSet().setSelected(node);
     104        MainApplication.getLayerManager().getEditDataSet().setSelected(node);
    105105        if (PermissionPrefWithDefault.CHANGE_VIEWPORT.isAllowed()) {
    106106            AutoScaleAction.autoScale("selection");
     
    120120            throw new RequestHandlerBadRequestException("NumberFormatException ("+e.getMessage()+')', e);
    121121        }
    122         if (Main.getLayerManager().getEditLayer() == null) {
     122        if (MainApplication.getLayerManager().getEditLayer() == null) {
    123123             throw new RequestHandlerBadRequestException(tr("There is no layer opened to add node"));
    124124        }
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java

    r12630 r12636  
    111111            throw new RequestHandlerBadRequestException(tr("One node ways"));
    112112        }
    113         if (Main.getLayerManager().getEditLayer() == null) {
     113        if (MainApplication.getLayerManager().getEditLayer() == null) {
    114114             throw new RequestHandlerBadRequestException(tr("There is no layer opened to add way"));
    115115        }
     
    168168        commands.add(new AddCommand(way));
    169169        Main.main.undoRedo.add(new SequenceCommand(tr("Add way"), commands));
    170         Main.getLayerManager().getEditDataSet().setSelected(way);
     170        MainApplication.getLayerManager().getEditDataSet().setSelected(way);
    171171        if (PermissionPrefWithDefault.CHANGE_VIEWPORT.isAllowed()) {
    172172            AutoScaleAction.autoScale("selection");
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java

    r12630 r12636  
    66import java.util.Arrays;
    77
    8 import org.openstreetmap.josm.Main;
    98import org.openstreetmap.josm.data.imagery.ImageryInfo;
    109import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
     
    9796        final ImageryInfo imgInfo = buildImageryInfo();
    9897        if (MainApplication.isDisplayingMapView()) {
    99             for (ImageryLayer layer : Main.getLayerManager().getLayersOfType(ImageryLayer.class)) {
     98            for (ImageryLayer layer : MainApplication.getLayerManager().getLayersOfType(ImageryLayer.class)) {
    10099                if (layer.getInfo().equals(imgInfo)) {
    101100                    Logging.info("Imagery layer already exists: "+imgInfo);
     
    106105        GuiHelper.runInEDT(() -> {
    107106            try {
    108                 Main.getLayerManager().addLayer(ImageryLayer.create(imgInfo));
     107                MainApplication.getLayerManager().addLayer(ImageryLayer.create(imgInfo));
    109108            } catch (IllegalArgumentException e) {
    110109                Logging.log(Logging.LEVEL_ERROR, e);
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r12634 r12636  
    1212import java.util.concurrent.Future;
    1313
    14 import org.openstreetmap.josm.Main;
    1514import org.openstreetmap.josm.actions.AutoScaleAction;
    1615import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
     
    123122                        // find out whether some data has already been downloaded
    124123                        Area present = null;
    125                         DataSet ds = Main.getLayerManager().getEditDataSet();
     124                        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    126125                        if (ds != null) {
    127126                            present = ds.getDataSourceArea();
     
    160159        if (args.containsKey("addtags")) {
    161160            GuiHelper.executeByMainWorkerInEDT(() -> {
    162                 DataSet ds = Main.getLayerManager().getEditDataSet();
     161                DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    163162                if (ds == null) // e.g. download failed
    164163                    return;
     
    173172            GuiHelper.executeByMainWorkerInEDT(() -> {
    174173                Set<OsmPrimitive> newSel = new HashSet<>();
    175                 DataSet ds = Main.getLayerManager().getEditDataSet();
     174                DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    176175                if (ds == null) // e.g. download failed
    177176                    return;
     
    197196                final SearchCompiler.Match search = SearchCompiler.compile(args.get("search"));
    198197                MainApplication.worker.submit(() -> {
    199                     final DataSet ds = Main.getLayerManager().getEditDataSet();
     198                    final DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    200199                    final Collection<OsmPrimitive> filteredPrimitives = SubclassFilteredCollection.filter(ds.allPrimitives(), search);
    201200                    ds.setSelected(filteredPrimitives);
     
    215214        if (args.containsKey("changeset_comment") || args.containsKey("changeset_source")) {
    216215            MainApplication.worker.submit(() -> {
    217                 if (Main.getLayerManager().getEditDataSet() != null) {
     216                if (MainApplication.getLayerManager().getEditDataSet() != null) {
    218217                    if (args.containsKey("changeset_comment")) {
    219                         Main.getLayerManager().getEditDataSet().addChangeSetTag("comment", args.get("changeset_comment"));
     218                        MainApplication.getLayerManager().getEditDataSet().addChangeSetTag("comment", args.get("changeset_comment"));
    220219                    }
    221220                    if (args.containsKey("changeset_source")) {
    222                         Main.getLayerManager().getEditDataSet().addChangeSetTag("source", args.get("changeset_source"));
     221                        MainApplication.getLayerManager().getEditDataSet().addChangeSetTag("source", args.get("changeset_source"));
    223222                    }
    224223                }
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandler.java

    r12634 r12636  
    99import java.util.List;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.data.osm.DataSet;
    1312import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    7271            MainApplication.worker.submit(() -> {
    7372                final List<PrimitiveId> downloaded = task.getDownloadedId();
    74                 final DataSet ds = Main.getLayerManager().getEditDataSet();
     73                final DataSet ds = MainApplication.getLayerManager().getEditDataSet();
    7574                if (downloaded != null) {
    7675                    GuiHelper.runInEDT(() -> ds.setSelected(downloaded));
  • trunk/src/org/openstreetmap/josm/io/session/MarkerSessionExporter.java

    r10364 r12636  
    1717import javax.swing.SwingConstants;
    1818
    19 import org.openstreetmap.josm.Main;
    2019import org.openstreetmap.josm.data.gpx.GpxData;
     20import org.openstreetmap.josm.gui.MainApplication;
    2121import org.openstreetmap.josm.gui.layer.Layer;
    2222import org.openstreetmap.josm.gui.layer.markerlayer.Marker;
     
    4444    public Collection<Layer> getDependencies() {
    4545        Layer gpxLayer = layer.fromLayer;
    46         if (gpxLayer != null && Main.getLayerManager().containsLayer(gpxLayer))
     46        if (gpxLayer != null && MainApplication.getLayerManager().containsLayer(gpxLayer))
    4747            return Collections.singleton(gpxLayer);
    4848        return Collections.emptySet();
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r12630 r12636  
    103103        }
    104104
    105         OsmDataLayer layer = Main.getLayerManager().getEditLayer();
     105        OsmDataLayer layer = MainApplication.getLayerManager().getEditLayer();
    106106        DataSet dataset = ways.get(0).getDataSet();
    107107
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java

    r12634 r12636  
    2323import org.openstreetmap.josm.Main;
    2424import org.openstreetmap.josm.actions.OpenFileAction.OpenFileTask;
     25import org.openstreetmap.josm.gui.MainApplication;
    2526import org.openstreetmap.josm.io.OsmTransferException;
    2627import org.xml.sax.SAXException;
     
    172173            break;
    173174        case "handleQuitRequestWith":
    174             boolean closed = Main.exitJosm(false, 0, null);
     175            boolean closed = MainApplication.exitJosm(false, 0, null);
    175176            if (args[1] != null) {
    176177                try {
  • trunk/test/functional/org/openstreetmap/josm/gui/mappaint/StyleCacheTest.java

    r11818 r12636  
    1717import org.junit.Rule;
    1818import org.junit.Test;
    19 import org.openstreetmap.josm.Main;
    2019import org.openstreetmap.josm.data.Bounds;
    2120import org.openstreetmap.josm.data.osm.DataSet;
     
    2322import org.openstreetmap.josm.data.osm.visitor.paint.Rendering;
    2423import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     24import org.openstreetmap.josm.gui.MainApplication;
    2525import org.openstreetmap.josm.gui.MapView;
    2626import org.openstreetmap.josm.gui.NavigatableComponent;
     
    9393        g.setColor(Color.BLACK);
    9494        g.fillRect(0, 0, IMG_WIDTH, IMG_WIDTH);
    95         nc = new MapView(Main.getLayerManager(), null);
     95        nc = new MapView(MainApplication.getLayerManager(), null);
    9696        nc.setBounds(0, 0, IMG_WIDTH, IMG_HEIGHT);
    9797    }
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r12569 r12636  
    146146    private void setupGUI() {
    147147        JOSMTestRules.cleanLayerEnvironment();
    148         assertTrue(Main.getLayerManager().getLayers().isEmpty());
    149         assertNull(Main.getLayerManager().getEditLayer());
    150         assertNull(Main.getLayerManager().getActiveLayer());
     148        assertTrue(MainApplication.getLayerManager().getLayers().isEmpty());
     149        assertNull(MainApplication.getLayerManager().getEditLayer());
     150        assertNull(MainApplication.getLayerManager().getActiveLayer());
    151151
    152152        initContentPane();
     
    163163        }
    164164        // Add a test layer to the layer manager to get the MapFrame
    165         Main.getLayerManager().addLayer(new TestLayer());
     165        MainApplication.getLayerManager().addLayer(new TestLayer());
    166166    }
    167167
     
    188188    public static void initMainPanel(boolean reAddListeners) {
    189189        if (Main.mainPanel == null) {
    190             Main.mainPanel = new MainPanel(Main.getLayerManager());
     190            Main.mainPanel = new MainPanel(MainApplication.getLayerManager());
    191191        }
    192192        if (reAddListeners) {
  • trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java

    r12562 r12636  
    1313import org.junit.Rule;
    1414import org.junit.Test;
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.TestUtils;
    1716import org.openstreetmap.josm.data.imagery.ImageryInfo;
     17import org.openstreetmap.josm.gui.MainApplication;
    1818import org.openstreetmap.josm.gui.layer.TMSLayer;
    1919import org.openstreetmap.josm.gui.layer.WMSLayer;
     
    5858    @Test
    5959    public void testActionPerformedEnabledTms() {
    60         assertTrue(Main.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty());
     60        assertTrue(MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty());
    6161        new AddImageryLayerAction(new ImageryInfo("foo_tms", "http://bar", "tms", null, null)).actionPerformed(null);
    62         List<TMSLayer> tmsLayers = Main.getLayerManager().getLayersOfType(TMSLayer.class);
     62        List<TMSLayer> tmsLayers = MainApplication.getLayerManager().getLayersOfType(TMSLayer.class);
    6363        assertEquals(1, tmsLayers.size());
    64         Main.getLayerManager().removeLayer(tmsLayers.get(0));
     64        MainApplication.getLayerManager().removeLayer(tmsLayers.get(0));
    6565    }
    6666
     
    7777        new AddImageryLayerAction(new ImageryInfo("localhost", "http://localhost:" + wireMockRule.port() + "/wms?",
    7878                "wms_endpoint", null, null)).actionPerformed(null);
    79         List<WMSLayer> wmsLayers = Main.getLayerManager().getLayersOfType(WMSLayer.class);
     79        List<WMSLayer> wmsLayers = MainApplication.getLayerManager().getLayersOfType(WMSLayer.class);
    8080        assertEquals(1, wmsLayers.size());
    8181
    82         Main.getLayerManager().removeLayer(wmsLayers.get(0));
     82        MainApplication.getLayerManager().removeLayer(wmsLayers.get(0));
    8383    }
    8484
     
    8888    @Test
    8989    public void testActionPerformedDisabled() {
    90         assertTrue(Main.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty());
     90        assertTrue(MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty());
    9191        try {
    9292            new AddImageryLayerAction(new ImageryInfo("foo")).actionPerformed(null);
     
    9494            assertEquals("Parameter 'info.url' must not be null", expected.getMessage());
    9595        }
    96         assertTrue(Main.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty());
     96        assertTrue(MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty());
    9797    }
    9898}
  • trunk/test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java

    r12632 r12636  
    1616import org.openstreetmap.josm.data.osm.Node;
    1717import org.openstreetmap.josm.data.osm.Way;
     18import org.openstreetmap.josm.gui.MainApplication;
    1819import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1920import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    6869
    6970        try {
    70             Main.getLayerManager().addLayer(layer);
     71            MainApplication.getLayerManager().addLayer(layer);
    7172
    7273            // Create an open way.
     
    7980        } finally {
    8081            // Ensure we clean the place before leaving, even if test fails.
    81             Main.getLayerManager().removeLayer(layer);
     82            MainApplication.getLayerManager().removeLayer(layer);
    8283        }
    8384
     
    109110
    110111        try {
    111             Main.getLayerManager().addLayer(layer);
     112            MainApplication.getLayerManager().addLayer(layer);
    112113
    113114            // Create a closed way.
     
    119120        } finally {
    120121            // Ensure we clean the place before leaving, even if test fails.
    121             Main.getLayerManager().removeLayer(layer);
     122            MainApplication.getLayerManager().removeLayer(layer);
    122123        }
    123124
     
    150151
    151152        try {
    152             Main.getLayerManager().addLayer(layer);
     153            MainApplication.getLayerManager().addLayer(layer);
    153154
    154155            // Create 2 ways.
     
    163164        } finally {
    164165            // Ensure we clean the place before leaving, even if test fails.
    165             Main.getLayerManager().removeLayer(layer);
     166            MainApplication.getLayerManager().removeLayer(layer);
    166167        }
    167168
  • trunk/test/unit/org/openstreetmap/josm/actions/CopyActionTest.java

    r10604 r12636  
    1717import org.junit.Rule;
    1818import org.junit.Test;
    19 import org.openstreetmap.josm.Main;
    2019import org.openstreetmap.josm.data.coor.LatLon;
    2120import org.openstreetmap.josm.data.osm.DataSet;
    2221import org.openstreetmap.josm.data.osm.Node;
    2322import org.openstreetmap.josm.data.osm.Way;
     23import org.openstreetmap.josm.gui.MainApplication;
    2424import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
    2525import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData;
     
    6666        assertTrue(action.warningShown);
    6767
    68         Main.getLayerManager().addLayer(new OsmDataLayer(new DataSet(), "test", null));
     68        MainApplication.getLayerManager().addLayer(new OsmDataLayer(new DataSet(), "test", null));
    6969        action.warningShown = false;
    7070
     
    9797        data.setSelected(way);
    9898
    99         Main.getLayerManager().addLayer(new OsmDataLayer(data, "test", null));
     99        MainApplication.getLayerManager().addLayer(new OsmDataLayer(data, "test", null));
    100100
    101101        CopyAction action = new CopyAction() {
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java

    r12632 r12636  
    1111import org.junit.Rule;
    1212import org.junit.Test;
    13 import org.openstreetmap.josm.Main;
    1413import org.openstreetmap.josm.data.coor.EastNorth;
    1514import org.openstreetmap.josm.data.coor.LatLon;
     
    1817import org.openstreetmap.josm.data.osm.Node;
    1918import org.openstreetmap.josm.data.osm.Way;
     19import org.openstreetmap.josm.gui.MainApplication;
    2020import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2121import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    6767        action.setEnabled(true);
    6868        try {
    69             Main.getLayerManager().addLayer(layer);
     69            MainApplication.getLayerManager().addLayer(layer);
    7070            action.actionPerformed(null);
    7171        } finally {
    7272            // Ensure we clean the place before leaving, even if test fails.
    73             Main.getLayerManager().removeLayer(layer);
     73            MainApplication.getLayerManager().removeLayer(layer);
    7474        }
    7575
     
    138138            action.setEnabled(true);
    139139            try {
    140                 Main.getLayerManager().addLayer(layer);
     140                MainApplication.getLayerManager().addLayer(layer);
    141141                action.actionPerformed(null);
    142142            } finally {
    143143                // Ensure we clean the place before leaving, even if test fails.
    144                 Main.getLayerManager().removeLayer(layer);
     144                MainApplication.getLayerManager().removeLayer(layer);
    145145            }
    146146
  • trunk/test/unit/org/openstreetmap/josm/actions/DeleteLayerActionTest.java

    r11101 r12636  
    77import org.junit.Rule;
    88import org.junit.Test;
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.data.osm.DataSet;