DefaultActionGroup (List<? extends SettingsEditorFragment<Settings, ?>> fragments, Ref<? super JComponent> lastSelected) { fragments.sort(Comparator.comparingInt(SettingsEditorFragment::getMenuPosition)); DefaultActionGroup actionGroup = new DefaultActionGroup(); String group = null; for (SettingsEditorFragment<Settings, ?> fragment : restoreGroups(fragments)) { if (fragment.isRemovable() && !Objects.equals(group, fragment.getGroup())) { group = fragment.getGroup(); actionGroup.add(new Separator(group)); } ActionGroup customGroup = fragment.getCustomActionGroup(); if (customGroup != null) { actionGroup.add(customGroup); continue; } List<SettingsEditorFragment<Settings, ?>> children = fragment.getChildren(); if (children.isEmpty()) { ToggleFragmentAction action = new ToggleFragmentAction(fragment, lastSelected); ShortcutSet shortcutSet = ActionUtil.getMnemonicAsShortcut(action); if (shortcutSet != null) { action.registerCustomShortcutSet(shortcutSet, null); } actionGroup.add(action); } else { DefaultActionGroup childGroup = buildGroup(children, lastSelected); childGroup.getTemplatePresentation().setText(fragment.getChildrenGroupName()); actionGroup.add(childGroup); } } return actionGroup; }