void (@NotNull final InstalledPackage pkg, @Nullable final String toVersion) { final PackageManagementService selPackageManagementService = myPackageManagementService; myPackageManagementService.fetchPackageVersions(pkg.getName(), new CatchingConsumer<>() { @Override public void consume(List<String> releases) { if (!releases.isEmpty() && !isUpdateAvailable(pkg.getVersion(), releases.get(0))) { return; } ApplicationManager.getApplication().invokeLater(() -> { ModalityState modalityState = ModalityState.current(); final PackageManagementService.Listener listener = new PackageManagementService.Listener() { @Override public void operationStarted(final String packageName) { ApplicationManager.getApplication().invokeLater(() -> { myPackagesTable.setPaintBusy(true); myCurrentlyInstalling.add(packageName); }, modalityState); } @Override public void operationFinished(final String packageName, @Nullable final PackageManagementService.ErrorDescription errorDescription) { ApplicationManager.getApplication().invokeLater(() -> { myPackagesTable.clearSelection(); updatePackages(selPackageManagementService); myCurrentlyInstalling.remove(packageName); myPackagesTable.setPaintBusy(!myCurrentlyInstalling.isEmpty()); if (errorDescription == null) { myNotificationArea.showSuccess(IdeBundle.message("package.successfully.upgraded", packageName)); } else { myNotificationArea.showError(IdeBundle.message("upgrade.packages.failed"), IdeBundle.message("upgrade.packages.failed.dialog.title"), errorDescription); } if (myCurrentlyInstalling.isEmpty() && !myWaitingToUpgrade.isEmpty()) { upgradePostponedPackages(); } }, modalityState); } }; PackageManagementServiceEx serviceEx = getServiceEx(); if (serviceEx != null) { serviceEx.updatePackage(pkg, toVersion, listener); } else { myPackageManagementService.installPackage(new RepoPackage(pkg.getName(), null /* TODO? */), null, true, null, listener, false); } myUpgradeButton.setEnabled(false); }, ModalityState.any()); } @Override public void consume(Exception e) { ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog( IdeBundle.message("error.occurred.please.check.your.internet.connection"), IdeBundle.message("upgrade.package.failed.title") ), ModalityState.any()); } }); }