Example usage for com.intellij.openapi.wm IdeFocusManager typeAheadUntil

List of usage examples for com.intellij.openapi.wm IdeFocusManager typeAheadUntil

Introduction

In this page you can find the example usage for com.intellij.openapi.wm IdeFocusManager typeAheadUntil.

Prototype

@Deprecated
public void typeAheadUntil(ActionCallback done) 

Source Link

Usage

From source file:com.intellij.ide.navigationToolbar.NavBarListener.java

License:Apache License

@Override
public void keyPressed(final KeyEvent e) {
    if (!(e.isAltDown() || e.isMetaDown() || e.isControlDown() || myPanel.isNodePopupActive())) {
        if (!Character.isLetter(e.getKeyChar())) {
            return;
        }// w  ww  .ja v  a 2  s. c o  m

        final IdeFocusManager focusManager = IdeFocusManager.getInstance(myPanel.getProject());
        final ActionCallback firstCharTyped = new ActionCallback();
        focusManager.typeAheadUntil(firstCharTyped);
        myPanel.moveDown();
        //noinspection SSBasedInspection
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                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) {
                }
            }
        });
    }
}