Search in sources :

Example 1 with FD_CMAKE

use of com.android.SdkConstants.FD_CMAKE in project android by JetBrains.

the class InstallCMakeHyperlink method execute.

@Override
protected void execute(@NotNull Project project) {
    // We need to statically fetch the SDK handler each time because the location might change.
    // TODO: remove the need for doing this each time.
    AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
    StudioLoggerProgressIndicator progressIndicator = new StudioLoggerProgressIndicator(getClass());
    RepoManager sdkManager = sdkHandler.getSdkManager(progressIndicator);
    StudioProgressRunner progressRunner = new StudioProgressRunner(false, /* backgroundable */
    false, /* cancellable */
    "Loading Remote SDK", true, /* in UI thread */
    project);
    RepoManager.RepoLoadedCallback onComplete = packages -> {
        Collection<RemotePackage> cmakePackages = packages.getRemotePackagesForPrefix(FD_CMAKE);
        if (!cmakePackages.isEmpty()) {
            RemotePackage cmakePackage;
            if (cmakePackages.size() == 1) {
                cmakePackage = getFirstItem(cmakePackages);
            } else {
                cmakePackage = sdkHandler.getLatestRemotePackageForPrefix(FD_CMAKE, false, progressIndicator);
            }
            if (cmakePackage != null) {
                ModelWizardDialog dialog = createDialogForPaths(project, ImmutableList.of(cmakePackage.getPath()));
                if (dialog != null && dialog.showAndGet()) {
                    GradleSyncInvoker.getInstance().requestProjectSyncAndSourceGeneration(project, null);
                }
                return;
            }
            notifyCMakePackageNotFound(project);
        }
    };
    Runnable onError = () -> notifyCMakePackageNotFound(project);
    sdkManager.load(DEFAULT_EXPIRATION_PERIOD_MS, null, ImmutableList.of(onComplete), ImmutableList.of(onError), progressRunner, new StudioDownloader(), StudioSettingsController.getInstance(), false);
}
Also used : AndroidSdks(com.android.tools.idea.sdk.AndroidSdks) ContainerUtil.getFirstItem(com.intellij.util.containers.ContainerUtil.getFirstItem) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) Collection(java.util.Collection) DEFAULT_EXPIRATION_PERIOD_MS(com.android.repository.api.RepoManager.DEFAULT_EXPIRATION_PERIOD_MS) RemotePackage(com.android.repository.api.RemotePackage) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog) StudioSettingsController(com.android.tools.idea.sdk.StudioSettingsController) ImmutableList(com.google.common.collect.ImmutableList) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) FD_CMAKE(com.android.SdkConstants.FD_CMAKE) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) RepoManager(com.android.repository.api.RepoManager) NotNull(org.jetbrains.annotations.NotNull) GradleSyncInvoker(com.android.tools.idea.gradle.project.sync.GradleSyncInvoker) SdkQuickfixUtils.createDialogForPaths(com.android.tools.idea.sdk.wizard.SdkQuickfixUtils.createDialogForPaths) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) RepoManager(com.android.repository.api.RepoManager) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) Collection(java.util.Collection) RemotePackage(com.android.repository.api.RemotePackage) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader)

Aggregations

FD_CMAKE (com.android.SdkConstants.FD_CMAKE)1 RemotePackage (com.android.repository.api.RemotePackage)1 RepoManager (com.android.repository.api.RepoManager)1 DEFAULT_EXPIRATION_PERIOD_MS (com.android.repository.api.RepoManager.DEFAULT_EXPIRATION_PERIOD_MS)1 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)1 GradleSyncInvoker (com.android.tools.idea.gradle.project.sync.GradleSyncInvoker)1 AndroidSdks (com.android.tools.idea.sdk.AndroidSdks)1 StudioDownloader (com.android.tools.idea.sdk.StudioDownloader)1 StudioSettingsController (com.android.tools.idea.sdk.StudioSettingsController)1 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)1 StudioProgressRunner (com.android.tools.idea.sdk.progress.StudioProgressRunner)1 SdkQuickfixUtils.createDialogForPaths (com.android.tools.idea.sdk.wizard.SdkQuickfixUtils.createDialogForPaths)1 ModelWizardDialog (com.android.tools.idea.wizard.model.ModelWizardDialog)1 ImmutableList (com.google.common.collect.ImmutableList)1 Project (com.intellij.openapi.project.Project)1 Messages (com.intellij.openapi.ui.Messages)1 ContainerUtil.getFirstItem (com.intellij.util.containers.ContainerUtil.getFirstItem)1 Collection (java.util.Collection)1 NotNull (org.jetbrains.annotations.NotNull)1