Changeset 12642 in josm


Ignore:
Timestamp:
2017-08-25T03:29:37+02:00 (3 months ago)
Author:
Don-vip
Message:

see #15182 - deprecate Main.main.panel. Replacement: gui.MainApplication.getMainPanel()

Location:
trunk
Files:
6 edited

Legend:

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

    r12641 r12642  
    150150    /**
    151151     * The main panel.
     152     * @deprecated Use {@link MainApplication#getMainPanel} instead
    152153     * @since 12125
    153154     */
     155    @Deprecated
    154156    public MainPanel panel;
    155157
  • trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java

    r12637 r12642  
    198198        JMenu subMenu = Main.main.menu.imagerySubMenu;
    199199        int heightUnrolled = 30*(getItemCount()+subMenu.getItemCount());
    200         if (heightUnrolled < Main.main.panel.getHeight()) {
     200        if (heightUnrolled < MainApplication.getMainPanel().getHeight()) {
    201201            // add all items of submenu if they will fit on screen
    202202            int n = subMenu.getItemCount();
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r12641 r12642  
    136136
    137137    /**
    138      * The same panel as {@link Main#panel}, required to be static for {@link MapFrameListener} handling.
     138     * The main panel, required to be static for {@link MapFrameListener} handling.
    139139     */
    140140    static MainPanel mainPanel;
     
    165165
    166166    /**
     167     * Provides access to the layers displayed in the main view.
     168     */
     169    private static final MainLayerManager layerManager = new MainLayerManager();
     170
     171    /**
    167172     * The commands undo/redo handler.
    168173     * @since 12641 (as a replacement to {@code Main.main.undoRedo})
    169174     */
    170     public static final UndoRedoHandler undoRedo = new UndoRedoHandler();
    171 
    172     /**
    173      * Provides access to the layers displayed in the main view.
    174      */
    175     private static final MainLayerManager layerManager = new MainLayerManager();
     175    public static final UndoRedoHandler undoRedo = new UndoRedoHandler(); // Must be declared after layerManager
    176176
    177177    /**
     
    271271
    272272    @Override
     273    @SuppressWarnings("deprecation")
    273274    protected void initializeMainWindow() {
    274275        if (mainFrame != null) {
    275             panel = mainFrame.getPanel();
     276            mainPanel = mainFrame.getPanel();
     277            panel = mainPanel;
    276278            mainFrame.initialize();
    277279            menu = mainFrame.getMenu();
    278280        } else {
    279281            // required for running some tests.
    280             panel = new MainPanel(layerManager);
     282            mainPanel = new MainPanel(layerManager);
     283            panel = mainPanel;
    281284            menu = new MainMenu();
    282285        }
    283         panel.addMapFrameListener((o, n) -> redoUndoListener.commandChanged(0, 0));
    284         panel.reAddListeners();
     286        mainPanel.addMapFrameListener((o, n) -> redoUndoListener.commandChanged(0, 0));
     287        mainPanel.reAddListeners();
    285288    }
    286289
     
    365368    public static MapFrame getMap() {
    366369        return map;
     370    }
     371
     372    /**
     373     * Returns the main panel.
     374     * @return the main panel
     375     * @since 12642 (as a replacement to {@code Main.main.panel})
     376     */
     377    public static MainPanel getMainPanel() {
     378        return mainPanel;
    367379    }
    368380
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandler.java

    r12620 r12642  
    1010import java.util.Collections;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.coor.EastNorth;
    1413import org.openstreetmap.josm.data.osm.OsmPrimitive;
     14import org.openstreetmap.josm.gui.MainApplication;
    1515import org.openstreetmap.josm.gui.datatransfer.importers.AbstractOsmDataPaster;
    1616import org.openstreetmap.josm.gui.datatransfer.importers.FilePaster;
     
    7272     */
    7373    public void pasteOn(OsmDataLayer editLayer, EastNorth mPosition, Transferable transferable) {
    74         importData(new TransferSupport(Main.main.panel, transferable), editLayer, mPosition);
     74        importData(new TransferSupport(MainApplication.getMainPanel(), transferable), editLayer, mPosition);
    7575    }
    7676
     
    8181    public void pasteTags(Collection<? extends OsmPrimitive> primitives) {
    8282        Transferable transferable = ClipboardUtils.getClipboardContent();
    83         importTags(new TransferSupport(Main.main.panel, transferable), primitives);
     83        importTags(new TransferSupport(MainApplication.getMainPanel(), transferable), primitives);
    8484    }
    8585
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r12639 r12642  
    140140    }
    141141
     142    @SuppressWarnings("deprecation")
    142143    private void setupGUI() {
    143144        JOSMTestRules.cleanLayerEnvironment();
     
    154155            if (Main.main.panel == null) {
    155156                initMainPanel(false);
    156                 Main.main.panel = MainApplicationTest.getMainPanel();
     157                Main.main.panel = MainApplication.getMainPanel();
    157158            }
    158159            Main.main.panel.reAddListeners();
  • trunk/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java

    r12639 r12642  
    8080     * @param reAddListeners {@code true} to re-add listeners
    8181     */
     82    @SuppressWarnings("deprecation")
    8283    public static void initMainPanel(boolean reAddListeners) {
    8384        if (MainApplication.mainPanel == null) {
     
    9091            Main.main.panel = MainApplication.mainPanel;
    9192        }
    92     }
    93 
    94     /**
    95      * Returns {@link MainApplication#mainPanel} (not public).
    96      * @return {@link MainApplication#mainPanel}
    97      */
    98     public static MainPanel getMainPanel() {
    99         return MainApplication.mainPanel;
    10093    }
    10194
Note: See TracChangeset for help on using the changeset viewer.