Example usage for com.intellij.openapi.actionSystem ActionPlaces ACTION_SEARCH

List of usage examples for com.intellij.openapi.actionSystem ActionPlaces ACTION_SEARCH

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem ActionPlaces ACTION_SEARCH.

Prototype

String ACTION_SEARCH

To view the source code for com.intellij.openapi.actionSystem ActionPlaces ACTION_SEARCH.

Click Source Link

Usage

From source file:com.intellij.ide.actions.GotoActionAction.java

License:Apache License

public static void performAction(Object element, @Nullable final Component component,
        @Nullable final AnActionEvent e) {
    // element could be AnAction (SearchEverywhere)
    final AnAction action = element instanceof AnAction ? (AnAction) element
            : ((GotoActionModel.ActionWrapper) element).getAction();
    if (action != null) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {
            @Override/*w  w w .  j a  va  2s  .  c o  m*/
            public void run() {
                if (component == null)
                    return;
                Presentation presentation = action.getTemplatePresentation().clone();
                DataContext context = DataManager.getInstance().getDataContext(component);
                AnActionEvent event = new AnActionEvent(e == null ? null : e.getInputEvent(), context,
                        ActionPlaces.ACTION_SEARCH, presentation, ActionManager.getInstance(),
                        e == null ? 0 : e.getModifiers());

                if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
                    if (action instanceof ActionGroup && ((ActionGroup) action).getChildren(event).length > 0) {
                        ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
                                presentation.getText(), (ActionGroup) action, context,
                                JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
                        if (component.isShowing()) {
                            popup.showInBestPositionFor(context);
                        } else {
                            popup.showInFocusCenter();
                        }
                    } else {
                        ActionUtil.performActionDumbAware(action, event);
                    }
                }
            }
        }, ModalityState.NON_MODAL);
    }
}