Search in sources :

Example 6 with ProgressIndicator

use of com.android.repository.api.ProgressIndicator in project android by JetBrains.

the class HaxmWizard method doCancelAction.

@Override
public void doCancelAction() {
    if (myHaxmPath.canPerformFinishingActions()) {
        doFinishAction();
        return;
    }
    // Have to ensure the SDK package is removed
    if (!myInvokedToUninstall) {
        try {
            AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
            ComponentInstaller componentInstaller = new ComponentInstaller(sdkHandler);
            ProgressIndicator progress = new StudioLoggerProgressIndicator(getClass());
            sdkHandler.getSdkManager(progress).reloadLocalIfNeeded(progress);
            componentInstaller.ensureSdkPackagesUninstalled(myHaxmPath.myHaxm.getRequiredSdkPackages(), progress);
        } catch (Exception e) {
            Messages.showErrorDialog(SDK_PACKAGE_CLEANUP_FAILED, "Cleanup Error");
            LOG.warn("Failed to make sure HAXM SDK package is uninstalled after HAXM wizard was cancelled", e);
        }
    }
    super.doCancelAction();
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) IOException(java.io.IOException)

Example 7 with ProgressIndicator

use of com.android.repository.api.ProgressIndicator in project android by JetBrains.

the class VfsInstallListener method statusChanged.

@Override
public void statusChanged(@NonNull PackageOperation op, @NonNull ProgressIndicator progress) throws PackageOperation.StatusChangeListenerException {
    if (op.getInstallStatus().equals(PackageOperation.InstallStatus.COMPLETE)) {
        Task refreshTask = new Task.Backgroundable(null, "Refreshing...", false, PerformInBackgroundOption.ALWAYS_BACKGROUND) {

            @Override
            public void run(@NotNull com.intellij.openapi.progress.ProgressIndicator indicator) {
                indicator.setIndeterminate(true);
                doRefresh(op, progress);
            }
        };
        ApplicationManager.getApplication().invokeLater(refreshTask::queue, ModalityState.NON_MODAL);
    }
}
Also used : Task(com.intellij.openapi.progress.Task) ProgressIndicator(com.android.repository.api.ProgressIndicator) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with ProgressIndicator

use of com.android.repository.api.ProgressIndicator in project android by JetBrains.

the class SdkBuildToolsTooLowErrorHandler method getQuickFixHyperlinks.

@NotNull
public List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull String minimumVersion, @NotNull Project project, @Nullable Module module) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    boolean buildToolInstalled = false;
    AndroidSdkHandler sdkHandler = null;
    AndroidSdkData androidSdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
    if (androidSdkData != null) {
        sdkHandler = androidSdkData.getSdkHandler();
    }
    if (sdkHandler != null) {
        ProgressIndicator progress = new StudioLoggerProgressIndicator(SdkBuildToolsTooLowErrorHandler.class);
        RepositoryPackages packages = sdkHandler.getSdkManager(progress).getPackages();
        LocalPackage buildTool = packages.getLocalPackages().get(getBuildToolsPath(parseRevision(minimumVersion)));
        buildToolInstalled = buildTool != null;
    }
    if (module != null) {
        VirtualFile buildFile = getGradleBuildFile(module);
        AndroidPluginInfo androidPluginInfo = AndroidPluginInfo.find(project);
        if (!buildToolInstalled) {
            if (androidPluginInfo != null && androidPluginInfo.isExperimental()) {
                hyperlinks.add(new InstallBuildToolsHyperlink(minimumVersion, null));
            } else {
                hyperlinks.add(new InstallBuildToolsHyperlink(minimumVersion, buildFile));
            }
        } else if (buildFile != null && androidPluginInfo != null && !androidPluginInfo.isExperimental()) {
            hyperlinks.add(new FixBuildToolsVersionHyperlink(buildFile, minimumVersion));
        }
        if (buildFile != null) {
            hyperlinks.add(new OpenFileHyperlink(buildFile.getPath()));
        }
    }
    return hyperlinks;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalPackage(com.android.repository.api.LocalPackage) FixBuildToolsVersionHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FixBuildToolsVersionHyperlink) ArrayList(java.util.ArrayList) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) InstallBuildToolsHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.InstallBuildToolsHyperlink) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) AndroidSdkData(org.jetbrains.android.sdk.AndroidSdkData) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) AndroidPluginInfo(com.android.tools.idea.gradle.plugin.AndroidPluginInfo) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) OpenFileHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenFileHyperlink) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with ProgressIndicator

use of com.android.repository.api.ProgressIndicator in project android by JetBrains.

the class MissingPlatformErrorHandler method findAndAddQuickFixes.

private void findAndAddQuickFixes(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
    String missingPlatform = getMissingPlatform(text);
    if (missingPlatform == null) {
        return;
    }
    String loadError = null;
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    AndroidSdkHandler sdkHandler = null;
    AndroidSdkData androidSdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
    if (androidSdkData != null) {
        sdkHandler = androidSdkData.getSdkHandler();
    }
    if (sdkHandler != null) {
        AndroidVersion version = AndroidTargetHash.getPlatformVersion(missingPlatform);
        if (version != null) {
            // Is the platform installed?
            ProgressIndicator logger = new StudioLoggerProgressIndicator(getClass());
            loadError = sdkHandler.getAndroidTargetManager(logger).getErrorForPackage(DetailsTypes.getPlatformPath(version));
            hyperlinks.add(new InstallPlatformHyperlink(version));
        }
    }
    if (hyperlinks.isEmpty()) {
        // We are unable to install platform automatically.
        List<AndroidFacet> facets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID);
        if (!facets.isEmpty()) {
            // We can only open SDK manager if the project has an Android facet. Android facet has a reference to the Android SDK manager.
            hyperlinks.add(new OpenAndroidSdkManagerHyperlink());
        }
    }
    if (isNotEmpty(loadError)) {
        text += "\nPossible cause: " + loadError;
    }
    SyncMessages.getInstance(project).updateNotification(notification, text, hyperlinks);
}
Also used : OpenAndroidSdkManagerHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink) ArrayList(java.util.ArrayList) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) AndroidVersion(com.android.sdklib.AndroidVersion) InstallPlatformHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.InstallPlatformHyperlink) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) AndroidSdkData(org.jetbrains.android.sdk.AndroidSdkData) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 10 with ProgressIndicator

use of com.android.repository.api.ProgressIndicator in project android by JetBrains.

the class AndroidSdk method getLatestCompatibleBuildToolsPath.

/**
   * Find latest build tools revision. Versions compatible with the selected platforms will be installed by the platform components.
   * @return The Revision of the latest build tools package, or null if no remote build tools packages are available.
   */
@Nullable
private String getLatestCompatibleBuildToolsPath() {
    ProgressIndicator progress = new ProgressIndicatorAdapter() {
    };
    RemotePackage latest = mySdkHandler.getLatestRemotePackageForPrefix(SdkConstants.FD_BUILD_TOOLS, false, progress);
    return latest != null ? latest.getPath() : null;
}
Also used : ProgressIndicator(com.android.repository.api.ProgressIndicator) ProgressIndicatorAdapter(com.android.repository.api.ProgressIndicatorAdapter) RemotePackage(com.android.repository.api.RemotePackage) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ProgressIndicator (com.android.repository.api.ProgressIndicator)10 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)7 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)4 LocalPackage (com.android.repository.api.LocalPackage)3 ArrayList (java.util.ArrayList)3 Revision (com.android.repository.Revision)2 RemotePackage (com.android.repository.api.RemotePackage)2 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)2 AndroidSdkData (org.jetbrains.android.sdk.AndroidSdkData)2 NotNull (org.jetbrains.annotations.NotNull)2 NonNull (com.android.annotations.NonNull)1 VisibleForTesting (com.android.annotations.VisibleForTesting)1 GradleCoordinate (com.android.ide.common.repository.GradleCoordinate)1 ProgressIndicatorAdapter (com.android.repository.api.ProgressIndicatorAdapter)1 RepoPackage (com.android.repository.api.RepoPackage)1 RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)1 AndroidVersion (com.android.sdklib.AndroidVersion)1 IAndroidTarget (com.android.sdklib.IAndroidTarget)1 AndroidSdkHandler (com.android.sdklib.repositoryv2.AndroidSdkHandler)1 AndroidPluginInfo (com.android.tools.idea.gradle.plugin.AndroidPluginInfo)1