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);
}
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;
}
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();
}
}
}
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;
}
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;
}
Aggregations