use of com.intellij.openapi.wm.impl.IdeFrameImpl in project intellij-community by JetBrains.
the class GuiTestUtil method waitForIdeToStart.
// Called by IdeTestApplication via reflection.
@SuppressWarnings("UnusedDeclaration")
public static void waitForIdeToStart() {
GuiActionRunner.executeInEDT(false);
Robot robot = null;
try {
robot = BasicRobot.robotWithCurrentAwtHierarchy();
final MyProjectManagerListener listener = new MyProjectManagerListener();
//[ACCEPT IntelliJ IDEA Privacy Policy Agreement]
acceptAgreementIfNeeded(robot);
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(LONG_TIMEOUT.duration()).using(robot);
if (listener.myActive) {
Pause.pause(new Condition("Project to be opened") {
@Override
public boolean test() {
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;
}
}, LONG_TIMEOUT);
}
} finally {
GuiActionRunner.executeInEDT(true);
if (robot != null) {
robot.cleanUpWithoutDisposingWindows();
}
}
}
use of com.intellij.openapi.wm.impl.IdeFrameImpl in project intellij-community by JetBrains.
the class CustomActionsSchema method initActionIcons.
private void initActionIcons() {
ActionManager actionManager = ActionManager.getInstance();
for (String actionId : myIconCustomizations.keySet()) {
final AnAction anAction = actionManager.getAction(actionId);
if (anAction != null) {
Icon icon;
final String iconPath = myIconCustomizations.get(actionId);
if (iconPath != null && new File(FileUtil.toSystemDependentName(iconPath)).exists()) {
Image image = null;
try {
image = ImageLoader.loadFromStream(VfsUtilCore.convertToURL(VfsUtil.pathToUrl(iconPath)).openStream());
} catch (IOException e) {
LOG.debug(e);
}
icon = image == null ? null : new JBImageIcon(image);
} else {
icon = AllIcons.Toolbar.Unknown;
}
anAction.getTemplatePresentation().setIcon(icon);
anAction.getTemplatePresentation().setDisabledIcon(IconLoader.getDisabledIcon(icon));
anAction.setDefaultIcon(false);
}
}
final IdeFrameImpl frame = WindowManagerEx.getInstanceEx().getFrame(null);
if (frame != null) {
frame.updateView();
}
}
use of com.intellij.openapi.wm.impl.IdeFrameImpl in project intellij-community by JetBrains.
the class IdeFrameFixture method find.
@NotNull
public static IdeFrameFixture find(@NotNull final Robot robot, @Nullable final File projectPath, @Nullable final String projectName) {
final GenericTypeMatcher<IdeFrameImpl> matcher = new GenericTypeMatcher<IdeFrameImpl>(IdeFrameImpl.class) {
@Override
protected boolean isMatching(@NotNull IdeFrameImpl frame) {
Project project = frame.getProject();
if (projectPath == null && project != null)
return true;
if (project != null && PathManager.getAbsolutePath(projectPath.getPath()).equals(PathManager.getAbsolutePath(project.getBasePath()))) {
return projectName == null || projectName.equals(project.getName());
}
return false;
}
};
Pause.pause(new Condition("IdeFrame " + (projectPath != null ? quote(projectPath.getPath()) : "") + " to show up") {
@Override
public boolean test() {
Collection<IdeFrameImpl> frames = robot.finder().findAll(matcher);
return !frames.isEmpty();
}
}, GuiTestUtil.LONG_TIMEOUT);
IdeFrameImpl ideFrame = robot.finder().find(matcher);
return new IdeFrameFixture(robot, ideFrame, new File(ideFrame.getProject().getBasePath()));
}
use of com.intellij.openapi.wm.impl.IdeFrameImpl in project intellij-community by JetBrains.
the class IdeKeyEventDispatcher method isModalContext.
/**
* @return {@code true} if and only if the {@code component} represents
* modal context.
* @throws IllegalArgumentException if {@code component} is {@code null}.
*/
public static boolean isModalContext(@NotNull Component component) {
Window window = UIUtil.getWindow(component);
if (window instanceof IdeFrameImpl) {
final Component pane = ((IdeFrameImpl) window).getGlassPane();
if (pane instanceof IdeGlassPaneEx) {
return ((IdeGlassPaneEx) pane).isInModalContext();
}
}
if (window instanceof JDialog) {
final JDialog dialog = (JDialog) window;
if (!dialog.isModal()) {
final Window owner = dialog.getOwner();
return owner != null && isModalContext(owner);
}
}
if (window instanceof JFrame) {
return false;
}
boolean isFloatingDecorator = window instanceof FloatingDecorator;
boolean isPopup = !(component instanceof JFrame) && !(component instanceof JDialog);
if (isPopup) {
if (component instanceof JWindow) {
JBPopup popup = (JBPopup) ((JWindow) component).getRootPane().getClientProperty(JBPopup.KEY);
if (popup != null) {
return popup.isModalContext();
}
}
}
return !isFloatingDecorator;
}
use of com.intellij.openapi.wm.impl.IdeFrameImpl in project intellij-community by JetBrains.
the class RequestFocusInEditorComponentCmd method run.
public final void run() {
try {
if (myTimestamp.isExpired()) {
final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (owner != null && owner == myComponent) {
myDoneCallback.setDone();
} else {
myDoneCallback.setRejected();
}
}
final Window owner = myComponent != null ? SwingUtilities.getWindowAncestor(myComponent) : null;
if (owner == null) {
myDoneCallback.setRejected();
return;
}
final Window activeFrame = IdeFrameImpl.getActiveFrame();
if (activeFrame != null && owner instanceof IdeFrameImpl && activeFrame != owner) {
myDoneCallback.setRejected();
return;
}
if (myComponent != null) {
final boolean forced = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == null;
myFocusManager.requestFocus(myComponent, myForced || forced).notifyWhenDone(myDoneCallback).doWhenDone(() -> {
if (SystemInfo.isLinux && Registry.is("suppress.focus.stealing"))
return;
// isn't active.
if (!owner.isActive()) {
final Window activeWindow = getActiveWindow(owner.getOwnedWindows());
if (activeWindow == null || (activeWindow instanceof FloatingDecorator)) {
//Thread.dumpStack();
//System.out.println("------------------------------------------------------");
owner.toFront();
}
}
});
} else {
myDoneCallback.setRejected();
}
} finally {
finish();
}
}
Aggregations