Search in sources :

Example 1 with OpenAndroidSdkManagerHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink in project android by JetBrains.

the class MissingPlatformsSetupStep method setUpProject.

@Override
public void setUpProject(@NotNull Project project, @Nullable ProgressIndicator indicator) {
    SyncMessages syncMessages = SyncMessages.getInstance(project);
    int sdkErrorCount = syncMessages.getMessageCount(SDK_SETUP_ISSUES);
    if (sdkErrorCount > 0) {
        // If we have errors due to platforms not being installed, we add an extra message that prompts user to open Android SDK manager and
        // install any missing platforms.
        String text = "Open Android SDK Manager and install all missing platforms.";
        SyncMessage hint = new SyncMessage(SDK_SETUP_ISSUES, INFO, NonNavigatable.INSTANCE, text);
        hint.add(new OpenAndroidSdkManagerHyperlink());
        syncMessages.report(hint);
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) SyncMessages(com.android.tools.idea.gradle.project.sync.messages.SyncMessages) OpenAndroidSdkManagerHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink)

Example 2 with OpenAndroidSdkManagerHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink in project android by JetBrains.

the class MissingAndroidSupportRepoErrorHandler method getQuickFixHyperlinks.

@Override
@NotNull
protected List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    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());
    }
    return hyperlinks;
}
Also used : OpenAndroidSdkManagerHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink) ArrayList(java.util.ArrayList) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with OpenAndroidSdkManagerHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink in project android by JetBrains.

the class ObjectStreamErrorHandler method findAndAddQuickFixes.

private static void findAndAddQuickFixes(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    NotificationHyperlink buildProjectHyperlink = new BuildProjectHyperlink();
    NotificationHyperlink openAndroidSdkManagerHyperlink = new OpenAndroidSdkManagerHyperlink();
    text += "Please try one of the following:<ul>" + "<li>" + buildProjectHyperlink.toHtml() + " to obtain the cause of the error</li>" + "<li>" + openAndroidSdkManagerHyperlink.toHtml() + " to check if there are any missing components</li></ul>";
    hyperlinks.add(buildProjectHyperlink);
    hyperlinks.add(openAndroidSdkManagerHyperlink);
    notification.setTitle(SyncMessage.DEFAULT_GROUP);
    notification.setMessage(text);
    notification.setNotificationCategory(NotificationCategory.convert(DEFAULT_NOTIFICATION_TYPE));
    SyncMessages.getInstance(project).addNotificationListener(notification, hyperlinks);
}
Also used : OpenAndroidSdkManagerHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink) BuildProjectHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.BuildProjectHyperlink) ArrayList(java.util.ArrayList) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 4 with OpenAndroidSdkManagerHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink in project android by JetBrains.

the class AndroidFacetImporterBase method reportCannotFindAndroidPlatformError.

private static void reportCannotFindAndroidPlatformError(String moduleName, @Nullable String apiLevel, Project project) {
    final OpenAndroidSdkManagerHyperlink hyperlink = new OpenAndroidSdkManagerHyperlink();
    AndroidUtils.reportImportErrorToEventLog("Cannot find appropriate Android platform" + (apiLevel != null ? " for API level " + apiLevel : "") + ". " + hyperlink.toHtml(), moduleName, project, new CustomNotificationListener(project, hyperlink));
}
Also used : OpenAndroidSdkManagerHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink) CustomNotificationListener(com.android.tools.idea.gradle.project.sync.hyperlink.CustomNotificationListener)

Example 5 with OpenAndroidSdkManagerHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink 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)

Aggregations

OpenAndroidSdkManagerHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink)5 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)3 ArrayList (java.util.ArrayList)3 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)2 ProgressIndicator (com.android.repository.api.ProgressIndicator)1 AndroidVersion (com.android.sdklib.AndroidVersion)1 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)1 BuildProjectHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.BuildProjectHyperlink)1 CustomNotificationListener (com.android.tools.idea.gradle.project.sync.hyperlink.CustomNotificationListener)1 InstallPlatformHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.InstallPlatformHyperlink)1 SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)1 SyncMessages (com.android.tools.idea.gradle.project.sync.messages.SyncMessages)1 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)1 AndroidSdkData (org.jetbrains.android.sdk.AndroidSdkData)1 NotNull (org.jetbrains.annotations.NotNull)1