Search in sources :

Example 26 with ActionManager

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

the class AntToolwindowRegistrar method projectOpened.

@Override
public void projectOpened() {
    final KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
    final String prefix = AntConfiguration.getActionIdPrefix(myProject);
    final ActionManager actionManager = ActionManager.getInstance();
    for (Keymap keymap : keymapManager.getAllKeymaps()) {
        for (String id : keymap.getActionIdList()) {
            if (id.startsWith(prefix) && actionManager.getAction(id) == null) {
                actionManager.registerAction(id, new TargetActionStub(id, myProject));
            }
        }
    }
    final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
    compilerManager.addBeforeTask(new CompileTask() {

        @Override
        public boolean execute(CompileContext context) {
            final AntConfiguration config = AntConfiguration.getInstance(myProject);
            ((AntConfigurationBase) config).ensureInitialized();
            return config.executeTargetBeforeCompile(createDataContext(context));
        }
    });
    compilerManager.addAfterTask(new CompileTask() {

        @Override
        public boolean execute(CompileContext context) {
            final AntConfigurationBase config = (AntConfigurationBase) AntConfiguration.getInstance(myProject);
            config.ensureInitialized();
            if (context.getMessageCount(CompilerMessageCategory.ERROR) > 0) {
                final AntBuildTarget target = config.getTargetForEvent(ExecuteAfterCompilationEvent.getInstance());
                if (target != null) {
                    context.addMessage(CompilerMessageCategory.INFORMATION, "Skipping ant target \"" + target.getDisplayName() + "\" because of compilation errors", null, -1, -1);
                }
                return true;
            }
            return config.executeTargetAfterCompile(createDataContext(context));
        }
    });
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) TargetActionStub(com.intellij.lang.ant.config.actions.TargetActionStub) KeymapManagerEx(com.intellij.openapi.keymap.ex.KeymapManagerEx) AntConfiguration(com.intellij.lang.ant.config.AntConfiguration) AntBuildTarget(com.intellij.lang.ant.config.AntBuildTarget) Keymap(com.intellij.openapi.keymap.Keymap) AntConfigurationBase(com.intellij.lang.ant.config.AntConfigurationBase)

Example 27 with ActionManager

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

the class AddMultipleFilesOptionsDialog method createToolbar.

private JComponent createToolbar() {
    ActionManager actionManager = ActionManager.getInstance();
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new SelectAllAction());
    group.add(new UnselectAllAction());
    return actionManager.createActionToolbar(CvsActionPlaces.ADD_FILES_TOOLBAR, group, true).getComponent();
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 28 with ActionManager

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

the class MacGestureAdapter method swipedLeft.

@Override
public void swipedLeft(SwipeEvent event) {
    ActionManager actionManager = ActionManager.getInstance();
    AnAction forward = actionManager.getAction("Forward");
    if (forward == null)
        return;
    actionManager.tryToExecute(forward, createMouseEventWrapper(myFrame), null, null, false);
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 29 with ActionManager

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

the class TraverseUIStarter method processKeymap.

private static void processKeymap(Element configurableElement) {
    final ActionManager actionManager = ActionManager.getInstance();
    final String componentName = actionManager.getComponentName();
    final SearchableOptionsRegistrar searchableOptionsRegistrar = SearchableOptionsRegistrar.getInstance();
    final Set<String> ids = ((ActionManagerImpl) actionManager).getActionIds();
    final TreeSet<OptionDescription> options = new TreeSet<>();
    for (String id : ids) {
        final AnAction anAction = actionManager.getAction(id);
        final String text = anAction.getTemplatePresentation().getText();
        if (text != null) {
            collectOptions(searchableOptionsRegistrar, options, text, componentName);
        }
        final String description = anAction.getTemplatePresentation().getDescription();
        if (description != null) {
            collectOptions(searchableOptionsRegistrar, options, description, componentName);
        }
    }
    writeOptions(configurableElement, options);
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) ActionManagerImpl(com.intellij.openapi.actionSystem.impl.ActionManagerImpl) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 30 with ActionManager

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

the class ActionsWithoutUpdateMethodTest method testActionsWithShortcuts.

public void testActionsWithShortcuts() throws Exception {
    Set<String> ids = new HashSet<>();
    for (String id : ((ActionManagerImpl) ActionManager.getInstance()).getActionIds()) {
        for (Keymap keymap : KeymapManagerEx.getInstanceEx().getAllKeymaps()) {
            if (keymap.getShortcuts(id).length > 0 && !PLATFORM_WIDE_ACTIONS.contains(id)) {
                ids.add(id);
            }
        }
    }
    ActionManager mgr = ActionManager.getInstance();
    ArrayList<AnAction> failed = new ArrayList<>();
    for (String id : ids) {
        AnAction action = mgr.getAction(id);
        if (action == null) {
            System.out.println("Can't find action: " + id);
            continue;
        }
        Method updateMethod = action.getClass().getMethod("update", AnActionEvent.class);
        if (updateMethod.getDeclaringClass() == AnAction.class) {
            failed.add(action);
        }
    }
    for (AnAction action : failed) {
        System.out.println(action + " ID: " + mgr.getId(action) + " Class: " + action.getClass());
    }
    assertEmpty("The following actions have shortcuts, but don't have update() method redefined", failed);
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) ArrayList(java.util.ArrayList) ActionManagerImpl(com.intellij.openapi.actionSystem.impl.ActionManagerImpl) Method(java.lang.reflect.Method) AnAction(com.intellij.openapi.actionSystem.AnAction) Keymap(com.intellij.openapi.keymap.Keymap) HashSet(com.intellij.util.containers.HashSet)

Aggregations

ActionManager (com.intellij.openapi.actionSystem.ActionManager)43 AnAction (com.intellij.openapi.actionSystem.AnAction)27 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)15 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)4 ActionToolbar (com.intellij.openapi.actionSystem.ActionToolbar)4 MouseEvent (java.awt.event.MouseEvent)4 Keymap (com.intellij.openapi.keymap.Keymap)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 ActionPopupMenu (com.intellij.openapi.actionSystem.ActionPopupMenu)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 Presentation (com.intellij.openapi.actionSystem.Presentation)2 ActionManagerImpl (com.intellij.openapi.actionSystem.impl.ActionManagerImpl)2 Application (com.intellij.openapi.application.Application)2 ToolWindow (com.intellij.openapi.wm.ToolWindow)2 IntellijAzureActionManager (com.microsoft.azure.toolkit.intellij.common.action.IntellijAzureActionManager)2 File (java.io.File)2 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)1 CloudDebugHelpAction (com.google.cloud.tools.intellij.debugger.actions.CloudDebugHelpAction)1 DataManager (com.intellij.ide.DataManager)1