void (@NotNull final Project project, @NotNull final String frameworkName, @NotNull final String requirement, @Nullable final Sdk sdk, final boolean forceInstallFramework, boolean asBackgroundTask, @Nullable final Runnable callback) { if (sdk == null) { reportPackageInstallationFailure(frameworkName, null); return; } // For remote SDK we are not sure if framework exists or not, so we'll check it anyway if (forceInstallFramework || PythonSdkUtil.isRemote(sdk)) { if (asBackgroundTask) { ProgressManager.getInstance() .run(new Task.Backgroundable(project, PyBundle.message("python.install.framework.ensure.installed", frameworkName), false) { @Override public void run(@NotNull final ProgressIndicator indicator) { installPackages(frameworkName, forceInstallFramework, indicator, requirement, sdk); } @Override public void onSuccess() { // Installed / checked successfully, call callback on AWT if (callback != null) { callback.run(); } } }); } else { ProgressManager.getInstance() .run(new Task.Modal(project, PyBundle.message("python.install.framework.ensure.installed", frameworkName), false) { @Override public void run(@NotNull final ProgressIndicator indicator) { installPackages(frameworkName, forceInstallFramework, indicator, requirement, sdk); } @Override public void onSuccess() { // Installed / checked successfully, call callback on AWT if (callback != null) { callback.run(); } } }); } } else { // No need to install, but still need to call callback on AWT if (callback != null) { assert SwingUtilities.isEventDispatchThread(); callback.run(); } } }