@Override
  public void actionPerformed(@NotNull AnActionEvent e) {
    final Project project = getEventProject(e);
    assert project != null;
    if (!ProjectKt.isDirectoryBased(project)) {
      Messages.showErrorDialog(project, LangBundle.message("dialog.message.project.templates.do.support.old.ipr.file"), CommonBundle.getErrorTitle());
      return;
    }

    final VirtualFile descriptionFile = getDescriptionFile(project, LocalArchivedTemplate.DESCRIPTION_PATH);
    final SaveProjectAsTemplateDialog dialog = new SaveProjectAsTemplateDialog(project, descriptionFile);

    if (dialog.showAndGet()) {
      final Module moduleToSave = dialog.getModuleToSave();
      final Path file = dialog.getTemplateFile();
      final String description = dialog.getDescription();

      FileDocumentManager.getInstance().saveAllDocuments();

      ProgressManager.getInstance().run(new Task.Backgroundable(project, LangBundle.message("progress.title.saving.project.as.template"), true) {
        @Override
        public void run(@NotNull final ProgressIndicator indicator) {
          saveProject(project, file, moduleToSave, description, dialog.isReplaceParameters(), indicator, shouldEscape());
        }

        @Override
        public void onSuccess() {
          AnAction newProjectAction = ActionManager.getInstance().getAction(getNewProjectActionId());
          newProjectAction.getTemplatePresentation().setText(ActionsBundle.actionText("NewDirectoryProject"));
          AnAction manageAction = ActionManager.getInstance().getAction("ManageProjectTemplates");
          Notification notification = new Notification("Project Template",
                                                       LangBundle.message("notification.title.template.created"),
                                                       LangBundle.message("notification.content.was.successfully.created",
                                                                          FileUtilRt.getNameWithoutExtension(file.getFileName().toString())),
                                                       NotificationType.INFORMATION);
          notification.addAction(newProjectAction);
          if (manageAction != null) {
            notification.addAction(manageAction);
          }
          notification.notify(getProject());
        }

        @Override
        public void onCancel() {
          PathKt.delete(file);
        }
      });
    }
  }
@Override
  public void actionPerformed(@NotNull AnActionEvent e)