diff --git a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java index f0610780dbbe..275121f6d33d 100644 --- a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java +++ b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -198,13 +198,13 @@ public class NewProjectUtil { if (newProject != projectToClose) { ProjectUtil.updateLastProjectLocation(projectFilePath); - if (WindowManager.isFullScreenSupportedInCurrentOS()) { + if (WindowManager.getInstance().isFullScreenSupportedInCurrentOS()) { IdeFocusManager instance = IdeFocusManager.findInstance(); IdeFrame lastFocusedFrame = instance.getLastFocusedFrame(); if (lastFocusedFrame != null) { boolean fullScreen = WindowManagerEx.getInstanceEx().isFullScreen((Frame)lastFocusedFrame); if (fullScreen) { - newProject.putUserData(IdeFrameImpl.SHOULD_OPEN_IN_FULLSCREEN, Boolean.TRUE); + newProject.putUserData(IdeFrameImpl.SHOULD_OPEN_IN_FULL_SCREEN, Boolean.TRUE); } } } diff --git a/platform/platform-api/src/com/intellij/openapi/wm/WindowManager.java b/platform/platform-api/src/com/intellij/openapi/wm/WindowManager.java index 5ffd2ada89f2..352e0bc54c3e 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/WindowManager.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/WindowManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,8 +62,6 @@ public abstract class WindowManager { return ApplicationManager.getApplication().getComponent(WindowManager.class); } - /** - */ public abstract void doNotSuggestAsParent(Window window); /** @@ -127,9 +125,9 @@ public abstract class WindowManager { public abstract void removeListener(WindowManagerListener listener); /** - * @return true if fullscreen mode is supported in current OS + * @return true if full screen mode is supported in current OS. */ - public static boolean isFullScreenSupportedInCurrentOS() { + public boolean isFullScreenSupportedInCurrentOS() { return SystemInfo.isMacOSLion || SystemInfo.isWindows; } } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ToggleFullScreenAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ToggleFullScreenAction.java index 0e2c097f4064..e8b8caf25d19 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ToggleFullScreenAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ToggleFullScreenAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.wm.IdeFocusManager; +import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.wm.ex.WindowManagerEx; import com.intellij.openapi.wm.impl.IdeFrameImpl; import org.jetbrains.annotations.Nullable; @@ -49,7 +49,7 @@ public class ToggleFullScreenAction extends AnAction implements DumbAware { public void update(final AnActionEvent e) { final Presentation p = e.getPresentation(); - final boolean isApplicable = (SystemInfo.isMac && SystemInfo.isMacOSLion) || SystemInfo.isWindows; + final boolean isApplicable = WindowManager.getInstance().isFullScreenSupportedInCurrentOS(); p.setVisible(isApplicable); p.setEnabled(isApplicable); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java index b9724de4adc1..034732dc5a3f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java @@ -71,11 +71,11 @@ import java.io.File; * @author Anton Katilin * @author Vladimir Kondratyev */ - -// Made non-final for Fabrique public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider { - public static final Key SHOULD_OPEN_IN_FULLSCREEN = Key.create("should.open.in.fullscreen"); + public static final Key SHOULD_OPEN_IN_FULL_SCREEN = Key.create("should.open.in.full.screen"); + private static final String FULL_SCREEN = "FullScreen"; + private String myTitle; private String myFileTitle; @@ -88,8 +88,8 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider { private final BalloonLayout myBalloonLayout; private static boolean myUpdatingTitle; private MacMainFrameDecorator myFrameDecorator; - - private boolean myRestoreFullscreen; + + private boolean myRestoreFullScreen; public IdeFrameImpl(ApplicationInfoEx applicationInfoEx, ActionManagerEx actionManager, UISettings uiSettings, DataManager dataManager, final Application application) { @@ -116,9 +116,9 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider { // to show window thumbnail under Macs // http://lists.apple.com/archives/java-dev/2009/Dec/msg00240.html if (SystemInfo.isMac) setIconImage(null); - // enable fullscreen titlebar button + // enable full screen title bar button if (SystemInfo.isMacOSLion && MacMainFrameDecorator.FULL_SCREEN_AVAILABLE) FullScreenUtilities.setWindowCanFullScreen(this, true); - + MouseGestureManager.getInstance().add(this); } @@ -189,7 +189,7 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider { ApplicationManagerEx.getApplicationEx().exit(); return; } - + final Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); if (openProjects.length > 1 || (openProjects.length == 1 && SystemInfo.isMacSystemMenu)) { if (myProject != null && myProject.isOpen()) { @@ -257,12 +257,12 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider { final Builder builder = new Builder(); if (SystemInfo.isMac) { builder.append(fileTitle).append(title) - .append(ProjectManager.getInstance().getOpenProjects().length == 0 + .append(ProjectManager.getInstance().getOpenProjects().length == 0 || ((ApplicationInfoEx)ApplicationInfo.getInstance()).isEAP() && !applicationName.endsWith("SNAPSHOT") ? applicationName : null); } else { builder.append(title).append(fileTitle).append(applicationName); } - + frame.setTitle(builder.sb.toString()); } finally { @@ -278,7 +278,7 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider { private static final class Builder { public StringBuilder sb = new StringBuilder(); - + public Builder append(@Nullable final String s) { if (s == null || s.length() == 0) return this; if (sb.length() > 0) sb.append(" - "); @@ -302,14 +302,14 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider { } public void setProject(final Project project) { - if (WindowManager.isFullScreenSupportedInCurrentOS() && myProject != project && project != null) { - myRestoreFullscreen = myProject == null && shouldRestoreFullScreen(project); - + if (WindowManager.getInstance().isFullScreenSupportedInCurrentOS() && myProject != project && project != null) { + myRestoreFullScreen = myProject == null && shouldRestoreFullScreen(project); + if (myProject != null) { storeFullScreenStateIfNeeded(false); // disable for old project } } - + myProject = project; if (project != null) { ProjectFrameBounds.getInstance(project); // make sure the service is initialized and its state will be saved @@ -329,23 +329,23 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider { if (project == null) { FocusTrackback.release(this); } - - if (isVisible() && myRestoreFullscreen) { + + if (isVisible() && myRestoreFullScreen) { WindowManagerEx.getInstanceEx().setFullScreen(this, true); - myRestoreFullscreen = false; + myRestoreFullScreen = false; } } @Override public void setVisible(boolean b) { super.setVisible(b); - - if (b && myRestoreFullscreen) { + + if (b && myRestoreFullScreen) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { WindowManagerEx.getInstanceEx().setFullScreen(IdeFrameImpl.this, true); - myRestoreFullscreen = false; + myRestoreFullScreen = false; } }); } @@ -427,22 +427,23 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider { } public void storeFullScreenStateIfNeeded(boolean state) { - if (!WindowManager.isFullScreenSupportedInCurrentOS()) return; - + if (!WindowManager.getInstance().isFullScreenSupportedInCurrentOS()) return; + if (myProject != null) { - PropertiesComponent.getInstance(myProject).setValue(FULL_SCREEN, Boolean.valueOf(state).toString()); + PropertiesComponent.getInstance(myProject).setValue(FULL_SCREEN, String.valueOf(state)); } } - public static boolean shouldRestoreFullScreen(Project project) { - if (!WindowManager.isFullScreenSupportedInCurrentOS() || project == null) return false; - return project.getUserData(SHOULD_OPEN_IN_FULLSCREEN) == Boolean.TRUE - || PropertiesComponent.getInstance(project).getBoolean(FULL_SCREEN, false); + public static boolean shouldRestoreFullScreen(@Nullable Project project) { + return WindowManager.getInstance().isFullScreenSupportedInCurrentOS() && + project != null && + (SHOULD_OPEN_IN_FULL_SCREEN.get(project) == Boolean.TRUE || PropertiesComponent.getInstance(project).getBoolean(FULL_SCREEN, false)); } @Override public void paint(Graphics g) { UIUtil.applyRenderingHints(g); + //noinspection Since15 super.paint(g); } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java index 0e4078452e99..3f07ae68d39a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -186,14 +186,14 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat } } }; - + bus.connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() { @Override public void appClosing() { - // save fullscreen window states + // save full screen window states if (isFullScreenSupportedInCurrentOS() && GeneralSettings.getInstance().isReopenLastProject()) { Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); - + if (openProjects.length > 0) { WindowManagerEx wm = WindowManagerEx.getInstanceEx(); for (Project project : openProjects) { @@ -821,10 +821,11 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat public WindowWatcher getWindowWatcher() { return myWindowWatcher; } - + public void setFullScreen(IdeFrameImpl frame, boolean fullScreen) { - if (!isFullScreenSupportedInCurrentOS() || frame.isInFullScreen() == fullScreen) + if (!isFullScreenSupportedInCurrentOS() || frame.isInFullScreen() == fullScreen) { return; + } try { if (SystemInfo.isMacOSLion) { diff --git a/platform/platform-impl/src/com/intellij/ui/mac/MacMainFrameDecorator.java b/platform/platform-impl/src/com/intellij/ui/mac/MacMainFrameDecorator.java index 444a778b4524..c6c38c8e6155 100644 --- a/platform/platform-impl/src/com/intellij/ui/mac/MacMainFrameDecorator.java +++ b/platform/platform-impl/src/com/intellij/ui/mac/MacMainFrameDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ public class MacMainFrameDecorator implements UISettingsListener, Disposable { } } public static final boolean FULL_SCREEN_AVAILABLE = SystemInfo.isJavaVersionAtLeast("1.6.0_29") && HAS_FULLSCREEN_UTILITIES; - + private static boolean SHOWN = false; private static Callback SET_VISIBLE_CALLBACK = new Callback() { @@ -157,9 +157,9 @@ public class MacMainFrameDecorator implements UISettingsListener, Disposable { if (rootPane != null) rootPane.putClientProperty(FULL_SCREEN, Boolean.TRUE); if (Patches.APPLE_BUG_ID_10207064) { // fix problem with bottom empty bar - // it seems like the title is still visible in fullscreen but the window itself shifted up for titlebar height + // it seems like the title is still visible in full screen but the window itself shifted up for title bar height // and the size of the frame is still calculated to be the height of the screen which is wrong - // so just add these titlebar height to the frame height once again + // so just add these title bar height to the frame height once again Timer timer = new Timer(300, new ActionListener() { @Override public void actionPerformed(ActionEvent e) {