Search in sources :

Example 26 with IdeFrame

use of com.intellij.openapi.wm.IdeFrame in project android by JetBrains.

the class Projects method open.

/**
   * Opens the given project in the IDE.
   *
   * @param project the project to open.
   */
public static void open(@NotNull Project project) {
    updateLastProjectLocation(project.getBasePath());
    if (WindowManager.getInstance().isFullScreenSupportedInCurrentOS()) {
        IdeFocusManager instance = IdeFocusManager.findInstance();
        IdeFrame lastFocusedFrame = instance.getLastFocusedFrame();
        if (lastFocusedFrame instanceof IdeFrameEx) {
            boolean fullScreen = ((IdeFrameEx) lastFocusedFrame).isInFullScreen();
            if (fullScreen) {
                project.putUserData(SHOULD_OPEN_IN_FULL_SCREEN, TRUE);
            }
        }
    }
    ProjectManagerEx.getInstanceEx().openProject(project);
}
Also used : IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) IdeFrame(com.intellij.openapi.wm.IdeFrame) IdeFrameEx(com.intellij.openapi.wm.ex.IdeFrameEx)

Example 27 with IdeFrame

use of com.intellij.openapi.wm.IdeFrame in project android by JetBrains.

the class GradleSyncInvoker method isBuildInProgress.

private static boolean isBuildInProgress(@NotNull Project project) {
    IdeFrame frame = ((WindowManagerEx) WindowManager.getInstance()).findFrameFor(project);
    StatusBarEx statusBar = frame == null ? null : (StatusBarEx) frame.getStatusBar();
    if (statusBar == null) {
        return false;
    }
    for (Pair<TaskInfo, ProgressIndicator> backgroundProcess : statusBar.getBackgroundProcesses()) {
        TaskInfo task = backgroundProcess.getFirst();
        if (task instanceof GradleTasksExecutor) {
            ProgressIndicator second = backgroundProcess.getSecond();
            if (second.isRunning()) {
                return true;
            }
        }
    }
    return false;
}
Also used : TaskInfo(com.intellij.openapi.progress.TaskInfo) GradleTasksExecutor(com.android.tools.idea.gradle.project.build.invoker.GradleTasksExecutor) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) IdeFrame(com.intellij.openapi.wm.IdeFrame) WindowManagerEx(com.intellij.openapi.wm.ex.WindowManagerEx) StatusBarEx(com.intellij.openapi.wm.ex.StatusBarEx)

Example 28 with IdeFrame

use of com.intellij.openapi.wm.IdeFrame in project android by JetBrains.

the class GuiTests method waitForIdeToStart.

// Called by IdeTestApplication via reflection.
@SuppressWarnings("UnusedDeclaration")
public static void waitForIdeToStart() {
    GuiActionRunner.executeInEDT(false);
    Robot robot = null;
    try {
        robot = BasicRobot.robotWithCurrentAwtHierarchy();
        MyProjectManagerListener listener = new MyProjectManagerListener();
        findFrame(new GenericTypeMatcher<Frame>(Frame.class) {

            @Override
            protected boolean isMatching(@NotNull Frame frame) {
                if (frame instanceof IdeFrame) {
                    if (frame instanceof IdeFrameImpl) {
                        listener.myActive = true;
                        ProjectManager.getInstance().addProjectManagerListener(listener);
                    }
                    return true;
                }
                return false;
            }
        }).withTimeout(TimeUnit.MINUTES.toMillis(2)).using(robot);
        // we attempt to clear here. All other events, including those posted by the Robot, will go through the IDE event queue.
        try {
            if (SYSTEM_EVENT_QUEUE.peekEvent() != null) {
                SYSTEM_EVENT_QUEUE.getNextEvent();
            }
        } catch (InterruptedException ex) {
        // Ignored.
        }
        if (listener.myActive) {
            Wait.seconds(1).expecting("project to be opened").until(() -> {
                boolean notified = listener.myNotified;
                if (notified) {
                    ProgressManager progressManager = ProgressManager.getInstance();
                    boolean isIdle = !progressManager.hasModalProgressIndicator() && !progressManager.hasProgressIndicator() && !progressManager.hasUnsafeProgressIndicator();
                    if (isIdle) {
                        ProjectManager.getInstance().removeProjectManagerListener(listener);
                    }
                    return isIdle;
                }
                return false;
            });
        }
    } finally {
        GuiActionRunner.executeInEDT(true);
        if (robot != null) {
            robot.cleanUpWithoutDisposingWindows();
        }
    }
}
Also used : IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) IdeFrame(com.intellij.openapi.wm.IdeFrame) WindowFinder.findFrame(org.fest.swing.finder.WindowFinder.findFrame) ProgressManager(com.intellij.openapi.progress.ProgressManager) Robot(org.fest.swing.core.Robot) BasicRobot(org.fest.swing.core.BasicRobot) IdeFrame(com.intellij.openapi.wm.IdeFrame)

Example 29 with IdeFrame

use of com.intellij.openapi.wm.IdeFrame in project intellij-plugins by JetBrains.

the class IDEAFacade method getProject.

@Nullable
public static Project getProject(Component component) {
    Project res = null;
    if (component != null) {
        res = (Project) getData(component, CommonDataKeys.PROJECT.getName());
    } else {
        IdeFrame[] frames = WindowManagerEx.getInstanceEx().getAllProjectFrames();
        for (IdeFrame frame : frames) {
            final IdeFrameImpl eachFrame = (IdeFrameImpl) frame;
            if (eachFrame.isActive()) {
                res = eachFrame.getProject();
                if (res != null)
                    break;
            }
        }
    }
    if (res == null) {
        Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
        res = openProjects.length > 0 ? openProjects[0] : null;
    }
    return res;
}
Also used : Project(com.intellij.openapi.project.Project) IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) IdeFrame(com.intellij.openapi.wm.IdeFrame) Nullable(org.jetbrains.annotations.Nullable)

Example 30 with IdeFrame

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

the class RestService method getLastFocusedOrOpenedProject.

@Nullable
protected static Project getLastFocusedOrOpenedProject() {
    IdeFrame lastFocusedFrame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame();
    Project project = lastFocusedFrame == null ? null : lastFocusedFrame.getProject();
    if (project == null) {
        Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
        return openProjects.length > 0 ? openProjects[0] : null;
    }
    return project;
}
Also used : Project(com.intellij.openapi.project.Project) IdeFrame(com.intellij.openapi.wm.IdeFrame) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

IdeFrame (com.intellij.openapi.wm.IdeFrame)49 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)7 Balloon (com.intellij.openapi.ui.popup.Balloon)5 IdeFocusManager (com.intellij.openapi.wm.IdeFocusManager)5 NotNull (org.jetbrains.annotations.NotNull)5 ProgressManager (com.intellij.openapi.progress.ProgressManager)4 MessageType (com.intellij.openapi.ui.MessageType)3 StatusBarEx (com.intellij.openapi.wm.ex.StatusBarEx)3 IdeFrameImpl (com.intellij.openapi.wm.impl.IdeFrameImpl)3 RelativePoint (com.intellij.ui.awt.RelativePoint)3 HyperlinkEvent (javax.swing.event.HyperlinkEvent)3 Application (com.intellij.openapi.application.Application)2 ApplicationActivationListener (com.intellij.openapi.application.ApplicationActivationListener)2 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2 ModalityState (com.intellij.openapi.application.ModalityState)2 Extensions (com.intellij.openapi.extensions.Extensions)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Ref (com.intellij.openapi.util.Ref)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2