use of com.android.tools.idea.sdk.progress.ThrottledProgressWrapper in project android by JetBrains.
the class InstallSelectedPackagesStep method startSdkInstall.
private void startSdkInstall() {
CustomLogger customLogger = new CustomLogger();
synchronized (LOGGER_LOCK) {
myLogger = new ThrottledProgressWrapper(customLogger);
}
Function<List<RepoPackage>, Void> completeCallback = failures -> {
UIUtil.invokeLaterIfNeeded(() -> {
myProgressBar.setValue(100);
myProgressOverallLabel.setText("");
if (!failures.isEmpty()) {
myInstallFailed.set(true);
myProgressBar.setEnabled(false);
} else {
myProgressDetailLabel.setText("Done");
checkForUpgrades(myInstallRequests);
}
myInstallationFinished.set(true);
});
return null;
};
InstallerFactory factory = StudioSdkInstallerUtil.createInstallerFactory(mySdkHandler);
InstallTask task = new InstallTask(factory, mySdkHandler, StudioSettingsController.getInstance(), myLogger);
task.setInstallRequests(myInstallRequests);
task.setUninstallRequests(myUninstallRequests);
task.setCompleteCallback(completeCallback);
task.setPrepareCompleteCallback(() -> myBackgroundAction.setEnabled(false));
ProgressIndicator indicator;
boolean hasOpenProjects = ProjectManager.getInstance().getOpenProjects().length > 0;
if (hasOpenProjects) {
indicator = new BackgroundableProcessIndicator(task);
} else {
// If we don't have any open projects runProcessWithProgressAsynchronously will show a modal popup no matter what.
// Instead use an empty progress indicator to suppress that.
indicator = new EmptyProgressIndicator();
}
customLogger.setIndicator(indicator);
myLogger.logInfo("To install:");
for (UpdatablePackage p : myInstallRequests) {
myLogger.logInfo(String.format("- %1$s (%2$s)", p.getRemote().getDisplayName(), p.getRemote().getPath()));
}
myLogger.logInfo("");
ProgressManager.getInstance().runProcessWithProgressAsynchronously(task, indicator);
}
Aggregations