void (@NotNull final AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext); if (view == null) { return; } final Project project = CommonDataKeys.PROJECT.getData(dataContext); final PsiDirectory dir = view.getOrChooseDirectory(); if (dir == null || project == null) return; final CreateFileFromTemplateDialog.Builder builder = createDialogBuilder(project, dataContext); buildDialog(project, dir, builder); final Ref<String> selectedTemplateName = Ref.create(null); builder.show(getErrorTitle(), getDefaultTemplateName(dir), new CreateFileFromTemplateDialog.FileCreator<T>() { @Override public T createFile(@NotNull String name, @NotNull String templateName) { selectedTemplateName.set(templateName); return CreateFromTemplateAction.this.createFile(name, templateName, adjustDirectory(dir)); } @Override public boolean startInWriteAction() { return CreateFromTemplateAction.this.startInWriteAction(); } @Override @NotNull public String getActionName(@NotNull String name, @NotNull String templateName) { return CreateFromTemplateAction.this.getActionName(dir, name, templateName); } }, createdElement -> { if (createdElement != null) { Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); int offset = getOffsetToPreserve(editor); view.selectElement(createdElement); if (offset != -1 && editor != null && !editor.isDisposed()) { editor.getCaretModel().moveToOffset(offset); } try (var ignored = SlowOperations.allowSlowOperations(SlowOperations.ACTION_PERFORM)) { postProcess(createdElement, selectedTemplateName.get(), builder.getCustomProperties()); } } }); }