use of com.intellij.openapi.keymap.ex.KeymapManagerEx in project intellij-community by JetBrains.
the class ActionsTreeUtil method createOtherGroup.
@NotNull
private static Group createOtherGroup(@Nullable Condition<AnAction> filtered, Group addedActions, @Nullable Keymap keymap) {
addedActions.initIds();
Set<String> result = new THashSet<>();
ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
if (keymap != null) {
for (String id : keymap.getActionIdList()) {
if (id.startsWith(EDITOR_PREFIX) && actionManager.getActionOrStub("$" + id.substring(6)) != null) {
continue;
}
if (!id.startsWith(QuickList.QUICK_LIST_PREFIX) && !addedActions.containsId(id)) {
result.add(id);
}
}
}
// add all registered actions
final KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
String[] registeredActionIds = actionManager.getActionIds("");
for (String id : registeredActionIds) {
final AnAction actionOrStub = actionManager.getActionOrStub(id);
if (actionOrStub instanceof ActionGroup && !((ActionGroup) actionOrStub).canBePerformed(DataManager.getInstance().getDataContext())) {
continue;
}
if (id.startsWith(QuickList.QUICK_LIST_PREFIX) || addedActions.containsId(id) || result.contains(id) || keymapManager.getBoundActions().contains(id)) {
continue;
}
result.add(id);
}
filterOtherActionsGroup(result);
Group group = new Group(KeyMapBundle.message("other.group.title"), AllIcons.Nodes.KeymapOther);
AnAction[] groupedActions = getActions("Other.KeymapGroup");
for (AnAction action : groupedActions) {
addAction(group, action, filtered);
}
result.removeAll(group.initIds());
for (String id : ContainerUtil.sorted(result, (id1, id2) -> getTextToCompare(id1).compareToIgnoreCase(getTextToCompare(id2)))) {
if (filtered == null || filtered.value(actionManager.getActionOrStub(id)))
group.addActionId(id);
}
return group;
}
use of com.intellij.openapi.keymap.ex.KeymapManagerEx in project intellij-community by JetBrains.
the class KeymapsTestCase method removeBoundActionIds.
private static void removeBoundActionIds(@NotNull Set<String> aids) {
KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
// explicitly bound to another action
for (Iterator<String> it = aids.iterator(); it.hasNext(); ) {
String id = it.next();
String sourceId = keymapManager.getActionBinding(id);
if (sourceId != null) {
it.remove();
}
}
}
use of com.intellij.openapi.keymap.ex.KeymapManagerEx 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));
}
});
}
use of com.intellij.openapi.keymap.ex.KeymapManagerEx in project intellij-community by JetBrains.
the class QuickChangeKeymapAction method fillActions.
@Override
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
KeymapManagerEx manager = (KeymapManagerEx) KeymapManager.getInstance();
Keymap current = manager.getActiveKeymap();
for (Keymap keymap : manager.getAllKeymaps()) {
addKeymapAction(group, manager, current, keymap, false);
}
}
use of com.intellij.openapi.keymap.ex.KeymapManagerEx in project intellij-community by JetBrains.
the class ActionsTreeUtil method createPluginsActionsGroup.
private static Group createPluginsActionsGroup(Condition<AnAction> filtered) {
Group pluginsGroup = new Group(KeyMapBundle.message("plugins.group.title"), null, null);
final KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
ActionManagerEx managerEx = ActionManagerEx.getInstanceEx();
final List<IdeaPluginDescriptor> plugins = new ArrayList<>();
Collections.addAll(plugins, PluginManagerCore.getPlugins());
Collections.sort(plugins, Comparator.comparing(IdeaPluginDescriptor::getName));
List<PluginId> collected = new ArrayList<>();
for (IdeaPluginDescriptor plugin : plugins) {
collected.add(plugin.getPluginId());
Group pluginGroup;
if (plugin.getName().equals("IDEA CORE")) {
continue;
} else {
pluginGroup = new Group(plugin.getName(), null, null);
}
final String[] pluginActions = managerEx.getPluginActions(plugin.getPluginId());
if (pluginActions.length == 0) {
continue;
}
Arrays.sort(pluginActions, Comparator.comparing(ActionsTreeUtil::getTextToCompare));
for (String pluginAction : pluginActions) {
if (keymapManager.getBoundActions().contains(pluginAction))
continue;
final AnAction anAction = managerEx.getActionOrStub(pluginAction);
if (filtered == null || filtered.value(anAction)) {
pluginGroup.addActionId(pluginAction);
}
}
if (pluginGroup.getSize() > 0) {
pluginsGroup.addGroup(pluginGroup);
}
}
for (PluginId pluginId : PluginId.getRegisteredIds().values()) {
if (collected.contains(pluginId))
continue;
Group pluginGroup = new Group(pluginId.getIdString(), null, null);
final String[] pluginActions = managerEx.getPluginActions(pluginId);
if (pluginActions.length == 0) {
continue;
}
for (String pluginAction : pluginActions) {
if (keymapManager.getBoundActions().contains(pluginAction))
continue;
final AnAction anAction = managerEx.getActionOrStub(pluginAction);
if (filtered == null || filtered.value(anAction)) {
pluginGroup.addActionId(pluginAction);
}
}
if (pluginGroup.getSize() > 0) {
pluginsGroup.addGroup(pluginGroup);
}
}
return pluginsGroup;
}
Aggregations