Search in sources :

Example 1 with WindowManagerImpl

use of com.intellij.openapi.wm.impl.WindowManagerImpl in project intellij-community by JetBrains.

the class GuiTestBase method closeAllProjects.

@SuppressWarnings("UnusedDeclaration")
protected // Called by GuiTestRunner via reflection.
void closeAllProjects() {
    pause(new Condition("Close all projects") {

        @Override
        public boolean test() {
            final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
            execute(new GuiTask() {

                @Override
                protected void executeInEDT() throws Throwable {
                    TransactionGuard.submitTransaction(ApplicationManager.getApplication(), () -> {
                        for (Project project : openProjects) {
                            assertTrue("Failed to close project " + quote(project.getName()), closeAndDispose(project));
                        }
                    });
                }
            });
            return ProjectManager.getInstance().getOpenProjects().length == 0;
        }
    }, SHORT_TIMEOUT);
    //noinspection ConstantConditions
    boolean welcomeFrameShown = execute(new GuiQuery<Boolean>() {

        @Override
        protected Boolean executeInEDT() throws Throwable {
            Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
            if (openProjects.length == 0) {
                WelcomeFrame.showNow();
                WindowManagerImpl windowManager = (WindowManagerImpl) WindowManager.getInstance();
                windowManager.disposeRootFrame();
                return true;
            }
            return false;
        }
    });
    if (welcomeFrameShown) {
        pause(new Condition("'Welcome' frame to show up") {

            @Override
            public boolean test() {
                for (Frame frame : Frame.getFrames()) {
                    if (frame == WelcomeFrame.getInstance() && frame.isShowing()) {
                        return true;
                    }
                }
                return false;
            }
        }, SHORT_TIMEOUT);
    }
}
Also used : Condition(org.fest.swing.timing.Condition) GuiTask(org.fest.swing.edt.GuiTask) Project(com.intellij.openapi.project.Project) WelcomeFrame(com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame) WindowManagerImpl(com.intellij.openapi.wm.impl.WindowManagerImpl)

Example 2 with WindowManagerImpl

use of com.intellij.openapi.wm.impl.WindowManagerImpl in project intellij-community by JetBrains.

the class RequestFocusInToolWindowCmd method updateFocusedComponentForWatcher.

private static void updateFocusedComponentForWatcher(final Component c) {
    final WindowWatcher watcher = ((WindowManagerImpl) WindowManager.getInstance()).getWindowWatcher();
    final FocusWatcher focusWatcher = watcher.getFocusWatcherFor(c);
    if (focusWatcher != null && c.isFocusOwner()) {
        focusWatcher.setFocusedComponentImpl(c);
    }
}
Also used : FocusWatcher(com.intellij.openapi.wm.FocusWatcher) WindowManagerImpl(com.intellij.openapi.wm.impl.WindowManagerImpl) WindowWatcher(com.intellij.openapi.wm.impl.WindowWatcher)

Aggregations

WindowManagerImpl (com.intellij.openapi.wm.impl.WindowManagerImpl)2 Project (com.intellij.openapi.project.Project)1 FocusWatcher (com.intellij.openapi.wm.FocusWatcher)1 WindowWatcher (com.intellij.openapi.wm.impl.WindowWatcher)1 WelcomeFrame (com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame)1 GuiTask (org.fest.swing.edt.GuiTask)1 Condition (org.fest.swing.timing.Condition)1