List<Component> () { List<Component> orderedComponents = new ArrayList<>(); List<ListPluginComponent> selectedComponents = getSelection(); Set<PluginsGroup> addedGroups = new HashSet<>(); for (ListPluginComponent component : selectedComponents) { PluginsGroup group = component.getGroup(); if (!addedGroups.contains(group)) { addedGroups.add(group); if (UIUtil.isFocusable(group.rightAction)) { orderedComponents.add(group.rightAction); } else if (!ContainerUtil.isEmpty(group.rightActions)) { orderedComponents.addAll(ContainerUtil.filter(group.rightActions, UIUtil::isFocusable)); } } orderedComponents.add(component); orderedComponents.addAll(component.getFocusableComponents()); } return orderedComponents; }