AnAction (@NotNull final ArtifactType type) { final List<? extends ArtifactTemplate> templates = type.getNewArtifactTemplates(myPackagingEditorContext); final ArtifactTemplate emptyTemplate = new ArtifactTemplate() { @Override public @Nls(capitalization = Nls.Capitalization.Title) String getPresentableName() { return JavaBundle.message("empty.title"); } @Override public NewArtifactConfiguration createArtifact() { final String name = "unnamed"; return new NewArtifactConfiguration(type.createRootElement(name), name, type); } }; if (templates.isEmpty()) { return new AddArtifactAction(type, emptyTemplate, type.getPresentableName(), type.getIcon()); } final DefaultActionGroup group = DefaultActionGroup.createPopupGroup(() -> type.getPresentableName()); group.getTemplatePresentation().setIcon(type.getIcon()); group.add(new AddArtifactAction(type, emptyTemplate, emptyTemplate.getPresentableName(), null)); group.addSeparator(); for (ArtifactTemplate template : templates) { group.add(new AddArtifactAction(type, template, template.getPresentableName(), null)); } return group; }