This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 192352
Collapse All | Expand All

(-)a/core.windows/manifest.mf (-1 / +1 lines)
Lines 6-10 Link Here
6
OpenIDE-Module-Recommends: org.netbeans.core.windows.nativeaccess.NativeWindowSystem
6
OpenIDE-Module-Recommends: org.netbeans.core.windows.nativeaccess.NativeWindowSystem
7
AutoUpdate-Show-In-Client: false
7
AutoUpdate-Show-In-Client: false
8
AutoUpdate-Essential-Module: true
8
AutoUpdate-Essential-Module: true
9
OpenIDE-Module-Specification-Version: 2.23
9
OpenIDE-Module-Specification-Version: 2.24
10
10
(-)a/core.windows/src/org/netbeans/core/windows/actions/ResetWindowsAction.java (-4 / +6 lines)
Lines 79-84 Link Here
79
@ActionReference(position = 3000, path = "Menu/Window")
79
@ActionReference(position = 3000, path = "Menu/Window")
80
public class ResetWindowsAction implements ActionListener {
80
public class ResetWindowsAction implements ActionListener {
81
    
81
    
82
    @Override
82
    public void actionPerformed(ActionEvent e) {
83
    public void actionPerformed(ActionEvent e) {
83
        final WindowSystem ws = Lookup.getDefault().lookup( WindowSystem.class );
84
        final WindowSystem ws = Lookup.getDefault().lookup( WindowSystem.class );
84
        if( null == ws ) {
85
        if( null == ws ) {
Lines 90-99 Link Here
90
        
91
        
91
        final WindowManagerImpl wm = WindowManagerImpl.getInstance();
92
        final WindowManagerImpl wm = WindowManagerImpl.getInstance();
92
        
93
        
93
        if( wm.getMainWindow() instanceof MainWindow ) {
94
        //cancel full-screen mode
94
            //cancel full-screen mode
95
        MainWindow.getInstance().setFullScreenMode(false);
95
            ((MainWindow) wm.getMainWindow()).setFullScreenMode( false );
96
        }
97
        
96
        
98
        wm.getMainWindow().setExtendedState( JFrame.NORMAL );
97
        wm.getMainWindow().setExtendedState( JFrame.NORMAL );
99
98
Lines 116-121 Link Here
116
        wm.deselectEditorTopComponents();
115
        wm.deselectEditorTopComponents();
117
        
116
        
118
        SwingUtilities.invokeLater( new Runnable() {
117
        SwingUtilities.invokeLater( new Runnable() {
118
            @Override
119
            public void run() {
119
            public void run() {
120
                //find the local folder that must be deleted
120
                //find the local folder that must be deleted
121
                FileObject rootFolder = FileUtil.getConfigFile( PersistenceManager.ROOT_LOCAL_FOLDER );
121
                FileObject rootFolder = FileUtil.getConfigFile( PersistenceManager.ROOT_LOCAL_FOLDER );
Lines 150-155 Link Here
150
                    editorMode.addOpenedTopComponentNoNotify(editors[i]);
150
                    editorMode.addOpenedTopComponentNoNotify(editors[i]);
151
                }
151
                }
152
                SwingUtilities.invokeLater( new Runnable() {
152
                SwingUtilities.invokeLater( new Runnable() {
153
                    @Override
153
                    public void run() {
154
                    public void run() {
154
                        Frame mainWindow = wm.getMainWindow();
155
                        Frame mainWindow = wm.getMainWindow();
155
                        mainWindow.invalidate();
156
                        mainWindow.invalidate();
Lines 159-164 Link Here
159
                //activate some editor window
160
                //activate some editor window
160
                if( null != activeEditor ) {
161
                if( null != activeEditor ) {
161
                    SwingUtilities.invokeLater( new Runnable() {
162
                    SwingUtilities.invokeLater( new Runnable() {
163
                        @Override
162
                        public void run() {
164
                        public void run() {
163
                            activeEditor.requestActive();
165
                            activeEditor.requestActive();
164
                        }
166
                        }
(-)a/core.windows/src/org/netbeans/core/windows/actions/ToggleFullScreenAction.java (-5 / +10 lines)
Lines 74-79 Link Here
74
    public ToggleFullScreenAction() {
74
    public ToggleFullScreenAction() {
75
        addPropertyChangeListener( new PropertyChangeListener() {
75
        addPropertyChangeListener( new PropertyChangeListener() {
76
76
77
            @Override
77
            public void propertyChange(PropertyChangeEvent evt) {
78
            public void propertyChange(PropertyChangeEvent evt) {
78
                if( Action.ACCELERATOR_KEY.equals(evt.getPropertyName()) ) {
79
                if( Action.ACCELERATOR_KEY.equals(evt.getPropertyName()) ) {
79
                    synchronized( ToggleFullScreenAction.this ) {
80
                    synchronized( ToggleFullScreenAction.this ) {
Lines 86-97 Link Here
86
        });
87
        });
87
    }
88
    }
88
    
89
    
90
    @Override
89
    public JComponent[] getMenuPresenters() {
91
    public JComponent[] getMenuPresenters() {
90
        createItems();
92
        createItems();
91
        updateState();
93
        updateState();
92
        return menuItems;
94
        return menuItems;
93
    }
95
    }
94
96
97
    @Override
95
    public JComponent[] synchMenuPresenters(JComponent[] items) {
98
    public JComponent[] synchMenuPresenters(JComponent[] items) {
96
        updateState();
99
        updateState();
97
        return menuItems;
100
        return menuItems;
Lines 112-119 Link Here
112
        synchronized( this ) {
115
        synchronized( this ) {
113
            createItems();
116
            createItems();
114
            menuItems[0].setSelected(null != frame 
117
            menuItems[0].setSelected(null != frame 
115
                    && (frame instanceof MainWindow)
118
                    && MainWindow.getInstance().isFullScreenMode());
116
                    && ((MainWindow)frame).isFullScreenMode());
117
        }
119
        }
118
    }
120
    }
119
    
121
    
Lines 129-150 Link Here
129
    }
131
    }
130
132
131
    /** Perform the action. Sets/unsets maximzed mode. */
133
    /** Perform the action. Sets/unsets maximzed mode. */
134
    @Override
132
    public void actionPerformed(java.awt.event.ActionEvent ev) {
135
    public void actionPerformed(java.awt.event.ActionEvent ev) {
133
        MainWindow frame = (MainWindow)WindowManager.getDefault().getMainWindow();
136
        MainWindow mainWindow = MainWindow.getInstance();
134
        frame.setFullScreenMode( !frame.isFullScreenMode() );
137
        mainWindow.setFullScreenMode( !mainWindow.isFullScreenMode() );
135
    }
138
    }
136
139
140
    @Override
137
    public String getName() {
141
    public String getName() {
138
        return NbBundle.getMessage(ToggleFullScreenAction.class, "CTL_ToggleFullScreenAction");
142
        return NbBundle.getMessage(ToggleFullScreenAction.class, "CTL_ToggleFullScreenAction");
139
    }
143
    }
140
144
145
    @Override
141
    public HelpCtx getHelpCtx() {
146
    public HelpCtx getHelpCtx() {
142
        return new HelpCtx(ToggleFullScreenAction.class);
147
        return new HelpCtx(ToggleFullScreenAction.class);
143
    }
148
    }
144
149
145
    @Override
150
    @Override
146
    public boolean isEnabled() {
151
    public boolean isEnabled() {
147
        return WindowManager.getDefault().getMainWindow() instanceof MainWindow;
152
        return WindowManager.getDefault().getMainWindow() == MainWindow.getInstance().getFrame();
148
    }
153
    }
149
}
154
}
150
155
(-)a/core.windows/src/org/netbeans/core/windows/view/DefaultView.java (-3 / +5 lines)
Lines 100-106 Link Here
100
    
100
    
101
    // XXX
101
    // XXX
102
    public Frame getMainWindow() {
102
    public Frame getMainWindow() {
103
        return hierarchy.getMainWindow();
103
        return hierarchy.getMainWindow().getFrame();
104
    }
104
    }
105
    
105
    
106
    public Component getEditorAreaComponent() {
106
    public Component getEditorAreaComponent() {
Lines 186-192 Link Here
186
                return;
186
                return;
187
            }
187
            }
188
        }
188
        }
189
        
189
190
        // Process all event types.
190
        // Process all event types.
191
        for(int i = 0; i < viewEvents.length; i++) {
191
        for(int i = 0; i < viewEvents.length; i++) {
192
            ViewEvent viewEvent = viewEvents[i];
192
            ViewEvent viewEvent = viewEvents[i];
Lines 520-525 Link Here
520
//        }, AWTEvent.FOCUS_EVENT_MASK);
520
//        }, AWTEvent.FOCUS_EVENT_MASK);
521
        
521
        
522
        hierarchy.getMainWindow().initializeComponents();
522
        hierarchy.getMainWindow().initializeComponents();
523
524
        JFrame frame = hierarchy.getMainWindow().getFrame();
523
        // Init toolbar.
525
        // Init toolbar.
524
        ToolbarPool.getDefault().setConfiguration(wsa.getToolbarConfigurationName());
526
        ToolbarPool.getDefault().setConfiguration(wsa.getToolbarConfigurationName());
525
        
527
        
Lines 569-575 Link Here
569
        // XXX PENDING
571
        // XXX PENDING
570
        if(wsa.getEditorAreaState() == Constants.EDITOR_AREA_JOINED) {
572
        if(wsa.getEditorAreaState() == Constants.EDITOR_AREA_JOINED) {
571
            // Ignore when main window is maximized.
573
            // Ignore when main window is maximized.
572
            if(hierarchy.getMainWindow().getExtendedState() != Frame.MAXIMIZED_BOTH) {
574
            if(frame.getExtendedState() != Frame.MAXIMIZED_BOTH) {
573
                if (DEBUG) {
575
                if (DEBUG) {
574
                    debugLog("do updateMainWindowBoundsSeparatedHelp");
576
                    debugLog("do updateMainWindowBoundsSeparatedHelp");
575
                }
577
                }
(-)a/core.windows/src/org/netbeans/core/windows/view/ViewHierarchy.java (-10 / +32 lines)
Lines 59-66 Link Here
59
import java.lang.ref.WeakReference;
59
import java.lang.ref.WeakReference;
60
import java.util.*;
60
import java.util.*;
61
import java.util.List;
61
import java.util.List;
62
import java.util.logging.Level;
63
import java.util.logging.Logger;
62
64
63
import org.netbeans.core.windows.Debug;
65
import org.netbeans.core.windows.Debug;
66
import org.netbeans.core.windows.WindowManagerImpl;
64
import org.openide.windows.TopComponent;
67
import org.openide.windows.TopComponent;
65
68
66
/**
69
/**
Lines 124-142 Link Here
124
    
127
    
125
    public MainWindow getMainWindow() {
128
    public MainWindow getMainWindow() {
126
        if (mainWindow == null) {
129
        if (mainWindow == null) {
127
            mainWindow = new MainWindow();
130
            JFrame mainFrame = null;
131
            for( Frame f : Frame.getFrames() ) {
132
                if( f instanceof JFrame ) {
133
                    JFrame frame = (JFrame)f;
134
                    if( "NbMainWindow".equals(frame.getName())) { //NOI18N
135
                        mainFrame = frame;
136
                        break;
137
                    }
138
                }
139
            }
140
            if( null == mainFrame ) {
141
                mainFrame = new JFrame();
142
            }
143
            Logger.getLogger(MainWindow.class.getName()).log(Level.FINE, "Installing MainWindow into " + mainFrame); //NOI18N
144
            mainWindow = MainWindow.install(mainFrame);
128
        }
145
        }
129
        return mainWindow;
146
        return mainWindow;
130
    }
147
    }
131
    
148
    
132
    public void installMainWindowListeners() {
149
    public void installMainWindowListeners() {
133
        mainWindow.addComponentListener(mainWindowListener);
150
        mainWindow.getFrame().addComponentListener(mainWindowListener);
134
        mainWindow.addWindowStateListener(mainWindowListener);
151
        mainWindow.getFrame().addWindowStateListener(mainWindowListener);
135
    }
152
    }
136
    
153
    
137
    public void uninstallMainWindowListeners() {
154
    public void uninstallMainWindowListeners() {
138
        mainWindow.removeComponentListener(mainWindowListener);
155
        mainWindow.getFrame().removeComponentListener(mainWindowListener);
139
        mainWindow.removeWindowStateListener(mainWindowListener);
156
        mainWindow.getFrame().removeWindowStateListener(mainWindowListener);
140
    }
157
    }
141
    
158
    
142
    /** Updates the view hierarchy according to new structure. */
159
    /** Updates the view hierarchy according to new structure. */
Lines 598-614 Link Here
598
    }
615
    }
599
    
616
    
600
    public void updateMainWindowBounds(WindowSystemAccessor wsa) {
617
    public void updateMainWindowBounds(WindowSystemAccessor wsa) {
618
        JFrame frame = mainWindow.getFrame();
601
        if(wsa.getEditorAreaState() == Constants.EDITOR_AREA_JOINED) {
619
        if(wsa.getEditorAreaState() == Constants.EDITOR_AREA_JOINED) {
602
            mainWindow.setBounds(wsa.getMainWindowBoundsJoined());
620
            frame.setBounds(wsa.getMainWindowBoundsJoined());
603
        } else {
621
        } else {
604
            // #45832 clear the desktop when going to SDI,
622
            // #45832 clear the desktop when going to SDI,
605
            setMainWindowDesktop(null);
623
            setMainWindowDesktop(null);
606
            // invalidate to recalculate the main window's preffered size..
624
            // invalidate to recalculate the main window's preffered size..
607
            mainWindow.invalidate();
625
            frame.invalidate();
608
            mainWindow.setBounds(wsa.getMainWindowBoundsSeparated());
626
            frame.setBounds(wsa.getMainWindowBoundsSeparated());
609
        }
627
        }
610
        // #38146 So the updateSplit works with correct size.
628
        // #38146 So the updateSplit works with correct size.
611
        mainWindow.validate();
629
        frame.validate();
612
        // PENDING consider better handling this event so there is not doubled
630
        // PENDING consider better handling this event so there is not doubled
613
        // validation (one in MainWindow - needs to be provided here) and this as second one.
631
        // validation (one in MainWindow - needs to be provided here) and this as second one.
614
    }
632
    }
Lines 815-820 Link Here
815
    private EditorAreaFrame createEditorAreaFrame() {
833
    private EditorAreaFrame createEditorAreaFrame() {
816
        final EditorAreaFrame frame = new EditorAreaFrame();
834
        final EditorAreaFrame frame = new EditorAreaFrame();
817
        frame.addComponentListener(new ComponentAdapter() {
835
        frame.addComponentListener(new ComponentAdapter() {
836
            @Override
818
            public void componentResized(ComponentEvent evt) {
837
            public void componentResized(ComponentEvent evt) {
819
                if(frame.getExtendedState() == Frame.MAXIMIZED_BOTH) {
838
                if(frame.getExtendedState() == Frame.MAXIMIZED_BOTH) {
820
                    // Ignore changes when the frame is in maximized state.
839
                    // Ignore changes when the frame is in maximized state.
Lines 823-828 Link Here
823
                controller.userResizedEditorArea(frame.getBounds());
842
                controller.userResizedEditorArea(frame.getBounds());
824
            }
843
            }
825
            
844
            
845
            @Override
826
            public void componentMoved(ComponentEvent evt) {
846
            public void componentMoved(ComponentEvent evt) {
827
                if(frame.getExtendedState() == Frame.MAXIMIZED_BOTH) {
847
                if(frame.getExtendedState() == Frame.MAXIMIZED_BOTH) {
828
                    // Ignore changes when the frame is in maximized state.
848
                    // Ignore changes when the frame is in maximized state.
Lines 834-839 Link Here
834
        frame.setWindowActivationListener(controller);
854
        frame.setWindowActivationListener(controller);
835
        
855
        
836
        frame.addWindowListener(new WindowAdapter() {
856
        frame.addWindowListener(new WindowAdapter() {
857
            @Override
837
            public void windowClosing(WindowEvent evt) {
858
            public void windowClosing(WindowEvent evt) {
838
                closeEditorModes();
859
                closeEditorModes();
839
            }
860
            }
Lines 923-929 Link Here
923
    }
944
    }
924
    
945
    
925
    public void updateUI() {
946
    public void updateUI() {
926
        SwingUtilities.updateComponentTreeUI(mainWindow);
947
        SwingUtilities.updateComponentTreeUI(mainWindow.getFrame());
927
        if(editorAreaFrame != null) {
948
        if(editorAreaFrame != null) {
928
            SwingUtilities.updateComponentTreeUI(editorAreaFrame);
949
            SwingUtilities.updateComponentTreeUI(editorAreaFrame);
929
        }
950
        }
Lines 946-951 Link Here
946
        return s;
967
        return s;
947
    }
968
    }
948
    
969
    
970
    @Override
949
    public String toString() {
971
    public String toString() {
950
        return dumpElement(desktop.getSplitRoot(), 0) + "\nseparateViews=" + separateModeViews.keySet(); // NOI18N
972
        return dumpElement(desktop.getSplitRoot(), 0) + "\nseparateViews=" + separateModeViews.keySet(); // NOI18N
951
    }
973
    }
(-)a/core.windows/src/org/netbeans/core/windows/view/dnd/WindowDnDManager.java (-4 / +4 lines)
Lines 496-502 Link Here
496
    private TopComponentDroppable findMainWindowDroppable(
496
    private TopComponentDroppable findMainWindowDroppable(
497
    Point location, int kind, TopComponent transfer) {
497
    Point location, int kind, TopComponent transfer) {
498
        
498
        
499
        MainWindow mainWindow = (MainWindow)WindowManagerImpl.getInstance().getMainWindow();
499
        JFrame mainWindow = (JFrame)WindowManagerImpl.getInstance().getMainWindow();
500
500
501
        if (!ZOrderManager.getInstance().isOnTop(mainWindow, location)) {
501
        if (!ZOrderManager.getInstance().isOnTop(mainWindow, location)) {
502
            return null;
502
            return null;
Lines 635-641 Link Here
635
    /** Indicates whether the cursor is around center panel of main window.
635
    /** Indicates whether the cursor is around center panel of main window.
636
     * In that case is needed also to provide a drop. */
636
     * In that case is needed also to provide a drop. */
637
    static boolean isAroundCenterPanel(Point location) {
637
    static boolean isAroundCenterPanel(Point location) {
638
        Component desktop = ((MainWindow)WindowManagerImpl.getInstance().getMainWindow()).getDesktop();
638
        Component desktop = MainWindow.getInstance().getDesktop();
639
        if(desktop == null) {
639
        if(desktop == null) {
640
            return false;
640
            return false;
641
        }
641
        }
Lines 683-689 Link Here
683
    /** Indicates whether the cursor is around center panel of main window.
683
    /** Indicates whether the cursor is around center panel of main window.
684
     * In that case is needed also to provide a drop. */
684
     * In that case is needed also to provide a drop. */
685
    static boolean isNearEdge(Point location, ViewAccessor viewAccessor) {
685
    static boolean isNearEdge(Point location, ViewAccessor viewAccessor) {
686
        Component desktop = ((MainWindow)WindowManagerImpl.getInstance().getMainWindow()).getDesktop();
686
        Component desktop = MainWindow.getInstance().getDesktop();
687
        if(desktop == null) {
687
        if(desktop == null) {
688
            return false;
688
            return false;
689
        }
689
        }
Lines 1155-1161 Link Here
1155
1155
1156
        /** Implements <code>TopComponentDroppable</code>. */
1156
        /** Implements <code>TopComponentDroppable</code>. */
1157
        public Component getDropComponent() {
1157
        public Component getDropComponent() {
1158
            return ((MainWindow)WindowManagerImpl.getInstance().getMainWindow()).getDesktop();
1158
            return MainWindow.getInstance().getDesktop();
1159
        }
1159
        }
1160
        
1160
        
1161
        /** Implements <code>TopComponentDroppable</code>. */
1161
        /** Implements <code>TopComponentDroppable</code>. */
(-)a/core.windows/src/org/netbeans/core/windows/view/ui/MainWindow.java (-85 / +143 lines)
Lines 82-90 Link Here
82
 *
82
 *
83
 * @author Ian Formanek, Petr Hamernik
83
 * @author Ian Formanek, Petr Hamernik
84
 */
84
 */
85
public final class MainWindow extends JFrame {
85
public final class MainWindow {
86
    /** generated Serialized Version UID */
86
    /** generated Serialized Version UID */
87
    static final long serialVersionUID = -1160791973145645501L;
87
    static final long serialVersionUID = -1160791973145645501L;
88
89
    private final JFrame frame;
90
88
    private static JMenuBar mainMenuBar;
91
    private static JMenuBar mainMenuBar;
89
92
90
    /** Desktop. */
93
    /** Desktop. */
Lines 101-143 Link Here
101
    private Lookup.Result <SaveCookie> saveResult;
104
    private Lookup.Result <SaveCookie> saveResult;
102
    private Lookup.Result <DataObject> dobResult;
105
    private Lookup.Result <DataObject> dobResult;
103
    private LookupListener saveListener;
106
    private LookupListener saveListener;
107
108
    private static MainWindow theInstance;
104
    
109
    
105
110
106
    /** Constructs main window. */
111
    /** Constructs main window. */
107
    public MainWindow() {
112
    private MainWindow(JFrame frame) {
108
        if( "Aqua".equals(UIManager.getLookAndFeel().getID())
113
        this.frame = frame;
109
                && null == System.getProperty("apple.awt.brushMetalLook") ) //NOI18N
110
            getRootPane().putClientProperty("apple.awt.brushMetalLook", Boolean.TRUE); //NOI18N
111
    }
114
    }
112
    
115
113
    /** Overrides superclass method, adds help context to the new root pane. */
116
    public static MainWindow install( JFrame frame ) {
114
    @Override
117
        synchronized( MainWindow.class ) {
115
    protected void setRootPane(JRootPane root) {
118
            if( null != theInstance ) {
116
        super.setRootPane(root);
119
                Logger.getLogger(MainWindow.class.getName()).log(Level.INFO, "Installing MainWindow again, existing frame is: " + theInstance.frame); //NOI18N
117
        if(root != null) {
120
            }
118
            HelpCtx.setHelpIDString(
121
            theInstance = new MainWindow(frame);
119
                    root, new HelpCtx(MainWindow.class).getHelpID());
122
            return theInstance;
120
        }
123
        }
121
        //Optimization related to jdk bug 4939857 - on pre 1.5 jdk's an
124
    }
122
        //extra repaint is caused by the search for an opaque component up
125
123
        //to the component root.  Post 1.5, root pane will automatically be
126
    public static MainWindow getInstance() {
124
        //opaque.
127
        synchronized( MainWindow.class ) {
125
        root.setOpaque(true);
128
            if( null == theInstance ) {
126
        if (Utilities.isWindows()) {
129
                Logger.getLogger(MainWindow.class.getName()).log(Level.INFO, "Accessing uninitialized MainWindow, using dummy JFrame instead." ); //NOI18N
127
            // use glass pane that will not cause repaint/revalidate of parent when set visible
130
                theInstance = new MainWindow(new JFrame());
128
            // is called (when setting wait cursor in ModuleActions) #40689
131
            }
129
            JComponent c = new JPanel() {
132
            return theInstance;
130
                @Override
131
                public void setVisible(boolean flag) {
132
                    if (flag != isVisible ()) {
133
                        super.setVisible(flag);
134
                    }
135
                }
136
            };
137
            c.setName(root.getName()+".nbGlassPane");  // NOI18N
138
            c.setVisible(false);
139
            ((JPanel)c).setOpaque(false);
140
            root.setGlassPane(c);
141
        }
133
        }
142
    }
134
    }
143
135
Lines 155-177 Link Here
155
        }
147
        }
156
        inited = true;
148
        inited = true;
157
149
150
        JPanel contentPane = new JPanel(new BorderLayout()) {
151
            @Override
152
            public void paint(Graphics g) {
153
                super.paint(g);
154
                Logger.getLogger(MainWindow.class.getName()).log(Level.FINE,
155
                        "Paint method of main window invoked normally."); //NOI18N
156
                // XXX is this only needed by obsolete #24291 hack, or now needed independently?
157
                WindowManagerImpl.getInstance().mainWindowPainted();
158
            }
159
160
        };
161
        frame.setContentPane(contentPane);
162
158
        init();
163
        init();
164
165
        initRootPane();
159
        
166
        
160
        // initialize frame
167
        // initialize frame
161
        initFrameIcons(this);
168
        initFrameIcons(frame);
162
        
169
        
163
        initListeners();
170
        initListeners();
164
171
165
        setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
172
        frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
166
173
167
        getAccessibleContext().setAccessibleDescription(
174
        frame.getAccessibleContext().setAccessibleDescription(
168
                NbBundle.getBundle(MainWindow.class).getString("ACSD_MainWindow"));
175
                NbBundle.getBundle(MainWindow.class).getString("ACSD_MainWindow"));
169
176
170
        setJMenuBar(mainMenuBar);
177
        frame.setJMenuBar(mainMenuBar);
171
    
178
    
172
        if (!Constants.NO_TOOLBARS) {
179
        if (!Constants.NO_TOOLBARS) {
173
            JComponent tb = getToolbarComponent();
180
            JComponent tb = getToolbarComponent();
174
            getContentPane().add(tb, BorderLayout.NORTH);
181
            frame.getContentPane().add(tb, BorderLayout.NORTH);
175
        }
182
        }
176
        
183
        
177
        if(!Constants.SWITCH_STATUSLINE_IN_MENUBAR) {
184
        if(!Constants.SWITCH_STATUSLINE_IN_MENUBAR) {
Lines 207-239 Link Here
207
                
214
                
208
                decoratePanel (statusLinePanel, false);
215
                decoratePanel (statusLinePanel, false);
209
                statusLinePanel.setName("statusLine"); //NOI18N
216
                statusLinePanel.setName("statusLine"); //NOI18N
210
                getContentPane().add (statusLinePanel, BorderLayout.SOUTH);
217
                frame.getContentPane().add (statusLinePanel, BorderLayout.SOUTH);
211
            } else { // custom status line provided
218
            } else { // custom status line provided
212
                JComponent status = getCustomStatusLine();
219
                JComponent status = getCustomStatusLine();
213
                if (status != null) {
220
                if (status != null) {
214
                    getContentPane().add(status, BorderLayout.SOUTH);
221
                    frame.getContentPane().add(status, BorderLayout.SOUTH);
215
                }
222
                }
216
            }
223
            }
217
        }
224
        }
218
225
219
        getContentPane().add(getDesktopPanel(), BorderLayout.CENTER);
226
        frame.getContentPane().add(getDesktopPanel(), BorderLayout.CENTER);
220
        
227
        
221
        //#38810 start - focusing the main window in case it's not active and the menu is
228
        //#38810 start - focusing the main window in case it's not active and the menu is
222
        // selected..
229
        // selected..
223
        MenuSelectionManager.defaultManager().addChangeListener(new ChangeListener(){
230
        MenuSelectionManager.defaultManager().addChangeListener(new ChangeListener(){
231
            @Override
224
            public void stateChanged(ChangeEvent e) {
232
            public void stateChanged(ChangeEvent e) {
225
                MenuElement[] elems = MenuSelectionManager.defaultManager().getSelectedPath();
233
                MenuElement[] elems = MenuSelectionManager.defaultManager().getSelectedPath();
226
                if (elems != null && elems.length > 0) {
234
                if (elems != null && elems.length > 0) {
227
                    if (elems[0] == getJMenuBar()) {
235
                    if (elems[0] == frame.getJMenuBar()) {
228
                        if (!isActive()) {
236
                        if (!frame.isActive()) {
229
                            toFront();
237
                            frame.toFront();
230
                        }
238
                        }
231
                    }
239
                    }
232
                }
240
                }
233
            }
241
            }
234
        });
242
        });
235
        //#38810 end
243
        //#38810 end
236
        setTitle(NbBundle.getMessage(MainWindow.class, "CTL_MainWindow_Title_No_Project", System.getProperty("netbeans.buildnumber")));
244
        frame.setTitle(NbBundle.getMessage(MainWindow.class, "CTL_MainWindow_Title_No_Project", System.getProperty("netbeans.buildnumber")));
237
        if (Utilities.getOperatingSystem() == Utilities.OS_MAC) {
245
        if (Utilities.getOperatingSystem() == Utilities.OS_MAC) {
238
            //Show a "save dot" in the close button if a modified file is
246
            //Show a "save dot" in the close button if a modified file is
239
            //being edited
247
            //being edited
Lines 243-252 Link Here
243
            dobResult = Utilities.actionsGlobalContext().lookupResult (DataObject.class);
251
            dobResult = Utilities.actionsGlobalContext().lookupResult (DataObject.class);
244
            if( null != saveResult && null != dobResult ) {
252
            if( null != saveResult && null != dobResult ) {
245
                saveListener = new LookupListener() {
253
                saveListener = new LookupListener() {
254
                    @Override
246
                    public void resultChanged(LookupEvent ev) {
255
                    public void resultChanged(LookupEvent ev) {
247
                        if (ev.getSource() == saveResult) {
256
                        if (ev.getSource() == saveResult) {
248
                            boolean modified = saveResult.allItems().size() > 0;
257
                            boolean modified = saveResult.allItems().size() > 0;
249
                            getRootPane().putClientProperty ("Window.documentModified", //NOI18N
258
                            frame.getRootPane().putClientProperty ("Window.documentModified", //NOI18N
250
                                    modified ? Boolean.TRUE : Boolean.FALSE);
259
                                    modified ? Boolean.TRUE : Boolean.FALSE);
251
                        } else if (ev.getSource() == dobResult) {
260
                        } else if (ev.getSource() == dobResult) {
252
                            int count = dobResult.allItems().size();
261
                            int count = dobResult.allItems().size();
Lines 256-269 Link Here
256
                                    FileObject file = dob.getPrimaryFile();
265
                                    FileObject file = dob.getPrimaryFile();
257
                                    File f = FileUtil.toFile(file);
266
                                    File f = FileUtil.toFile(file);
258
                                    if (f != null) {
267
                                    if (f != null) {
259
                                        getRootPane().putClientProperty("Window.documentFile", f); //NOI18N
268
                                        frame.getRootPane().putClientProperty("Window.documentFile", f); //NOI18N
260
                                        break;
269
                                        break;
261
                                    }
270
                                    }
262
                                    //Fall through
271
                                    //Fall through
263
                                case 0 :
272
                                case 0 :
264
                                    //Fall through
273
                                    //Fall through
265
                                default :
274
                                default :
266
                                    getRootPane().putClientProperty("Window.documentFile", null); //NOI18N
275
                                    frame.getRootPane().putClientProperty("Window.documentFile", null); //NOI18N
267
                            }
276
                            }
268
                        }
277
                        }
269
                    }
278
                    }
Lines 315-328 Link Here
315
        }
324
        }
316
        return some ? icons : null;
325
        return some ? icons : null;
317
    }
326
    }
327
328
    protected void initRootPane() {
329
        JRootPane root = frame.getRootPane();
330
        if( null == root )
331
            return;
332
        if( "Aqua".equals(UIManager.getLookAndFeel().getID())
333
                && null == System.getProperty("apple.awt.brushMetalLook") ) //NOI18N
334
            root.putClientProperty("apple.awt.brushMetalLook", Boolean.TRUE); //NOI18N
335
        HelpCtx.setHelpIDString(
336
                root, new HelpCtx(MainWindow.class).getHelpID());
337
        if (Utilities.isWindows()) {
338
            // use glass pane that will not cause repaint/revalidate of parent when set visible
339
            // is called (when setting wait cursor in ModuleActions) #40689
340
            JComponent c = new JPanel() {
341
                @Override
342
                public void setVisible(boolean flag) {
343
                    if (flag != isVisible ()) {
344
                        super.setVisible(flag);
345
                    }
346
                }
347
            };
348
            c.setName(root.getName()+".nbGlassPane");  // NOI18N
349
            c.setVisible(false);
350
            ((JPanel)c).setOpaque(false);
351
            root.setGlassPane(c);
352
        }
353
    }
354
355
356
    //delegate some JFrame methods for convenience
357
358
    public void setBounds(Rectangle bounds) {
359
        frame.setBounds(bounds);
360
    }
361
362
    public void setExtendedState(int extendedState) {
363
        frame.setExtendedState(extendedState);
364
    }
365
366
    public void setVisible(boolean visible) {
367
        frame.setVisible(visible);
368
    }
369
370
    public int getExtendedState() {
371
        return frame.getExtendedState();
372
    }
373
374
    public JMenuBar getJMenuBar() {
375
        return frame.getJMenuBar();
376
    }
318
    
377
    
319
    static private class StatusLineElementsListener implements LookupListener {
378
    static private class StatusLineElementsListener implements LookupListener {
320
        private JPanel decoratingPanel;
379
        private JPanel decoratingPanel;
321
        StatusLineElementsListener (JPanel decoratingPanel) {
380
        StatusLineElementsListener (JPanel decoratingPanel) {
322
            this.decoratingPanel = decoratingPanel;
381
            this.decoratingPanel = decoratingPanel;
323
        }
382
        }
383
        @Override
324
        public void resultChanged (LookupEvent ev) {
384
        public void resultChanged (LookupEvent ev) {
325
            SwingUtilities.invokeLater (new Runnable () {
385
            SwingUtilities.invokeLater (new Runnable () {
386
                @Override
326
                public void run () {
387
                public void run () {
327
                    decoratePanel (decoratingPanel, false);
388
                    decoratePanel (decoratingPanel, false);
328
                }
389
                }
Lines 352-358 Link Here
352
    }
413
    }
353
    
414
    
354
    private void initListeners() {
415
    private void initListeners() {
355
        addWindowListener (new WindowAdapter() {
416
        frame.addWindowListener (new WindowAdapter() {
356
                @Override
417
                @Override
357
                public void windowClosing(WindowEvent evt) {
418
                public void windowClosing(WindowEvent evt) {
358
                    LifecycleManager.getDefault().exit();
419
                    LifecycleManager.getDefault().exit();
Lines 362-368 Link Here
362
                public void windowActivated (WindowEvent evt) {
423
                public void windowActivated (WindowEvent evt) {
363
                   // #19685. Cancel foreigner popup when
424
                   // #19685. Cancel foreigner popup when
364
                   // activated main window.
425
                   // activated main window.
365
                   org.netbeans.core.windows.RegistryImpl.cancelMenu(MainWindow.this);
426
                   org.netbeans.core.windows.RegistryImpl.cancelMenu(frame);
366
                }
427
                }
367
            }
428
            }
368
        );
429
        );
Lines 475-486 Link Here
475
        }
536
        }
476
        if( null != forcedBounds ) {
537
        if( null != forcedBounds ) {
477
            bounds = new Rectangle( forcedBounds );
538
            bounds = new Rectangle( forcedBounds );
478
            setPreferredSize( bounds.getSize() );
539
            frame.setPreferredSize( bounds.getSize() );
479
            forcedBounds = null;
540
            forcedBounds = null;
480
        }
541
        }
481
        
542
        
482
        if(!bounds.isEmpty()) {
543
        if(!bounds.isEmpty()) {
483
            setBounds(bounds);
544
            frame.setBounds(bounds);
484
        }
545
        }
485
    }
546
    }
486
    
547
    
Lines 510-519 Link Here
510
        if(desktop != null) {
571
        if(desktop != null) {
511
            getDesktopPanel().add(desktop, BorderLayout.CENTER);
572
            getDesktopPanel().add(desktop, BorderLayout.CENTER);
512
        } 
573
        } 
513
        invalidate();
574
        frame.invalidate();
514
        validate();
575
        frame.validate();
515
576
516
        repaint();
577
        frame.repaint();
517
    }
578
    }
518
579
519
    // XXX PENDING used in DnD only.
580
    // XXX PENDING used in DnD only.
Lines 539-545 Link Here
539
    // XXX
600
    // XXX
540
    /** Gets bounds of main window without the dektop component. */
601
    /** Gets bounds of main window without the dektop component. */
541
    public Rectangle getPureMainWindowBounds() {
602
    public Rectangle getPureMainWindowBounds() {
542
        Rectangle bounds = getBounds();
603
        Rectangle bounds = frame.getBounds();
543
604
544
        // XXX Substract the desktop height, we know the pure main window
605
        // XXX Substract the desktop height, we know the pure main window
545
        // is always at the top, the width is same.
606
        // is always at the top, the width is same.
Lines 551-565 Link Here
551
        return bounds;
612
        return bounds;
552
    }
613
    }
553
614
554
    @Override
555
    public void paint(Graphics g) {
556
        super.paint(g);
557
        Logger.getLogger(MainWindow.class.getName()).log(Level.FINE, 
558
                "Paint method of main window invoked normally."); //NOI18N
559
        // XXX is this only needed by obsolete #24291 hack, or now needed independently?
560
        WindowManagerImpl.getInstance().mainWindowPainted();
561
    }
562
563
    // Full Screen Mode
615
    // Full Screen Mode
564
    private boolean isFullScreenMode = false;
616
    private boolean isFullScreenMode = false;
565
    private Rectangle restoreBounds;
617
    private Rectangle restoreBounds;
Lines 575-596 Link Here
575
        }
627
        }
576
        isSwitchingFullScreenMode = true;
628
        isSwitchingFullScreenMode = true;
577
        if( !isFullScreenMode ) {
629
        if( !isFullScreenMode ) {
578
            restoreExtendedState = getExtendedState();
630
            restoreExtendedState = frame.getExtendedState();
579
            restoreBounds = getBounds();
631
            restoreBounds = frame.getBounds();
580
            isUndecorated = isUndecorated();
632
            isUndecorated = frame.isUndecorated();
581
            windowDecorationStyle = getRootPane().getWindowDecorationStyle();
633
            windowDecorationStyle = frame.getRootPane().getWindowDecorationStyle();
582
        }
634
        }
583
        isFullScreenMode = fullScreenMode;
635
        isFullScreenMode = fullScreenMode;
584
        if( Utilities.isWindows() )
636
        if( Utilities.isWindows() )
585
            setVisible( false );
637
            frame.setVisible( false );
586
        else 
638
        else 
587
            WindowManagerImpl.getInstance().setVisible(false);
639
            WindowManagerImpl.getInstance().setVisible(false);
588
        
640
        
589
        dispose();
641
        frame.dispose();
590
        
642
        
591
        setUndecorated( isFullScreenMode || isUndecorated );
643
        frame.setUndecorated( isFullScreenMode || isUndecorated );
592
        // Added to support Custom Look and Feel with Decorations
644
        // Added to support Custom Look and Feel with Decorations
593
        getRootPane().setWindowDecorationStyle( isFullScreenMode ? JRootPane.NONE : windowDecorationStyle );
645
        frame.getRootPane().setWindowDecorationStyle( isFullScreenMode ? JRootPane.NONE : windowDecorationStyle );
594
646
595
        final String toolbarConfigName = ToolbarPool.getDefault().getConfiguration();
647
        final String toolbarConfigName = ToolbarPool.getDefault().getConfiguration();
596
        if( null != toolbarConfigName ) {
648
        if( null != toolbarConfigName ) {
Lines 602-617 Link Here
602
        final boolean updateBounds = ( !isFullScreenMode );//&& restoreExtendedState != JFrame.MAXIMIZED_BOTH );
654
        final boolean updateBounds = ( !isFullScreenMode );//&& restoreExtendedState != JFrame.MAXIMIZED_BOTH );
603
655
604
        GraphicsDevice device = null;
656
        GraphicsDevice device = null;
605
        Graphics gc = getGraphics();
657
        Graphics gc = frame.getGraphics();
606
        if( gc instanceof Graphics2D ) {
658
        if( gc instanceof Graphics2D ) {
607
            GraphicsConfiguration conf = ((Graphics2D)gc).getDeviceConfiguration();
659
            GraphicsConfiguration conf = ((Graphics2D)gc).getDeviceConfiguration();
608
            if( null != conf )
660
            if( null != conf )
609
                device = conf.getDevice();
661
                device = conf.getDevice();
610
        }
662
        }
611
        if( null != device && device.isFullScreenSupported() ) {
663
        if( null != device && device.isFullScreenSupported() ) {
612
            device.setFullScreenWindow( isFullScreenMode ? this : null );
664
            device.setFullScreenWindow( isFullScreenMode ? frame : null );
613
        } else {
665
        } else {
614
            setExtendedState( isFullScreenMode ? JFrame.MAXIMIZED_BOTH : restoreExtendedState );
666
            frame.setExtendedState( isFullScreenMode ? JFrame.MAXIMIZED_BOTH : restoreExtendedState );
615
        }
667
        }
616
        
668
        
617
        if( updateBounds || (isFullScreenMode() && !Utilities.isWindows()) ) {
669
        if( updateBounds || (isFullScreenMode() && !Utilities.isWindows()) ) {
Lines 623-637 Link Here
623
            }
675
            }
624
        }
676
        }
625
        if( Utilities.isWindows() ) {
677
        if( Utilities.isWindows() ) {
626
            setVisible( true );
678
            frame.setVisible( true );
627
            SwingUtilities.invokeLater( new Runnable() {
679
            SwingUtilities.invokeLater( new Runnable() {
680
                @Override
628
                public void run() {
681
                public void run() {
629
                    invalidate();
682
                    frame.invalidate();
630
                    validate();
683
                    frame.validate();
631
                    repaint();
684
                    frame.repaint();
632
                    if( updateBounds ) {
685
                    if( updateBounds ) {
633
                        setPreferredSize( restoreBounds.getSize() );
686
                        frame.setPreferredSize( restoreBounds.getSize() );
634
                        setBounds( restoreBounds );
687
                        frame.setBounds( restoreBounds );
635
                    }
688
                    }
636
                    ToolbarPool.getDefault().setConfiguration( toolbarConfigName );
689
                    ToolbarPool.getDefault().setConfiguration( toolbarConfigName );
637
                    isSwitchingFullScreenMode = false;
690
                    isSwitchingFullScreenMode = false;
Lines 640-649 Link Here
640
        } else {
693
        } else {
641
            WindowManagerImpl.getInstance().setVisible(true);
694
            WindowManagerImpl.getInstance().setVisible(true);
642
            SwingUtilities.invokeLater( new Runnable() {
695
            SwingUtilities.invokeLater( new Runnable() {
696
                @Override
643
                public void run() {
697
                public void run() {
644
                    invalidate();
698
                    frame.invalidate();
645
                    validate();
699
                    frame.validate();
646
                    repaint();
700
                    frame.repaint();
647
                    ToolbarPool.getDefault().setConfiguration( toolbarConfigName );
701
                    ToolbarPool.getDefault().setConfiguration( toolbarConfigName );
648
                    isSwitchingFullScreenMode = false;
702
                    isSwitchingFullScreenMode = false;
649
                }
703
                }
Lines 655-660 Link Here
655
        return isFullScreenMode;
709
        return isFullScreenMode;
656
    }
710
    }
657
711
712
    public JFrame getFrame() {
713
        return frame;
714
    }
715
658
    private static class HeavyWeightPopupFactory extends PopupFactory {
716
    private static class HeavyWeightPopupFactory extends PopupFactory {
659
717
660
        @Override
718
        @Override
(-)a/core.windows/src/org/netbeans/core/windows/view/ui/toolbars/ToolbarConfiguration.java (-2 / +1 lines)
Lines 151-158 Link Here
151
    }
151
    }
152
152
153
    private void fillToolbarsMenu (JComponent menu, boolean isContextMenu) {
153
    private void fillToolbarsMenu (JComponent menu, boolean isContextMenu) {
154
        Frame frame = WindowManager.getDefault().getMainWindow();
154
        boolean fullScreen = MainWindow.getInstance().isFullScreenMode();
155
        boolean fullScreen = (frame instanceof MainWindow) && ((MainWindow)frame).isFullScreenMode();
156
155
157
        Map<String, ToolbarConstraints> name2constr = collectAllConstraints();
156
        Map<String, ToolbarConstraints> name2constr = collectAllConstraints();
158
        // generate list of available toolbars
157
        // generate list of available toolbars
(-)a/core.windows/test/unit/src/org/netbeans/core/windows/view/ui/CustomMenuBarTest.java (-5 / +5 lines)
Lines 88-94 Link Here
88
        //Verify that test layer was added to default filesystem
88
        //Verify that test layer was added to default filesystem
89
        assertNotNull(FileUtil.getConfigFile("LookAndFeel/MenuBar.instance"));
89
        assertNotNull(FileUtil.getConfigFile("LookAndFeel/MenuBar.instance"));
90
90
91
        MainWindow mw = (MainWindow) WindowManager.getDefault().getMainWindow();
91
        MainWindow mw = MainWindow.getInstance();
92
        mw.initializeComponents();
92
        mw.initializeComponents();
93
        assertEquals(mw.getJMenuBar(), createMenuBar());
93
        assertEquals(mw.getJMenuBar(), createMenuBar());
94
        IDEInitializer.removeLayers();
94
        IDEInitializer.removeLayers();
Lines 101-118 Link Here
101
101
102
        //Verify that test layer was added to default filesystem
102
        //Verify that test layer was added to default filesystem
103
        assertNotNull(FileUtil.getConfigFile("LookAndFeel/StatusLine.instance"));
103
        assertNotNull(FileUtil.getConfigFile("LookAndFeel/StatusLine.instance"));
104
        MainWindow mw = (MainWindow) WindowManager.getDefault().getMainWindow();
104
        MainWindow mw = MainWindow.getInstance();
105
        mw.initializeComponents();
105
        mw.initializeComponents();
106
        assertTrue(findComponent(mw, createStatusLine()));
106
        assertTrue(findComponent(mw.getFrame(), createStatusLine()));
107
107
108
        IDEInitializer.removeLayers();
108
        IDEInitializer.removeLayers();
109
    }
109
    }
110
110
111
    public void testNoToolbar() throws Exception {
111
    public void testNoToolbar() throws Exception {
112
        MainWindow mw = (MainWindow) WindowManager.getDefault().getMainWindow();
112
        MainWindow mw = MainWindow.getInstance();
113
        mw.initializeComponents();
113
        mw.initializeComponents();
114
        ToolbarPool tp = ToolbarPool.getDefault();
114
        ToolbarPool tp = ToolbarPool.getDefault();
115
        assertTrue(!findComponent(mw, tp));
115
        assertTrue(!findComponent(mw.getFrame(), tp));
116
    }
116
    }
117
117
118
    private static boolean findComponent(Container cont, Component comp) {
118
    private static boolean findComponent(Container cont, Component comp) {
(-)a/openide.windows/apichanges.xml (+16 lines)
Lines 50-55 Link Here
50
<apidef name="winsys">Window System API</apidef>
50
<apidef name="winsys">Window System API</apidef>
51
</apidefs>
51
</apidefs>
52
<changes>
52
<changes>
53
<change id="reuse.existing.frame.as.the.main.window">
54
    <api name="winsys"/>
55
    <summary>Reuse existing JFrame instance (if any) as IDE's main window.</summary>
56
    <version major="6" minor="36"/>
57
    <date day="23" month="1" year="2010"/>
58
    <author login="saubrecht"/>
59
    <compatibility addition="no" binary="compatible" source="compatible" semantic="compatible" deprecation="no" deletion="no" modification="no"/>
60
    <description>
61
        When window system loads it checks for existing Frames (java.awt.Frame.getFrames()) and
62
        if there is a JFrame whose name is "NbMainWindow" then it is reused as the main window.
63
        Main menu, toolbars and content pane will be put into this existing JFrame.
64
        If there isn't such a JFrame instance then a new empty JFrame is created
65
        and used for the main window - the same way as before this change.
66
    </description>
67
    <class package="org.netbeans.core.windows.view.ui" name="MainWindow"/>
68
</change>
53
69
54
<change id="retain.non.persistent.topcomponent.locations">
70
<change id="retain.non.persistent.topcomponent.locations">
55
    <api name="winsys"/>
71
    <api name="winsys"/>
(-)a/openide.windows/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.windows
2
OpenIDE-Module: org.openide.windows
3
OpenIDE-Module-Specification-Version: 6.35
3
OpenIDE-Module-Specification-Version: 6.36
4
OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties
5
AutoUpdate-Essential-Module: true
5
AutoUpdate-Essential-Module: true
6
6

Return to bug 192352