void (final Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) { builder .setTitle(JavaBundle.message("action.create.new.class")) .addKind(JavaPsiBundle.message("node.class.tooltip"), IconManager.getInstance().getPlatformIcon(com.intellij.ui.PlatformIcons.Class), JavaTemplateUtil.INTERNAL_CLASS_TEMPLATE_NAME) .addKind(JavaPsiBundle.message("node.interface.tooltip"), PlatformIcons.INTERFACE_ICON, JavaTemplateUtil.INTERNAL_INTERFACE_TEMPLATE_NAME); if (HighlightingFeature.RECORDS.isAvailable(directory)) { builder.addKind(JavaPsiBundle.message("node.record.tooltip"), PlatformIcons.RECORD_ICON, JavaTemplateUtil.INTERNAL_RECORD_TEMPLATE_NAME); } LanguageLevel level = PsiUtil.getLanguageLevel(directory); if (level.isAtLeast(LanguageLevel.JDK_1_5)) { builder.addKind(JavaPsiBundle.message("node.enum.tooltip"), PlatformIcons.ENUM_ICON, JavaTemplateUtil.INTERNAL_ENUM_TEMPLATE_NAME); builder.addKind(JavaPsiBundle.message("node.annotation.tooltip"), PlatformIcons.ANNOTATION_TYPE_ICON, JavaTemplateUtil.INTERNAL_ANNOTATION_TYPE_TEMPLATE_NAME); } PsiDirectory[] dirs = {directory}; for (FileTemplate template : FileTemplateManager.getInstance(project).getAllTemplates()) { final @NotNull CreateFromTemplateHandler handler = FileTemplateUtil.findHandler(template); if (handler instanceof JavaCreateFromTemplateHandler && handler.handlesTemplate(template) && handler.canCreate(dirs)) { builder.addKind(template.getName(), JavaFileType.INSTANCE.getIcon(), template.getName()); } } builder.setValidator(new InputValidatorEx() { @Override public String getErrorText(String inputString) { if (inputString.length() > 0 && !PsiNameHelper.getInstance(project).isQualifiedName(inputString)) { return JavaErrorBundle.message("create.class.action.this.not.valid.java.qualified.name"); } String shortName = StringUtil.getShortName(inputString); if (HighlightClassUtil.isRestrictedIdentifier(shortName, level)) { return JavaErrorBundle.message("restricted.identifier", shortName); } return null; } @Override public boolean checkInput(String inputString) { return true; } @Override public boolean canClose(String inputString) { return !StringUtil.isEmptyOrSpaces(inputString) && getErrorText(inputString) == null; } }); }