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

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

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
59 edited

Legend:

Unmodified
Added
Removed
  • 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        }
Note: See TracChangeset for help on using the changeset viewer.