Search in sources :

Example 1 with ActionManagerEx

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

the class ActionMacroManager method checkCanCreateMacro.

public boolean checkCanCreateMacro(String name) {
    final ActionManagerEx actionManager = (ActionManagerEx) ActionManager.getInstance();
    final String actionId = ActionMacro.MACRO_ACTION_PREFIX + name;
    if (actionManager.getAction(actionId) != null) {
        if (Messages.showYesNoDialog(IdeBundle.message("message.macro.exists", name), IdeBundle.message("title.macro.name.already.used"), Messages.getWarningIcon()) != Messages.YES) {
            return false;
        }
        actionManager.unregisterAction(actionId);
        removeMacro(name);
    }
    return true;
}
Also used : ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx)

Example 2 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, @NotNull String actionId, boolean assertActionIsEnabled) {
    ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
    AnAction action = actionManager.getAction(actionId);
    assertNotNull(action);
    executeAction(editor, assertActionIsEnabled, action);
}
Also used : ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx)

Example 3 with ActionManagerEx

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

the class AntConfigurationImpl method updateRegisteredActions.

private void updateRegisteredActions() {
    final Project project = getProject();
    if (project.isDisposed()) {
        return;
    }
    final List<Pair<String, AnAction>> actionList = new ArrayList<>();
    for (final AntBuildFile buildFile : myBuildFiles) {
        final AntBuildModelBase model = (AntBuildModelBase) buildFile.getModel();
        String defaultTargetActionId = model.getDefaultTargetActionId();
        if (defaultTargetActionId != null) {
            final TargetAction action = new TargetAction(buildFile, TargetAction.DEFAULT_TARGET_NAME, new String[] { TargetAction.DEFAULT_TARGET_NAME }, null);
            actionList.add(new Pair<>(defaultTargetActionId, action));
        }
        collectTargetActions(model.getFilteredTargets(), actionList, buildFile);
        collectTargetActions(getMetaTargets(buildFile), actionList, buildFile);
    }
    //noinspection SynchronizeOnThis
    synchronized (this) {
        // unregister Ant actions
        ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
        final String[] oldIds = actionManager.getActionIds(AntConfiguration.getActionIdPrefix(project));
        for (String oldId : oldIds) {
            actionManager.unregisterAction(oldId);
        }
        final Set<String> registeredIds = StringSetSpinAllocator.alloc();
        try {
            for (Pair<String, AnAction> pair : actionList) {
                if (!registeredIds.contains(pair.first)) {
                    registeredIds.add(pair.first);
                    actionManager.registerAction(pair.first, pair.second);
                }
            }
        } finally {
            StringSetSpinAllocator.dispose(registeredIds);
        }
    }
}
Also used : CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) TargetAction(com.intellij.lang.ant.config.actions.TargetAction) AnAction(com.intellij.openapi.actionSystem.AnAction) ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx) Project(com.intellij.openapi.project.Project)

Example 4 with ActionManagerEx

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

the class AntKeymapExtension method createGroup.

public KeymapGroup createGroup(final Condition<AnAction> filtered, Project project) {
    final Map<AntBuildFile, KeymapGroup> buildFileToGroup = new HashMap<>();
    final KeymapGroup result = KeymapGroupFactory.getInstance().createGroup(KeyMapBundle.message("ant.targets.group.title"), AllIcons.Nodes.KeymapAnt);
    final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
    final String[] ids = actionManager.getActionIds(project != null ? AntConfiguration.getActionIdPrefix(project) : AntConfiguration.ACTION_ID_PREFIX);
    Arrays.sort(ids);
    if (project != null) {
        final AntConfiguration antConfiguration = AntConfiguration.getInstance(project);
        ApplicationManager.getApplication().runReadAction(() -> {
            for (final String id : ids) {
                if (filtered != null && !filtered.value(actionManager.getActionOrStub(id))) {
                    continue;
                }
                final AntBuildFile buildFile = antConfiguration.findBuildFileByActionId(id);
                if (buildFile != null) {
                    KeymapGroup subGroup = buildFileToGroup.get(buildFile);
                    if (subGroup == null) {
                        subGroup = KeymapGroupFactory.getInstance().createGroup(buildFile.getPresentableName());
                        buildFileToGroup.put(buildFile, subGroup);
                        result.addGroup(subGroup);
                    }
                    subGroup.addActionId(id);
                } else {
                    LOG.info("no buildfile found for actionId=" + id);
                }
            }
        });
    }
    return result;
}
Also used : AntBuildFile(com.intellij.lang.ant.config.AntBuildFile) HashMap(com.intellij.util.containers.HashMap) KeymapGroup(com.intellij.openapi.keymap.KeymapGroup) AntConfiguration(com.intellij.lang.ant.config.AntConfiguration) ActionManagerEx(com.intellij.openapi.actionSystem.ex.ActionManagerEx)

Example 5 with ActionManagerEx

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

the class AntToolwindowRegistrar method projectClosed.

@Override
public void projectClosed() {
    final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
    final String[] oldIds = actionManager.getActionIds(AntConfiguration.getActionIdPrefix(myProject));
    for (String oldId : oldIds) {
        actionManager.unregisterAction(oldId);
    }
}
Also used : 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