void (@NotNull FileChooserPanel panel, @NotNull AnActionEvent e) { var paths = panel.selectedPaths(); if (paths.isEmpty()) return; var project = e.getProject(); var ok = MessageDialogBuilder.yesNo(UIBundle.message("file.chooser.delete.title"), UIBundle.message("file.chooser.delete.confirm")) .yesText(ApplicationBundle.message("button.delete")).noText(CommonBundle.getCancelButtonText()) .icon(UIUtil.getWarningIcon()) .ask(project); if (!ok) return; try { var progress = IdeBundle.message("progress.deleting"); 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 { for (var path : paths) { if (indicator.isCanceled()) break; indicator.setText(path.toString()); NioFiles.deleteRecursively(path, p -> { indicator.checkCanceled(); indicator.setText2(path.relativize(p).toString()); }); } return null; } })); } catch (IOException ex) { Messages.showErrorDialog(panel.getComponent(), IoErrorText.message(ex), CommonBundle.getErrorTitle()); } }