Search in sources :

Example 16 with ActionManagerEx

use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.

the class MacrosGroup method getChildren.

@NotNull
public AnAction[] getChildren(@Nullable AnActionEvent e) {
    ArrayList<AnAction> actions = new ArrayList<>();
    final ActionManagerEx actionManager = ((ActionManagerEx) ActionManager.getInstance());
    String[] ids = actionManager.getActionIds(ActionMacro.MACRO_ACTION_PREFIX);
    for (String id : ids) {
        actions.add(actionManager.getAction(id));
    }
    return actions.toArray(new AnAction[actions.size()]);
}
Also used : ArrayList(java.util.ArrayList) AnAction(com.intellij.openapi.actionSystem.AnAction) ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with ActionManagerEx

use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.

the class ActionButton method performAction.

private void performAction(MouseEvent e) {
    AnActionEvent event = AnActionEvent.createFromInputEvent(e, myPlace, myPresentation, getDataContext());
    if (!ActionUtil.lastUpdateAndCheckDumb(myAction, event, false)) {
        return;
    }
    if (isButtonEnabled()) {
        final ActionManagerEx manager = ActionManagerEx.getInstanceEx();
        final DataContext dataContext = event.getDataContext();
        manager.fireBeforeActionPerformed(myAction, dataContext, event);
        Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
        if (component != null && !component.isShowing()) {
            return;
        }
        actionPerformed(event);
        manager.queueActionPerformedEvent(myAction, dataContext, event);
    }
}
Also used : ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx)

Example 18 with ActionManagerEx

use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.

the class EditorTestUtil method executeAction.

public static void executeAction(@NotNull Editor editor, boolean assertActionIsEnabled, @NotNull AnAction action) {
    AnActionEvent event = AnActionEvent.createFromAnAction(action, null, "", createEditorContext(editor));
    action.beforeActionPerformedUpdate(event);
    if (!event.getPresentation().isEnabled()) {
        assertFalse("Action " + action + " is disabled", assertActionIsEnabled);
        return;
    }
    ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
    actionManager.fireBeforeActionPerformed(action, event.getDataContext(), event);
    action.actionPerformed(event);
    actionManager.fireAfterActionPerformed(action, event.getDataContext(), event);
}
Also used : ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx)

Example 19 with ActionManagerEx

use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.

the class IdeKeyEventDispatcher method processAction.

public boolean processAction(final InputEvent e, @NotNull ActionProcessor processor) {
    ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
    final Project project = CommonDataKeys.PROJECT.getData(myContext.getDataContext());
    final boolean dumb = project != null && DumbService.getInstance(project).isDumb();
    List<AnActionEvent> nonDumbAwareAction = new ArrayList<>();
    List<AnAction> actions = myContext.getActions();
    for (final AnAction action : actions.toArray(new AnAction[actions.size()])) {
        Presentation presentation = myPresentationFactory.getPresentation(action);
        // Mouse modifiers are 0 because they have no any sense when action is invoked via keyboard
        final AnActionEvent actionEvent = processor.createEvent(e, myContext.getDataContext(), ActionPlaces.MAIN_MENU, presentation, ActionManager.getInstance());
        try (AccessToken ignored = ProhibitAWTEvents.start("update")) {
            ActionUtil.performDumbAwareUpdate(LaterInvocator.isInModalContext(), action, actionEvent, true);
        }
        if (dumb && !action.isDumbAware()) {
            if (!Boolean.FALSE.equals(presentation.getClientProperty(ActionUtil.WOULD_BE_ENABLED_IF_NOT_DUMB_MODE))) {
                nonDumbAwareAction.add(actionEvent);
            }
            continue;
        }
        if (!presentation.isEnabled()) {
            continue;
        }
        processor.onUpdatePassed(e, action, actionEvent);
        if (myContext.getDataContext() instanceof DataManagerImpl.MyDataContext) {
            // this is not true for test data contexts
            ((DataManagerImpl.MyDataContext) myContext.getDataContext()).setEventCount(IdeEventQueue.getInstance().getEventCount(), this);
        }
        actionManager.fireBeforeActionPerformed(action, actionEvent.getDataContext(), actionEvent);
        Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(actionEvent.getDataContext());
        if (component != null && !component.isShowing()) {
            return true;
        }
        ((TransactionGuardImpl) TransactionGuard.getInstance()).performUserActivity(() -> processor.performAction(e, action, actionEvent));
        actionManager.fireAfterActionPerformed(action, actionEvent.getDataContext(), actionEvent);
        return true;
    }
    if (!nonDumbAwareAction.isEmpty()) {
        showDumbModeWarningLaterIfNobodyConsumesEvent(e, nonDumbAwareAction.toArray(new AnActionEvent[nonDumbAwareAction.size()]));
    }
    return false;
}
Also used : ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx) Project(com.intellij.openapi.project.Project) JTextComponent(javax.swing.text.JTextComponent)

Example 20 with ActionManagerEx

use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.

the class YYYYYYY method processKeyTyped.

private boolean processKeyTyped(char c) {
    // [vova] This is patch for Mac OS X. Under Mac "input methods"
    // is handled before our EventQueue consume upcoming KeyEvents.
    IdeEventQueue queue = IdeEventQueue.getInstance();
    if (queue.shouldNotTypeInEditor() || ProgressManager.getInstance().hasModalProgressIndicator()) {
        return false;
    }
    FileDocumentManager manager = FileDocumentManager.getInstance();
    final VirtualFile file = manager.getFile(myDocument);
    if (file != null && !file.isValid()) {
        return false;
    }
    ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
    DataContext dataContext = getDataContext();
    actionManager.fireBeforeEditorTyping(c, dataContext);
    MacUIUtil.hideCursor();
    EditorActionManager.getInstance().getTypedAction().actionPerformed(this, c, dataContext);
    return true;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DataContext(com.intellij.openapi.actionSystem.DataContext) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx)

Aggregations

ActionManagerEx (com.intellij.openapi.actionSystem.ex.ActionManagerEx)20 KeymapGroup (com.intellij.openapi.keymap.KeymapGroup)5 DataContext (com.intellij.openapi.actionSystem.DataContext)3 AnAction (com.intellij.openapi.actionSystem.AnAction)2 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)2 KeymapManagerEx (com.intellij.openapi.keymap.ex.KeymapManagerEx)2 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 HashMap (com.intellij.util.containers.HashMap)2 NotNull (org.jetbrains.annotations.NotNull)2 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)1 AntBuildFile (com.intellij.lang.ant.config.AntBuildFile)1 AntConfiguration (com.intellij.lang.ant.config.AntConfiguration)1 TargetAction (com.intellij.lang.ant.config.actions.TargetAction)1 MockApplication (com.intellij.mock.MockApplication)1 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)1 ActionToolbar (com.intellij.openapi.actionSystem.ActionToolbar)1 PluginId (com.intellij.openapi.extensions.PluginId)1 Group (com.intellij.openapi.keymap.impl.ui.Group)1 MouseShortcutPanel (com.intellij.openapi.keymap.impl.ui.MouseShortcutPanel)1