Search in sources :

Example 1 with IdeFrameImpl

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();
        }
    }
}
Also used : Condition(org.fest.swing.timing.Condition) 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) IdeFrame(com.intellij.openapi.wm.IdeFrame)

Example 2 with IdeFrameImpl

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();
    }
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) JBImageIcon(com.intellij.util.ui.JBImageIcon) IOException(java.io.IOException) JBImageIcon(com.intellij.util.ui.JBImageIcon) AnAction(com.intellij.openapi.actionSystem.AnAction) File(java.io.File)

Example 3 with IdeFrameImpl

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()));
}
Also used : Condition(org.fest.swing.timing.Condition) IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) Project(com.intellij.openapi.project.Project) GenericTypeMatcher(org.fest.swing.core.GenericTypeMatcher) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with IdeFrameImpl

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;
}
Also used : IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) IdeGlassPaneEx(com.intellij.openapi.wm.impl.IdeGlassPaneEx) FloatingDecorator(com.intellij.openapi.wm.impl.FloatingDecorator) JTextComponent(javax.swing.text.JTextComponent) JBPopup(com.intellij.openapi.ui.popup.JBPopup)

Example 5 with IdeFrameImpl

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();
    }
}
Also used : EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow) IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) FloatingDecorator(com.intellij.openapi.wm.impl.FloatingDecorator)

Aggregations

IdeFrameImpl (com.intellij.openapi.wm.impl.IdeFrameImpl)14 Project (com.intellij.openapi.project.Project)5 RelativePoint (com.intellij.ui.awt.RelativePoint)4 IdeFrame (com.intellij.openapi.wm.IdeFrame)3 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)2 ProgressManager (com.intellij.openapi.progress.ProgressManager)2 ComponentPopupBuilder (com.intellij.openapi.ui.popup.ComponentPopupBuilder)2 JBPopup (com.intellij.openapi.ui.popup.JBPopup)2 FloatingDecorator (com.intellij.openapi.wm.impl.FloatingDecorator)2 File (java.io.File)2 Robot (org.fest.swing.core.Robot)2 WindowFinder.findFrame (org.fest.swing.finder.WindowFinder.findFrame)2 Condition (org.fest.swing.timing.Condition)2 NotNull (org.jetbrains.annotations.NotNull)2 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 Editor (com.intellij.openapi.editor.Editor)1 EditorWindow (com.intellij.openapi.fileEditor.impl.EditorWindow)1 DumbService (com.intellij.openapi.project.DumbService)1 PopupChooserBuilder (com.intellij.openapi.ui.popup.PopupChooserBuilder)1