@Override
  protected void actionPerformed(@NotNull FileChooserPanel panel, @NotNull AnActionEvent e) {
    var directory = panel.currentDirectory();
    var fileType = e.getData(FileChooserKeys.NEW_FILE_TYPE);
    if (fileType == null || directory == null || directory.getFileSystem().isReadOnly()) return;

    var title = UIBundle.message("file.chooser.new.file.title");
    var prompt = UIBundle.message("file.chooser.new.file.prompt");
    var initial = "newFile." + fileType.getDefaultExtension();
    var selection = new TextRange(0, 7);
    var validator = new FileNameInputValidator(directory.getFileSystem());

    while (true) {
      var input = MessagesService.getInstance().showInputDialog(null, panel.getComponent(), prompt, title, null, initial, validator, selection, null);
      if (input == null) break;
      var name = input.trim();
      initial = name;
      selection = null;

      var progress = UIBundle.message("file.chooser.creating.progress", name);
      try {
        panel.reloadAfter(() -> ProgressManager.getInstance().run(new Task.WithResult<Path, IOException>(e.getProject(), panel.getComponent(), progress, true) {
          @Override
          protected Path compute(@NotNull ProgressIndicator indicator) throws IOException {
            indicator.setIndeterminate(true);
            var newFile = directory.resolve(name);
            NioFiles.createDirectories(newFile.getParent());
            var content = requireNonNullElse(e.getData(FileChooserKeys.NEW_FILE_TEMPLATE_TEXT), "");
            Files.writeString(newFile, content, StandardOpenOption.CREATE_NEW);
            return newFile;
          }
        }));
        break;
      }
      catch (IOException | InvalidPathException ex) {
        Messages.showErrorDialog(panel.getComponent(), IoErrorText.message(ex), CommonBundle.getErrorTitle());
      }
    }
  }
@Override
  protected void actionPerformed(@NotNull FileChooserPanel panel, @NotNull AnActionEvent e)