Search in sources :

Example 26 with AnAction

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

the class ValueHint method createInspectTree.

public static InspectDebuggerTree createInspectTree(final NodeDescriptorImpl descriptor, Project project) {
    final InspectDebuggerTree tree = new InspectDebuggerTree(project);
    final AnAction setValueAction = ActionManager.getInstance().getAction(DebuggerActions.SET_VALUE);
    setValueAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)), tree);
    Disposer.register(tree, new Disposable() {

        @Override
        public void dispose() {
            setValueAction.unregisterCustomShortcutSet(tree);
        }
    });
    tree.setInspectDescriptor(descriptor);
    DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(project).getContext();
    tree.rebuild(context);
    return tree;
}
Also used : Disposable(com.intellij.openapi.Disposable) CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) InspectDebuggerTree(com.intellij.debugger.ui.impl.InspectDebuggerTree) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 27 with AnAction

use of com.intellij.openapi.actionSystem.AnAction in project ideavim by JetBrains.

the class ActionHandler method execute.

public boolean execute(@NotNull Editor editor, @NotNull final DataContext context, @NotNull ExCommand cmd) throws ExException {
    final String actionName = cmd.getArgument().trim();
    final AnAction action = ActionManager.getInstance().getAction(actionName);
    if (action == null) {
        VimPlugin.showMessage("Action not found: " + actionName);
        return false;
    }
    final Application application = ApplicationManager.getApplication();
    if (application.isUnitTestMode()) {
        executeAction(action, context, actionName);
    } else {
        UiHelper.runAfterGotFocus(new Runnable() {

            @Override
            public void run() {
                executeAction(action, context, actionName);
            }
        });
    }
    return true;
}
Also used : AnAction(com.intellij.openapi.actionSystem.AnAction) Application(com.intellij.openapi.application.Application)

Example 28 with AnAction

use of com.intellij.openapi.actionSystem.AnAction in project ideavim by JetBrains.

the class KeyHandler method executeAction.

/**
   * Execute an action by name
   *
   * @param name    The name of the action to execute
   * @param context The context to run it in
   */
public static boolean executeAction(@NotNull String name, @NotNull DataContext context) {
    ActionManager aMgr = ActionManager.getInstance();
    AnAction action = aMgr.getAction(name);
    return action != null && executeAction(action, context);
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 29 with AnAction

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

the class QuickChangeCodeStyleSchemeAction method fillActions.

@Override
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
    final CodeStyleSettingsManager manager = CodeStyleSettingsManager.getInstance(project);
    if (manager.PER_PROJECT_SETTINGS != null) {
        //noinspection HardCodedStringLiteral
        group.add(new AnAction("<project>", "", manager.USE_PER_PROJECT_SETTINGS ? ourCurrentAction : ourNotCurrentAction) {

            @Override
            public void actionPerformed(@NotNull AnActionEvent e) {
                manager.USE_PER_PROJECT_SETTINGS = true;
            }
        });
    }
    CodeStyleScheme currentScheme = CodeStyleSchemes.getInstance().getCurrentScheme();
    for (CodeStyleScheme scheme : CodeStyleSchemesImpl.getSchemeManager().getAllSchemes()) {
        addScheme(group, manager, currentScheme, scheme, false);
    }
}
Also used : CodeStyleSettingsManager(com.intellij.psi.codeStyle.CodeStyleSettingsManager) CodeStyleScheme(com.intellij.psi.codeStyle.CodeStyleScheme) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 30 with AnAction

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

the class AutoPopupController method setupListeners.

private void setupListeners() {
    ActionManagerEx.getInstanceEx().addAnActionListener(new AnActionListener() {

        @Override
        public void beforeActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {
            cancelAllRequest();
        }

        @Override
        public void beforeEditorTyping(char c, DataContext dataContext) {
            cancelAllRequest();
        }

        @Override
        public void afterActionPerformed(final AnAction action, final DataContext dataContext, AnActionEvent event) {
        }
    }, this);
    IdeEventQueue.getInstance().addActivityListener(() -> cancelAllRequest(), this);
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) AnActionListener(com.intellij.openapi.actionSystem.ex.AnActionListener) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

AnAction (com.intellij.openapi.actionSystem.AnAction)184 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)62 NotNull (org.jetbrains.annotations.NotNull)31 Project (com.intellij.openapi.project.Project)24 Nullable (org.jetbrains.annotations.Nullable)22 ActionManager (com.intellij.openapi.actionSystem.ActionManager)21 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)21 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)13 ArrayList (java.util.ArrayList)13 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)7 Presentation (com.intellij.openapi.actionSystem.Presentation)7 PsiFile (com.intellij.psi.PsiFile)7 ReopenProjectAction (com.intellij.ide.ReopenProjectAction)6 Editor (com.intellij.openapi.editor.Editor)6 Keymap (com.intellij.openapi.keymap.Keymap)6 Ref (com.intellij.openapi.util.Ref)6 List (java.util.List)6 DataContext (com.intellij.openapi.actionSystem.DataContext)5