void (@NotNull List<? extends AnAction> actions, boolean layoutSecondaries) { boolean isLastElementSeparator = false; List<AnAction> rightAligned = new ArrayList<>(); for (int i = 0; i < actions.size(); i++) { AnAction action = actions.get(i); if (isAlignmentEnabled() && action instanceof RightAlignedToolbarAction || forceRightAlignment()) { rightAligned.add(action); continue; } if (layoutSecondaries) { if (!myActionGroup.isPrimary(action)) { mySecondaryActions.add(action); continue; } } if (action instanceof Separator) { if (isLastElementSeparator) continue; if (i > 0 && i < actions.size() - 1) { add(SEPARATOR_CONSTRAINT, mySeparatorCreator.apply(myShowSeparatorTitles ? ((Separator)action).getText() : null)); isLastElementSeparator = true; continue; } } else if (action instanceof CustomComponentAction) { add(CUSTOM_COMPONENT_CONSTRAINT, getCustomComponent(action)); } else { add(ACTION_BUTTON_CONSTRAINT, createToolbarButton(action)); } isLastElementSeparator = false; } if (mySecondaryActions.getChildrenCount() > 0) { mySecondaryActionsButton = new ActionButton(mySecondaryActions, myPresentationFactory.getPresentation(mySecondaryActions), myPlace, getMinimumButtonSize()) { @Override protected String getShortcutText() { String shortcut = myPresentation.getClientProperty(SECONDARY_SHORTCUT); return shortcut != null ? shortcut : super.getShortcutText(); } }; mySecondaryActionsButton.setNoIconsInPopup(true); add(SECONDARY_ACTION_CONSTRAINT, mySecondaryActionsButton); } for (AnAction action : rightAligned) { JComponent button = action instanceof CustomComponentAction ? getCustomComponent(action) : createToolbarButton(action); if (!isInsideNavBar()) { button.putClientProperty(RIGHT_ALIGN_KEY, Boolean.TRUE); } add(button); } }