int (@NotNull DefaultActionGroup allActionsGroup, @NotNull Project project, @NotNull Function<? super RunnerAndConfigurationSettings, ? extends AnAction> createAction, @NotNull Function<? super @NlsSafe String, ? extends DefaultActionGroup> createFolder, @Nullable BiFunction<? super RunnerAndConfigurationSettings, String, ? extends AnAction> createSubAction) { int allConfigurationsNumber = 0; for (Map<String, List<RunnerAndConfigurationSettings>> structure : RunManagerImpl.getInstanceImpl(project).getConfigurationsGroupedByTypeAndFolder(true).values()) { final DefaultActionGroup actionGroup = new DefaultActionGroup(); for (Map.Entry<String, List<RunnerAndConfigurationSettings>> entry : structure.entrySet()) { @NlsSafe String folderName = entry.getKey(); DefaultActionGroup group = folderName == null ? actionGroup : createFolder.apply(folderName); group.getTemplatePresentation().setIcon(AllIcons.Nodes.Folder); List<RunnerAndConfigurationSettings> configurationsList = entry.getValue(); for (RunnerAndConfigurationSettings settings : configurationsList) { group.add(createAction.apply(settings)); if (createSubAction != null && group != actionGroup) { // Inline run configuration from folder to the top level popup. It may be hidden by default but shown on search. actionGroup.add(createSubAction.apply(settings, folderName)); } } if (group != actionGroup) { actionGroup.add(group); } allConfigurationsNumber += configurationsList.size(); } allActionsGroup.add(actionGroup); allActionsGroup.addSeparator(); } return allConfigurationsNumber; }