Search in sources :

Example 31 with NotificationHyperlink

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

the class MissingBuildToolsErrorHandler method getQuickFixHyperlinks.

@Override
@NotNull
protected List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    //If get to this point, the message matches patter
    Matcher matcher = MISSING_BUILD_TOOLS_PATTERN.matcher(getFirstLineMessage(text));
    if (matcher.matches()) {
        String version = matcher.group(3);
        hyperlinks.add(new InstallBuildToolsHyperlink(version, null));
    }
    return hyperlinks;
}
Also used : Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) InstallBuildToolsHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.InstallBuildToolsHyperlink) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Example 32 with NotificationHyperlink

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

the class MissingDependencyErrorHandler method handleMissingDependency.

private static void handleMissingDependency(@NotNull NotificationData notification, @NotNull Project project, @NotNull String msg, @NotNull String dependency, @NotNull List<NotificationHyperlink> additionalHyperlinks) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>(additionalHyperlinks);
    ToggleOfflineModeHyperlink disableOfflineMode = ToggleOfflineModeHyperlink.disableOfflineMode(project);
    if (disableOfflineMode != null) {
        hyperlinks.add(0, disableOfflineMode);
    }
    hyperlinks.add(new SearchInBuildFilesHyperlink(dependency));
    SyncMessages.getInstance(project).updateNotification(notification, msg, hyperlinks);
}
Also used : ArrayList(java.util.ArrayList) ToggleOfflineModeHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.ToggleOfflineModeHyperlink) SearchInBuildFilesHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.SearchInBuildFilesHyperlink) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 33 with NotificationHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink 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 34 with NotificationHyperlink

use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink 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 35 with NotificationHyperlink

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

the class UnsupportedGradleVersionErrorHandler method getQuickFixHyperlinks.

@NotNull
public static List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull Project project, @Nullable String gradleVersion) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    GradleWrapper gradleWrapper = GradleWrapper.find(project);
    if (gradleWrapper != null) {
        // It is very likely that we need to fix the model version as well. Do everything in one shot.
        NotificationHyperlink hyperlink = createIfProjectUsesGradleWrapper(project, gradleVersion);
        if (hyperlink != null) {
            hyperlinks.add(hyperlink);
        }
    } else {
        GradleProjectSettings gradleProjectSettings = GradleProjectSettingsFinder.getInstance().findGradleProjectSettings(project);
        if (gradleProjectSettings != null && gradleProjectSettings.getDistributionType() == DistributionType.LOCAL) {
            hyperlinks.add(new CreateGradleWrapperHyperlink());
        }
    }
    hyperlinks.add(new OpenGradleSettingsHyperlink());
    return hyperlinks;
}
Also used : OpenGradleSettingsHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenGradleSettingsHyperlink) GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings) ArrayList(java.util.ArrayList) GradleWrapper(com.android.tools.idea.gradle.util.GradleWrapper) FixGradleVersionInWrapperHyperlink.createIfProjectUsesGradleWrapper(com.android.tools.idea.gradle.project.sync.hyperlink.FixGradleVersionInWrapperHyperlink.createIfProjectUsesGradleWrapper) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) CreateGradleWrapperHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.CreateGradleWrapperHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)70 ArrayList (java.util.ArrayList)28 NotNull (org.jetbrains.annotations.NotNull)28 SyncMessagesStub (com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub)17 SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)11 Module (com.intellij.openapi.module.Module)11 OpenUrlHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenUrlHyperlink)10 FixAndroidGradlePluginVersionHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink)8 OpenFileHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenFileHyperlink)8 File (java.io.File)8 Project (com.intellij.openapi.project.Project)5 AndroidPluginInfo (com.android.tools.idea.gradle.plugin.AndroidPluginInfo)4 GradleVersion (com.android.ide.common.repository.GradleVersion)3 OpenAndroidSdkManagerHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 ProgressIndicator (com.android.repository.api.ProgressIndicator)2 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)2 NotificationMessage (com.android.tools.idea.gradle.project.AndroidGradleNotificationStub.NotificationMessage)2 CreateGradleWrapperHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.CreateGradleWrapperHyperlink)2 InstallBuildToolsHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.InstallBuildToolsHyperlink)2