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

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

Introduction

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

Prototype

@NotNull
    public static IdeFocusManager findInstanceByComponent(@NotNull Component component) 

Source Link

Usage

From source file:automation.RobotControl.java

License:Apache License

public void navigateAndClickMenu(Component cmp, Runnable runnable, boolean horizontalFirst)
        throws InterruptedException {
    Point cmpLocationOnScreen = cmp.getLocationOnScreen();
    Rectangle bounds = cmp.getBounds();
    IdeFocusManager.findInstanceByComponent(cmp).requestFocus(cmp, true);
    Point clickPoint = new Point(cmpLocationOnScreen.x + bounds.width / 2,
            cmpLocationOnScreen.y + bounds.height / 2);

    navigateAndClickMenu(clickPoint, runnable, horizontalFirst);
}

From source file:automation.RobotControl.java

License:Apache License

public void navigateAndClick(Component cmp, Runnable runnable) throws Exception {
    Point cmpLocationOnScreen = cmp.getLocationOnScreen();
    Rectangle bounds = cmp.getBounds();
    IdeFocusManager.findInstanceByComponent(cmp).requestFocus(cmp, true);
    Point clickPoint = new Point(cmpLocationOnScreen.x + bounds.width / 2,
            cmpLocationOnScreen.y + bounds.height / 2);
    navigateAndClick(clickPoint, runnable);
}

From source file:automation.RobotControl.java

License:Apache License

public void navigateAndDoubleClick(Component cmp, Runnable runnable) throws Exception {
    Point cmpLocationOnScreen = cmp.getLocationOnScreen();
    Rectangle bounds = cmp.getBounds();
    IdeFocusManager.findInstanceByComponent(cmp).requestFocus(cmp, true);
    Point clickPoint = new Point(cmpLocationOnScreen.x + bounds.width / 2,
            cmpLocationOnScreen.y + bounds.height / 2);
    navigateAndDoubleClick(clickPoint, runnable);
}

From source file:automation.RobotControl.java

License:Apache License

public void navigateAndRightClick(Component cmp, Runnable runnable) throws Exception {
    Point cmpLocationOnScreen = cmp.getLocationOnScreen();
    Rectangle bounds = cmp.getBounds();
    IdeFocusManager.findInstanceByComponent(cmp).requestFocus(cmp, true);
    Point clickPoint = new Point(cmpLocationOnScreen.x + bounds.width / 2,
            cmpLocationOnScreen.y + bounds.height / 2);
    navigateAndRightClick(clickPoint, runnable);
}

From source file:automation.RobotControl.java

License:Apache License

public void navigateAndClickScript(Component cmp) throws Exception {
    Point cmpLocationOnScreen = cmp.getLocationOnScreen();
    Rectangle bounds = cmp.getBounds();
    IdeFocusManager.findInstanceByComponent(cmp).requestFocus(cmp, true);
    myRobot.mouseMove(cmpLocationOnScreen.x + bounds.width / 2, cmpLocationOnScreen.y + bounds.height / 2);
    //    MyLog.log("mouse moved");
    mouseClick();//from   w w w.j av  a2 s .c  om
    //    MyLog.log("mouse clicked");

}

From source file:com.android.tools.idea.wizard.dynamic.DynamicWizard.java

License:Apache License

private void showStep(@NotNull Step step) {
    JComponent component = step.getComponent();
    addStepIfNecessary(step);/*from   www  .  ja va2  s.c  om*/
    Icon icon = step.getIcon();
    myHost.setIcon(icon);
    ((CardLayout) myContentPanel.getLayout()).show(myContentPanel, myComponentToIdMap.get(component));

    JComponent focusedComponent = step.getPreferredFocusedComponent();
    if (focusedComponent != null) {
        IdeFocusManager.findInstanceByComponent(focusedComponent).requestFocus(focusedComponent, true);
    }
}

From source file:com.android.tools.idea.wizard.DynamicWizard.java

License:Apache License

private void showStep(@NotNull Step step) {
    JComponent component = step.getComponent();
    addStepIfNecessary(step);//from   w  ww . j av  a 2 s. c  om
    Icon icon = step.getIcon();
    myHost.setIcon(icon);
    ((CardLayout) myContentPanel.getLayout()).show(myContentPanel, myComponentToIdMap.get(component));

    JComponent focusedComponent = step.getPreferredFocusedComponent();
    if (focusedComponent != null) {
        IdeFocusManager.findInstanceByComponent(focusedComponent).requestFocus(focusedComponent, false);
    }
}

From source file:com.android.tools.idea.wizard.model.ModelWizard.java

License:Apache License

private void showCurrentStep() {
    ModelWizardStep step = mySteps.get(myCurrIndex);
    myTitle.set(step.getTitle());//from ww w. jav a  2 s.  c om
    myExtraAction.setNullableValue(step.getExtraAction());
    ((CardLayout) myContentPanel.getLayout()).show(myContentPanel, Integer.toString(myCurrIndex));

    JComponent focusedComponent = step.getPreferredFocusComponent();
    if (focusedComponent != null) {
        IdeFocusManager.findInstanceByComponent(focusedComponent).requestFocus(focusedComponent, false);
    }
}

From source file:com.intellij.codeInsight.template.impl.LiveTemplateSettingsEditor.java

License:Apache License

public void focusKey() {
    myKeyField.selectAll();//ww w.  j ava 2s  . c  o  m
    //todo[peter,kirillk] without these invokeLaters this requestFocus conflicts with com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.MyDialog.MyWindowListener.windowOpened()
    IdeFocusManager.findInstanceByComponent(myKeyField).requestFocus(myKeyField, true);
    final ModalityState modalityState = ModalityState.stateForComponent(myKeyField);
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            ApplicationManager.getApplication().invokeLater(new Runnable() {
                @Override
                public void run() {
                    ApplicationManager.getApplication().invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            IdeFocusManager.findInstanceByComponent(myKeyField).requestFocus(myKeyField, true);
                        }
                    }, modalityState);
                }
            }, modalityState);
        }
    }, modalityState);
}

From source file:com.intellij.diagnostic.IdeErrorsDialog.java

License:Apache License

@Override
protected JComponent createCenterPanel() {
    DefaultActionGroup goBack = new DefaultActionGroup();
    BackAction back = new BackAction();
    goBack.add(back);/*from  w ww. java  2  s  .  com*/
    ActionToolbar backToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, goBack,
            true);
    backToolbar.getComponent().setBorder(IdeBorderFactory.createEmptyBorder());
    backToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
    myBackButtonPanel.add(backToolbar.getComponent(), BorderLayout.CENTER);

    DefaultActionGroup goForward = new DefaultActionGroup();
    ForwardAction forward = new ForwardAction();
    goForward.add(forward);
    ActionToolbar forwardToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN,
            goForward, true);
    forwardToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
    forwardToolbar.getComponent().setBorder(IdeBorderFactory.createEmptyBorder());
    myNextButtonPanel.add(forwardToolbar.getComponent(), BorderLayout.CENTER);

    myTabs = new HeaderlessTabbedPane(getDisposable());
    final LabeledTextComponent.TextListener commentsListener = new LabeledTextComponent.TextListener() {
        @Override
        public void textChanged(String newText) {
            if (myMute) {
                return;
            }

            AbstractMessage message = getSelectedMessage();
            if (message != null) {
                message.setAdditionalInfo(newText);
            }
        }
    };
    if (!myInternalMode) {
        myDetailsTabForm = new DetailsTabForm(null, myInternalMode);
        myCommentsTabForm = new CommentsTabForm();
        myCommentsTabForm.addCommentsListener(commentsListener);
        myTabs.addTab(DiagnosticBundle.message("error.comments.tab.title"), myCommentsTabForm.getContentPane());
        myDetailsTabForm.setCommentsAreaVisible(false);
    } else {
        final AnAction analyzePlatformAction = ActionManager.getInstance()
                .getAction("AnalyzeStacktraceOnError");
        if (analyzePlatformAction != null) {
            myAnalyzeAction = new AnalyzeAction(analyzePlatformAction);
        }
        myDetailsTabForm = new DetailsTabForm(myAnalyzeAction, myInternalMode);
        myDetailsTabForm.setCommentsAreaVisible(true);
        myDetailsTabForm.addCommentsListener(commentsListener);
    }

    myTabs.addTab(DiagnosticBundle.message("error.details.tab.title"), myDetailsTabForm.getContentPane());

    myAttachmentsTabForm = new AttachmentsTabForm();
    myAttachmentsTabForm.addInclusionListener(new ChangeListener() {
        public void stateChanged(final ChangeEvent e) {
            updateAttachmentWarning(getSelectedMessage());
        }
    });

    int activeTabIndex = Integer.parseInt(PropertiesComponent.getInstance().getValue(ACTIVE_TAB_OPTION, "0"));
    if (activeTabIndex >= myTabs.getTabCount() || activeTabIndex < 0) {
        activeTabIndex = 0; // may happen if myInternalMode changed since last open
    }

    myTabs.setSelectedIndex(activeTabIndex);

    myTabs.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            final JComponent c = getPreferredFocusedComponent();
            if (c != null) {
                IdeFocusManager.findInstanceByComponent(myContentPane).requestFocus(c, true);
            }
        }
    });

    myTabsPanel.add(myTabs, BorderLayout.CENTER);

    myDisableLink
            .setHyperlinkText(UIUtil.removeMnemonic(DiagnosticBundle.message("error.list.disable.plugin")));
    myDisableLink.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                disablePlugin();
            }
        }
    });

    myCredentialsLabel.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                new JetBrainsAccountDialog(getRootPane()).show();
                updateCredentialsPane(getSelectedMessage());
            }
        }
    });

    myAttachmentWarningLabel.setIcon(UIUtil.getBalloonWarningIcon());
    myAttachmentWarningLabel.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(final HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                myTabs.setSelectedIndex(myTabs.indexOfComponent(myAttachmentsTabForm.getContentPane()));
                myAttachmentsTabForm.selectFirstIncludedAttachment();
            }
        }
    });

    myDetailsTabForm.addAssigneeListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (myMute)
                return;

            AbstractMessage message = getSelectedMessage();
            if (message != null) {
                message.setAssigneeId(myDetailsTabForm.getAssigneeId());
            }
        }
    });

    return myContentPane;
}