void (List<? extends InstalledPackage> installedPackages, @NotNull Listener listener) { final String packageName = installedPackages.size() == 1 ? installedPackages.get(0).getName() : null; final PyPackageManagerUI ui = new PyPackageManagerUI(myProject, mySdk, new PyPackageManagerUI.Listener() { @Override public void started() { listener.operationStarted(packageName); } @Override public void finished(List<ExecutionException> exceptions) { listener.operationFinished(packageName, toErrorDescription(exceptions, mySdk)); } }); final List<PyPackage> pyPackages = new ArrayList<>(); for (InstalledPackage aPackage : installedPackages) { if (aPackage instanceof PyPackage) { pyPackages.add((PyPackage)aPackage); } } ui.uninstall(pyPackages); }