Example usage for com.intellij.openapi.actionSystem.ex ActionUtil lastUpdateAndCheckDumb

List of usage examples for com.intellij.openapi.actionSystem.ex ActionUtil lastUpdateAndCheckDumb

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem.ex ActionUtil lastUpdateAndCheckDumb.

Prototype

public static boolean lastUpdateAndCheckDumb(AnAction action, AnActionEvent e, boolean visibilityMatters) 

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//from www  .  j  a  va2  s.  co  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);
    }
}

From source file:com.intellij.ui.tabs.impl.ActionButton.java

License:Apache License

public void actionPerformed(final ActionEvent e) {
    AnActionEvent event = createAnEvent(null, e.getModifiers());
    if (event != null && ActionUtil.lastUpdateAndCheckDumb(myAction, event, true)) {
        ActionUtil.performActionDumbAware(myAction, event);
    }// w ww .  j a  v a  2s .c o m
}