void (@NotNull PluginsGroup group, @NotNull List<? extends IdeaPluginDescriptor> descriptors, int groupIndex) { UIPluginGroup uiGroup = new UIPluginGroup(); group.ui = uiGroup; myGroups.add(groupIndex == -1 ? myGroups.size() : groupIndex, uiGroup); OpaquePanel panel = new OpaquePanel(new BorderLayout(), SECTION_HEADER_BACKGROUND) { @Override public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleOpaquePanelComponent(); } return accessibleContext; } protected class AccessibleOpaquePanelComponent extends AccessibleJComponent { @Override public String getAccessibleName() { return group.title; } @Override public AccessibleRole getAccessibleRole() { return AccessibilityUtils.GROUPED_ELEMENTS; } } }; panel.setBorder(JBUI.Borders.empty(4, 10)); JLabel title = new JLabel(group.title) { @Override public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); Container parent = getParent(); Insets insets = parent.getInsets(); size.width = Math.min(parent.getWidth() - insets.left - insets.right - (parent.getComponentCount() == 2 ? parent.getComponent(1).getWidth() + JBUIScale.scale(20) : 0), size.width); return size; } @Override public String getToolTipText() { return super.getPreferredSize().width > getWidth() ? super.getToolTipText() : null; } }; title.setToolTipText(group.title); title.setForeground(SECTION_HEADER_FOREGROUND); panel.add(title, BorderLayout.WEST); group.titleLabel = title; if (group.rightAction != null) { panel.add(group.rightAction, BorderLayout.EAST); } else if (!ContainerUtil.isEmpty(group.rightActions)) { JPanel actions = new NonOpaquePanel(new HorizontalLayout(JBUIScale.scale(5))); panel.add(actions, BorderLayout.EAST); for (JComponent action : group.rightActions) { actions.add(action); } } int index; int eventIndex; if (groupIndex == 0) { add(panel, 0); index = 1; eventIndex = 0; } else if (groupIndex == -1) { add(panel); index = eventIndex = -1; } else { assert groupIndex < myGroups.size(); index = getComponentIndex(myGroups.get(groupIndex + 1).panel); assert index != -1; add(panel, index++); eventIndex = getEventIndexForGroup(groupIndex + 1); } uiGroup.panel = panel; addToGroup(group, descriptors, index, eventIndex); }