KeymapGroup (Condition<? super AnAction> condition, final Project project) { KeymapGroup result = KeymapGroupFactory.getInstance().createGroup( ExternalSystemBundle.message("external.system.keymap.group"), AllIcons.Nodes.ConfigFolder); AnAction[] externalSystemActions = ActionsTreeUtil.getActions("ExternalSystem.Actions"); for (AnAction action : externalSystemActions) { ActionsTreeUtil.addAction(result, action, condition); } if (project == null) return result; MultiMap<ProjectSystemId, String> projectToActionsMapping = MultiMap.create(); for (ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) { projectToActionsMapping.putValues(manager.getSystemId(), ContainerUtil.emptyList()); } ActionManager actionManager = ActionManager.getInstance(); if (actionManager != null) { for (String eachId : actionManager.getActionIdList(getActionPrefix(project, null))) { AnAction eachAction = actionManager.getAction(eachId); if (!(eachAction instanceof MyExternalSystemAction taskAction)) continue; if (condition != null && !condition.value(actionManager.getActionOrStub(eachId))) continue; projectToActionsMapping.putValue(taskAction.getSystemId(), eachId); } } Map<ProjectSystemId, KeymapGroup> keymapGroupMap = new HashMap<>(); for (ProjectSystemId systemId : projectToActionsMapping.keySet()) { if (!keymapGroupMap.containsKey(systemId)) { final Icon projectIcon = ExternalSystemUiUtil.getUiAware(systemId).getProjectIcon(); KeymapGroup group = KeymapGroupFactory.getInstance().createGroup(systemId.getReadableName(), projectIcon); keymapGroupMap.put(systemId, group); } } for (Map.Entry<ProjectSystemId, Collection<String>> each : projectToActionsMapping.entrySet()) { Collection<String> tasks = each.getValue(); final ProjectSystemId systemId = each.getKey(); final KeymapGroup systemGroup = keymapGroupMap.get(systemId); if (systemGroup == null) continue; for (String actionId : tasks) { systemGroup.addActionId(actionId); } if (systemGroup instanceof Group) { Icon icon = AllIcons.General.Add; ((Group)systemGroup).addHyperlink(new Hyperlink(icon, ExternalSystemBundle.message("link.label.choose.task.to.assign.shortcut")) { @Override public void onClick(MouseEvent e) { SelectExternalTaskDialog dialog = new SelectExternalTaskDialog(systemId, project); if (dialog.showAndGet() && dialog.getResult() != null) { TaskData taskData = dialog.getResult().second; String ownerModuleName = dialog.getResult().first; ExternalSystemTaskAction externalSystemAction = (ExternalSystemTaskAction)getOrRegisterAction(project, ownerModuleName, taskData); ApplicationManager.getApplication().getMessageBus().syncPublisher(KeymapListener.CHANGE_TOPIC).processCurrentKeymapChanged(); Settings allSettings = Settings.KEY.getData(DataManager.getInstance().getDataContext(e.getComponent())); KeymapPanel keymapPanel = allSettings != null ? allSettings.find(KeymapPanel.class) : null; if (keymapPanel != null) { // clear actions filter keymapPanel.showOption(""); keymapPanel.selectAction(externalSystemAction.myId); } } } }); } } for (KeymapGroup keymapGroup : keymapGroupMap.values()) { if (isGroupFiltered(condition, keymapGroup)) { result.addGroup(keymapGroup); } } for (ActionsProvider extension : ActionsProvider.EP_NAME.getExtensionList()) { KeymapGroup keymapGroup = extension.createGroup(condition, project); if (isGroupFiltered(condition, keymapGroup)) { result.addGroup(keymapGroup); } } return result; }