AbstractAddGroup (boolean fromPopup) { return new AbstractAddGroup(JavaUiBundle.message("add.new.header.text")) { @Override public AnAction @NotNull [] getChildren(@Nullable final AnActionEvent e) { AnAction addModuleAction = new AddModuleAction(false, fromPopup); addModuleAction.getTemplatePresentation().setText(JavaUiBundle.message("action.text.new.module")); List<AnAction> result = new ArrayList<>(); result.add(addModuleAction); AnAction importModuleAction = new AddModuleAction(true, fromPopup); importModuleAction.getTemplatePresentation().setText(JavaUiBundle.message("action.text.import.module")); importModuleAction.getTemplatePresentation().setIcon(AllIcons.ToolbarDecorator.Import); result.add(importModuleAction); final Collection<AnAction> actions = AddFacetToModuleAction.createAddFrameworkActions(myFacetEditorFacade, myProject); if (!actions.isEmpty()) { result.add(new Separator(JavaUiBundle.message("add.group.framework.separator"))); result.addAll(actions); } final NullableComputable<MyNode> selectedNodeRetriever = () -> { final TreePath selectionPath = myTree.getSelectionPath(); final Object lastPathComponent = selectionPath == null ? null : selectionPath.getLastPathComponent(); if (lastPathComponent instanceof MyNode) { return (MyNode)lastPathComponent; } return null; }; Collection<AnAction> actionsFromExtensions = new ArrayList<>(); for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) { actionsFromExtensions.addAll(extension.createAddActions(selectedNodeRetriever, TREE_UPDATER, myProject, myRoot)); } if (!actionsFromExtensions.isEmpty() && !result.isEmpty()) { result.add(new Separator()); } result.addAll(actionsFromExtensions); return result.toArray(AnAction.EMPTY_ARRAY); } }; }