boolean (final Set<File> filesToProcess, @NotNull final String targetDirPath, final Map<String, String> copiedFiles) { final Ref<Boolean> finished = Ref.create(false); new Task.Modal(myProject, JavaUiBundle.message("progress.title.0.library.files", myCopy ? "Copying" : "Moving"), true) { @Override public void run(@NotNull ProgressIndicator indicator) { final File targetDir = new File(FileUtil.toSystemDependentName(targetDirPath)); for (final File from : filesToProcess) { indicator.checkCanceled(); final File to = FileUtil.findSequentNonexistentFile(targetDir, FileUtilRt.getNameWithoutExtension(from.getName()), FileUtilRt.getExtension(from.getName())); try { if (from.isDirectory()) { if (myCopy) { FileUtil.copyDir(from, to); } else { FileUtil.moveDirWithContent(from, to); } } else { if (myCopy) { FileUtil.copy(from, to); } else { FileUtil.rename(from, to); } } } catch (IOException e) { String message = JavaUiBundle.message(myCopy ? "dialog.message.cannot.file.copy" : "dialog.message.cannot.file.move", from.getAbsolutePath(), e.getMessage()); String title = JavaUiBundle.message( myCopy ? "dialog.title.cannot.change.library.0.copy" : "dialog.title.cannot.change.library.0.move"); Messages.showErrorDialog(ChangeLibraryLevelActionBase.this.myProject, message, title); LOG.info(e); return; } copiedFiles.put(FileUtil.toSystemIndependentName(from.getAbsolutePath()), FileUtil.toSystemIndependentName(to.getAbsolutePath())); } finished.set(true); } }.queue(); if (!finished.get()) { return false; } WriteAction.run(() -> { for (Map.Entry<String, String> entry : copiedFiles.entrySet()) { String fromPath = entry.getKey(); String toPath = entry.getValue(); LocalFileSystem.getInstance().refreshAndFindFileByPath(toPath); if (!myCopy) { final VirtualFile parent = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(fromPath).getParentFile()); if (parent != null) { parent.refresh(false, false); } } } }); return true; }