Couple<DefaultActionGroup> (@NotNull ActionGroup actionGroup, @NotNull Function<? super AnAction, ? extends AnAction> wrapper, int mainButtonsNum) { DefaultActionGroup group = new DefaultActionGroup(); collectAllActions(group, actionGroup); AnAction[] actions = group.getChildren(null); DefaultActionGroup main = new DefaultActionGroup(); DefaultActionGroup more = new DefaultActionGroup(IdeBundle.message("welcome.screen.more.actions.link.text"), true); more.getTemplatePresentation().setHideGroupIfEmpty(true); for (AnAction child : actions) { if (!isActionAvailable(child)) continue; if (main.getChildrenCount() < mainButtonsNum) { main.addAction(wrapper.apply(child)); } else { more.addAction(wrapper.apply(child)); } } return Couple.of(main, more); }