boolean (@NotNull List<PyPackage> packages) { try { Map<String, Set<PyPackage>> dependentPackages = collectDependents(packages, mySdk); if (dependentPackages.isEmpty()) { return false; } boolean[] warning = {true}; ApplicationManager.getApplication().invokeAndWait(() -> { if (dependentPackages.size() == 1) { Map.Entry<String, Set<PyPackage>> packageToDependents = ContainerUtil.getOnlyItem(dependentPackages.entrySet()); assert packageToDependents != null; Set<PyPackage> dependents = packageToDependents.getValue(); String message = PyBundle.message("python.packaging.dialog.description.attempt.to.uninstall.for.one.dependent.package", packageToDependents.getKey(), StringUtil.join(dependents, ", "), dependents.size()); warning[0] = MessageDialogBuilder.yesNo(PyBundle.message("python.packaging.warning"), message) .asWarning() .ask(myProject); } else { List<String> dep = new ArrayList<>(); for (Map.Entry<String, Set<PyPackage>> entry : dependentPackages.entrySet()) { dep.add(PyBundle.message( "python.packaging.dialog.description.attempt.to.uninstall.for.several.dependent.packages.single.package.description", entry.getKey(), StringUtil.join(entry.getValue(), ", "))); } String message = PyBundle.message("python.packaging.dialog.description.attempt.to.uninstall.for.several.dependent.packages", StringUtil.join(dep, "\n")); warning[0] = MessageDialogBuilder.yesNo(PyBundle.message("python.packaging.warning"), message) .asWarning() .ask(myProject); } }, ModalityState.current()); if (!warning[0]) { return true; } } catch (ExecutionException e) { LOG.info("Error loading packages dependents: " + e.getMessage(), e); } return false; }