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

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

File:
1 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();
Note: See TracChangeset for help on using the changeset viewer.