public final void disposeRootFrame() { if (myProject2Frame.size() == 1) { final IdeFrameImpl rootFrame = myProject2Frame.remove(null); if (rootFrame != null) { // disposing last frame if quitting rootFrame.dispose(); } } }
@Nullable public final StatusBar getStatusBar(final Project project) { if (!myProject2Frame.containsKey(project)) { return null; } final IdeFrameImpl frame = getFrame(project); LOG.assertTrue(frame != null); return frame.getStatusBar(); }
public void hideDialog(JDialog dialog, Project project) { if (project == null) { dialog.dispose(); } else { IdeFrameImpl frame = getFrame(project); if (frame.isActive()) { dialog.dispose(); } else { queueForDisposal(dialog, project); dialog.setVisible(false); } } }
public final IdeFrameImpl allocateFrame(final Project project) { LOG.assertTrue(!myProject2Frame.containsKey(project)); final IdeFrameImpl frame; if (myProject2Frame.containsKey(null)) { frame = myProject2Frame.get(null); myProject2Frame.remove(null); myProject2Frame.put(project, frame); frame.setProject(project); } else { frame = new IdeFrameImpl( (ApplicationInfoEx) ApplicationInfo.getInstance(), ActionManagerEx.getInstanceEx(), UISettings.getInstance(), DataManager.getInstance(), ApplicationManager.getApplication()); final Rectangle bounds = ProjectFrameBounds.getInstance(project).getBounds(); if (bounds != null) { frame.setBounds(bounds); } else if (myFrameBounds != null) { frame.setBounds(myFrameBounds); } frame.setExtendedState(myFrameExtendedState); frame.setProject(project); myProject2Frame.put(project, frame); frame.setVisible(true); } frame.addWindowListener(myActivationListener); myEventDispatcher.getMulticaster().frameCreated(frame); return frame; }
public final void writeExternal(final Element element) { // Save frame bounds final Element frameElement = new Element(FRAME_ELEMENT); element.addContent(frameElement); final Project[] projects = ProjectManager.getInstance().getOpenProjects(); final Project project; if (projects.length > 0) { project = projects[projects.length - 1]; } else { project = null; } final IdeFrameImpl frame = getFrame(project); if (frame != null) { int extendedState = frame.getExtendedState(); if (SystemInfo.isMacOSLion && frame.getPeer() instanceof FramePeer) { // frame.state is not updated by jdk so get it directly from peer extendedState = ((FramePeer) frame.getPeer()).getState(); } boolean usePreviousBounds = extendedState == Frame.MAXIMIZED_BOTH || isFullScreenSupportedInCurrentOS() && WindowManagerEx.getInstanceEx().isFullScreen(frame); Rectangle rectangle = usePreviousBounds ? myFrameBounds : frame.getBounds(); if (rectangle == null) { // frame is out of the screen? rectangle = ScreenUtil.getScreenRectangle(0, 0); } frameElement.setAttribute(X_ATTR, Integer.toString(rectangle.x)); frameElement.setAttribute(Y_ATTR, Integer.toString(rectangle.y)); frameElement.setAttribute(WIDTH_ATTR, Integer.toString(rectangle.width)); frameElement.setAttribute(HEIGHT_ATTR, Integer.toString(rectangle.height)); frameElement.setAttribute(EXTENDED_STATE_ATTR, Integer.toString(extendedState)); // Save default layout final Element layoutElement = new Element(DesktopLayout.TAG); element.addContent(layoutElement); myLayout.writeExternal(layoutElement); } }
public void showFrame() { final IdeFrameImpl frame = new IdeFrameImpl( myApplicationInfoEx, myActionManager, myUiSettings, myDataManager, ApplicationManager.getApplication()); myProject2Frame.put(null, frame); if (myFrameBounds == null || !ScreenUtil.isVisible( myFrameBounds)) { // avoid situations when IdeFrame is out of all screens Rectangle rect = ScreenUtil.getScreenRectangle(0, 0); int yParts = rect.height / 6; int xParts = rect.width / 5; myFrameBounds = new Rectangle(xParts, yParts, xParts * 3, yParts * 4); } frame.setBounds(myFrameBounds); frame.setVisible(true); frame.setExtendedState(myFrameExtendedState); }
public final void releaseFrame(final IdeFrameImpl frame) { myEventDispatcher.getMulticaster().beforeFrameReleased(frame); final Project project = frame.getProject(); LOG.assertTrue(project != null); frame.removeWindowListener(myActivationListener); proceedDialogDisposalQueue(project); frame.setProject(null); frame.setTitle(null); frame.setFileTitle(null, null); myProject2Frame.remove(project); Disposer.dispose(frame.getStatusBar()); frame.dispose(); }
public void setFullScreen(IdeFrameImpl frame, boolean fullScreen) { if (!isFullScreenSupportedInCurrentOS() || frame.isInFullScreen() == fullScreen) return; try { if (SystemInfo.isMacOSLion) { frame.getFrameDecorator().toggleFullScreen(fullScreen); return; } if (SystemInfo.isWindows) { GraphicsDevice device = ScreenUtil.getScreenDevice(frame.getBounds()); if (device == null) return; try { frame.getRootPane().putClientProperty(ScreenUtil.DISPOSE_TEMPORARY, Boolean.TRUE); if (fullScreen) { frame.getRootPane().putClientProperty("oldBounds", frame.getBounds()); } frame.dispose(); frame.setUndecorated(fullScreen); } finally { if (fullScreen) { frame.setBounds(device.getDefaultConfiguration().getBounds()); } else { Object o = frame.getRootPane().getClientProperty("oldBounds"); if (o instanceof Rectangle) { frame.setBounds((Rectangle) o); } } frame.setVisible(true); frame.getRootPane().putClientProperty(ScreenUtil.DISPOSE_TEMPORARY, null); } } } finally { frame.storeFullScreenStateIfNeeded(fullScreen); } }