Search in sources :

Example 6 with FixAndroidGradlePluginVersionHyperlink

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

the class LayoutRenderingIssueValidationStrategy method fixAndReportFoundIssues.

@Override
void fixAndReportFoundIssues() {
    if (myModelVersion != null) {
        String text = String.format("Using an obsolete version of the Gradle plugin (%1$s);", myModelVersion);
        text += " this can lead to layouts not rendering correctly.";
        SyncMessage message = new SyncMessage(DEFAULT_GROUP, WARNING, text);
        message.add(Arrays.asList(new FixAndroidGradlePluginVersionHyperlink(), new OpenUrlHyperlink("https://code.google.com/p/android/issues/detail?id=170841", "More Info...")));
        SyncMessages.getInstance(getProject()).report(message);
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) FixAndroidGradlePluginVersionHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink) OpenUrlHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenUrlHyperlink)

Example 7 with FixAndroidGradlePluginVersionHyperlink

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

the class OldAndroidPluginErrorHandler 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());
    AndroidPluginInfo result = searchInBuildFilesOnly(project);
    if (result != null && result.getPluginBuildFile() != null) {
        hyperlinks.add(new OpenFileHyperlink(result.getPluginBuildFile().getPath()));
    }
    return hyperlinks;
}
Also used : FixAndroidGradlePluginVersionHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink) AndroidPluginInfo(com.android.tools.idea.gradle.plugin.AndroidPluginInfo) ArrayList(java.util.ArrayList) 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 8 with FixAndroidGradlePluginVersionHyperlink

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

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

Example 10 with FixAndroidGradlePluginVersionHyperlink

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

the class AndroidGradlePluginVersionReaderTest method testGetQuickFixes.

public void testGetQuickFixes() throws Exception {
    loadSimpleApplication();
    Module appModule = myModules.getAppModule();
    List<NotificationHyperlink> quickFixes = myVersionReader.getQuickFixes(appModule, VersionRange.parse("[1.2.0, +)"), null);
    assertThat(quickFixes).hasSize(2);
    NotificationHyperlink quickFix = quickFixes.get(0);
    assertThat(quickFix).isInstanceOf(FixAndroidGradlePluginVersionHyperlink.class);
    FixAndroidGradlePluginVersionHyperlink fixAndroidGradlePluginQuickFix = (FixAndroidGradlePluginVersionHyperlink) quickFix;
    assertEquals(BuildEnvironment.getInstance().getGradlePluginVersion(), fixAndroidGradlePluginQuickFix.getPluginVersion().toString());
    quickFix = quickFixes.get(1);
    assertThat(quickFix).isInstanceOf(OpenUrlHyperlink.class);
    OpenUrlHyperlink openUrlQuickFix = (OpenUrlHyperlink) quickFix;
    assertEquals("https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle", openUrlQuickFix.getUrl());
}
Also used : FixAndroidGradlePluginVersionHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink) OpenUrlHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenUrlHyperlink) Module(com.intellij.openapi.module.Module) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Aggregations

FixAndroidGradlePluginVersionHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink)10 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)8 OpenUrlHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenUrlHyperlink)6 ArrayList (java.util.ArrayList)5 NotNull (org.jetbrains.annotations.NotNull)4 GradleVersion (com.android.ide.common.repository.GradleVersion)3 AndroidPluginInfo (com.android.tools.idea.gradle.plugin.AndroidPluginInfo)3 Module (com.intellij.openapi.module.Module)3 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 OpenFileHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenFileHyperlink)1 SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)1 HtmlLinkManager (com.android.tools.idea.rendering.HtmlLinkManager)1 HtmlBuilder (com.android.utils.HtmlBuilder)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1