Search in sources :

Example 26 with IdeFocusManager

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

the class NavBarListener method keyPressed.

@Override
public void keyPressed(final KeyEvent e) {
    if (!(e.isAltDown() || e.isMetaDown() || e.isControlDown() || myPanel.isNodePopupActive())) {
        if (!Character.isLetter(e.getKeyChar())) {
            return;
        }
        final IdeFocusManager focusManager = IdeFocusManager.getInstance(myPanel.getProject());
        final ActionCallback firstCharTyped = new ActionCallback();
        focusManager.typeAheadUntil(firstCharTyped);
        myPanel.moveDown();
        //noinspection SSBasedInspection
        SwingUtilities.invokeLater(() -> {
            try {
                final Robot robot = new Robot();
                final boolean shiftOn = e.isShiftDown();
                final int code = e.getKeyCode();
                if (shiftOn) {
                    robot.keyPress(KeyEvent.VK_SHIFT);
                }
                robot.keyPress(code);
                robot.keyRelease(code);
                //don't release Shift
                firstCharTyped.setDone();
            } catch (AWTException ignored) {
            }
        });
    }
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager)

Example 27 with IdeFocusManager

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

the class ThemeSelectionPanel method focus.

public void focus() {
    final Project project = myConfiguration.getModule().getProject();
    final IdeFocusManager focusManager = project.isDefault() ? IdeFocusManager.getGlobalInstance() : IdeFocusManager.getInstance(project);
    focusManager.doWhenFocusSettlesDown(new Runnable() {

        @Override
        public void run() {
            focusManager.requestFocus(myThemeList, true);
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager)

Aggregations

IdeFocusManager (com.intellij.openapi.wm.IdeFocusManager)27 Project (com.intellij.openapi.project.Project)6 IdeFrame (com.intellij.openapi.wm.IdeFrame)5 NotNull (org.jetbrains.annotations.NotNull)4 FocusManagerImpl (com.intellij.openapi.wm.impl.FocusManagerImpl)3 DataManager (com.intellij.ide.DataManager)2 Disposable (com.intellij.openapi.Disposable)2 PersistentStateComponent (com.intellij.openapi.components.PersistentStateComponent)2 AsyncResult (com.intellij.openapi.util.AsyncResult)2 Nullable (org.jetbrains.annotations.Nullable)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Patches (com.intellij.Patches)1 DaemonCodeAnalyzer (com.intellij.codeInsight.daemon.DaemonCodeAnalyzer)1 PsiElement2UsageTargetAdapter (com.intellij.find.findUsages.PsiElement2UsageTargetAdapter)1 AllIcons (com.intellij.icons.AllIcons)1 IdeBundle (com.intellij.ide.IdeBundle)1 CopyReferenceAction (com.intellij.ide.actions.CopyReferenceAction)1 GotoFileAction (com.intellij.ide.actions.GotoFileAction)1 DarculaTextBorder (com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder)1 DarculaTextFieldUI (com.intellij.ide.ui.laf.darcula.ui.DarculaTextFieldUI)1