Ignore:
Timestamp:
2017-05-12T01:28:59+02:00 (3 years ago)
Author:
Don-vip
Message:

see #14741 - rework initialization of Main.Panel so that it is done after PlatformHook.preStartupHook, as any other Swing code

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
4 edited

Legend:

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

    r11654 r12125  
    198198        JMenu subMenu = Main.main.menu.imagerySubMenu;
    199199        int heightUnrolled = 30*(getItemCount()+subMenu.getItemCount());
    200         if (heightUnrolled < Main.panel.getHeight()) {
     200        if (heightUnrolled < Main.main.panel.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

    r11925 r12125  
    8888    private static final List<String> COMMAND_LINE_ARGS = new ArrayList<>();
    8989
    90     private MainFrame mainFrame;
     90    private final MainFrame mainFrame;
    9191
    9292    /**
     
    109109    @Override
    110110    protected void initializeMainWindow() {
    111         mainPanel.reAddListeners();
    112111        if (mainFrame != null) {
     112            mainFrame.preInitialize();
     113            panel = mainFrame.getPanel();
    113114            mainFrame.initialize();
    114 
    115115            menu = mainFrame.getMenu();
    116116        } else {
    117117            // required for running some tests.
     118            panel = new MainPanel(Main.getLayerManager());
    118119            menu = new MainMenu();
    119120        }
     121        panel.addMapFrameListener((o, n) -> redoUndoListener.commandChanged(0, 0));
     122        panel.reAddListeners();
    120123    }
    121124
  • trunk/src/org/openstreetmap/josm/gui/MainFrame.java

    r11905 r12125  
    4949    protected transient WindowGeometry geometry;
    5050    protected int windowState = JFrame.NORMAL;
     51    private MainPanel panel;
    5152    private MainMenu menu;
    5253
     
    7172
    7273    /**
     74     * Performs pre-initialization required before the call to {@link #initialize()}.
     75     * @since 12125
     76     */
     77    public void preInitialize() {
     78        panel = new MainPanel(Main.getLayerManager());
     79    }
     80
     81    /**
    7382     * Initializes the content of the window and get the current status panel.
     83     * {@link #preInitialize()} must have been previously called.
    7484     */
    7585    public void initialize() {
     
    98108        refreshTitle();
    99109
    100         getContentPane().add(Main.panel, BorderLayout.CENTER);
     110        getContentPane().add(panel, BorderLayout.CENTER);
    101111        menu.initialize();
    102112    }
     
    115125     * Gets the main menu used for this window.
    116126     * @return The main menu.
     127     * @throws IllegalStateException if the main frame has not been initialized yet
     128     * @see #initialize
    117129     */
    118130    public MainMenu getMenu() {
     
    121133        }
    122134        return menu;
     135    }
     136
     137    /**
     138     * Gets the main panel.
     139     * @return The main panel.
     140     * @throws IllegalStateException if the main frame has not been initialized yet
     141     * @see #initialize
     142     * @since 12125
     143     */
     144    public MainPanel getPanel() {
     145        if (panel == null) {
     146            throw new IllegalStateException("Not initialized.");
     147        }
     148        return panel;
    123149    }
    124150
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandler.java

    r11746 r12125  
    7171     */
    7272    public void pasteOn(OsmDataLayer editLayer, EastNorth mPosition, Transferable transferable) {
    73         importData(new TransferSupport(Main.panel, transferable), editLayer, mPosition);
     73        importData(new TransferSupport(Main.main.panel, transferable), editLayer, mPosition);
    7474    }
    7575
     
    8080    public void pasteTags(Collection<? extends OsmPrimitive> primitives) {
    8181        Transferable transferable = ClipboardUtils.getClipboardContent();
    82         importTags(new TransferSupport(Main.panel, transferable), primitives);
     82        importTags(new TransferSupport(Main.main.panel, transferable), primitives);
    8383    }
    8484
Note: See TracChangeset for help on using the changeset viewer.