void (@NotNull FileChooserPanel panel, @NotNull AnActionEvent e) { var directory = panel.currentDirectory(); if (directory == null || directory.getFileSystem().isReadOnly()) return; var title = UIBundle.message("file.chooser.new.dir.title"); var prompt = UIBundle.message("file.chooser.new.dir.prompt"); var initial = "newDirectory"; var selection = new TextRange(0, initial.length()); 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; try { var progress = UIBundle.message("file.chooser.creating.progress", name); 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 newDirectory = directory.resolve(name); if (Files.exists(newDirectory)) throw new FileAlreadyExistsException(newDirectory.toString()); NioFiles.createDirectories(newDirectory); return newDirectory; } })); break; } catch (IOException | InvalidPathException ex) { Messages.showErrorDialog(panel.getComponent(), IoErrorText.message(ex), CommonBundle.getErrorTitle()); } } }