List<AnAction> (boolean originalProvider) { DefaultActionGroup views = DefaultActionGroup.createPopupGroup(() -> LangBundle.message("action.change.view.text")); ChangeViewAction lastHeader = null; for (int i = 0; i < contentManager.getContentCount(); i++) { Content each = contentManager.getContent(i); if (each == null) continue; String id = each.getUserData(ID_KEY); String subId = each.getUserData(SUB_ID_KEY); ChangeViewAction newHeader = new ChangeViewAction(id, subId); if (lastHeader != null) { boolean lastHasKids = lastHeader.mySubId != null; boolean newHasKids = newHeader.mySubId != null; if (lastHasKids != newHasKids || lastHasKids && !Strings.areSameInstance(lastHeader.myId, newHeader.myId)) { views.add(Separator.getInstance()); } } views.add(newHeader); lastHeader = newHeader; } List<AnAction> result = new ArrayList<>(); result.add(views); result.add(Separator.getInstance()); if (actionGroup != null) { List<AnAction> secondary = new ArrayList<>(); for (AnAction each : actionGroup.getChildren(null)) { if (actionGroup.isPrimary(each)) { result.add(each); } else { secondary.add(each); } } result.add(Separator.getInstance()); result.addAll(secondary); } return result; }