Search in sources :

Example 46 with NotificationHyperlink

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

the class UnknownHostErrorHandler method getQuickFixHyperlinks.

@Override
@NotNull
protected List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    NotificationHyperlink enableOfflineMode = ToggleOfflineModeHyperlink.enableOfflineMode(project);
    if (enableOfflineMode != null) {
        hyperlinks.add(enableOfflineMode);
    }
    hyperlinks.add(new OpenUrlHyperlink("https://docs.gradle.org/current/userguide/userguide_single.html#sec:accessing_the_web_via_a_proxy", "Learn about configuring HTTP proxies in Gradle"));
    return hyperlinks;
}
Also used : ArrayList(java.util.ArrayList) OpenUrlHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenUrlHyperlink) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Example 47 with NotificationHyperlink

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

the class UnsupportedModelVersionErrorHandler method getQuickFixHyperlinks.

@Override
@NotNull
protected List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    hyperlinks.add(new FixAndroidGradlePluginVersionHyperlink());
    return hyperlinks;
}
Also used : FixAndroidGradlePluginVersionHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink) ArrayList(java.util.ArrayList) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Example 48 with NotificationHyperlink

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

the class GradleBrokenPipeErrorHandler method getQuickFixHyperlinks.

@Override
@NotNull
protected List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    hyperlinks.add(new OpenUrlHyperlink("https://sites.google.com/a/android.com/tools/knownissues?pli=1#TOC-Gradle-Sync-Failed:-Broken-Pipe", "More info (including workarounds)"));
    return hyperlinks;
}
Also used : ArrayList(java.util.ArrayList) OpenUrlHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenUrlHyperlink) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Example 49 with NotificationHyperlink

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

the class GradleDslMethodNotFoundErrorHandler method getQuickFixHyperlinks.

private static void getQuickFixHyperlinks(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    String filePath = notification.getFilePath();
    VirtualFile file = filePath != null ? LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath) : null;
    if (file != null && FN_BUILD_GRADLE.equals(file.getName())) {
        updateNotificationWithBuildFile(project, file, notification, text);
        return;
    }
    if (file != null && notification.getLine() > 0 && notification.getNavigatable() == null) {
        OpenFileHyperlink hyperlink = new OpenFileHyperlink(filePath, notification.getLine() - 1);
        hyperlinks.add(hyperlink);
    }
    SyncMessages.getInstance(project).updateNotification(notification, text, hyperlinks);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ArrayList(java.util.ArrayList) OpenFileHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenFileHyperlink) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 50 with NotificationHyperlink

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

the class GradleDslMethodNotFoundErrorHandler method updateNotificationWithBuildFile.

private static void updateNotificationWithBuildFile(@NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull NotificationData notification, @NotNull String text) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    NotificationHyperlink gradleSettingsHyperlink = getGradleSettingsHyperlink(project);
    NotificationHyperlink applyGradlePluginHyperlink = getApplyGradlePluginHyperlink(virtualFile, notification);
    NotificationHyperlink upgradeAndroidPluginHyperlink = new FixAndroidGradlePluginVersionHyperlink();
    String newMsg = text + "\nPossible causes:<ul>";
    if (!gradleModelIsRecent(project)) {
        newMsg = newMsg + String.format("<li>The project '%1$s' may be using a version of the Android Gradle plug-in that does" + " not contain the method (e.g. 'testCompile' was added in 1.1.0).\n", project.getName()) + upgradeAndroidPluginHyperlink.toHtml() + "</li>";
    }
    newMsg = newMsg + String.format("<li>The project '%1$s' may be using a version of Gradle that does not contain the method.\n", project.getName()) + gradleSettingsHyperlink.toHtml() + "</li>" + "<li>The build file may be missing a Gradle plugin.\n" + applyGradlePluginHyperlink.toHtml() + "</li>";
    notification.setTitle(SyncMessage.DEFAULT_GROUP);
    notification.setMessage(newMsg);
    notification.setNotificationCategory(NotificationCategory.convert(DEFAULT_NOTIFICATION_TYPE));
    hyperlinks.add(gradleSettingsHyperlink);
    hyperlinks.add(applyGradlePluginHyperlink);
    hyperlinks.add(upgradeAndroidPluginHyperlink);
    SyncMessages.getInstance(project).addNotificationListener(notification, hyperlinks);
}
Also used : FixAndroidGradlePluginVersionHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink) ArrayList(java.util.ArrayList) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

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