Search in sources :

Example 36 with NotificationHyperlink

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

the class GradleVersionReader method getQuickFixes.

@Override
@NotNull
public List<NotificationHyperlink> getQuickFixes(@NotNull Module module, @Nullable VersionRange expectedVersion, @Nullable PositionInFile location) {
    List<NotificationHyperlink> quickFixes = new ArrayList<>();
    AndroidPluginInfo pluginInfo = AndroidPluginInfo.find(module.getProject());
    if (pluginInfo != null) {
        GradleVersion pluginVersion = GradleVersion.parse(pluginInfo.getPluginGeneration().getLatestKnownVersion());
        GradleVersion gradleVersion = GradleVersion.parse(GRADLE_LATEST_VERSION);
        String text = "Fix Gradle version (as part of the update, the Android plugin will be updated to version " + pluginVersion + ")";
        quickFixes.add(new FixAndroidGradlePluginVersionHyperlink(text, pluginVersion, gradleVersion));
    }
    quickFixes.add(new OpenUrlHyperlink("https://developer.android.com/studio/releases/index.html#Revisions", "Open Documentation"));
    return quickFixes;
}
Also used : FixAndroidGradlePluginVersionHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink) AndroidPluginInfo(com.android.tools.idea.gradle.plugin.AndroidPluginInfo) ArrayList(java.util.ArrayList) OpenUrlHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenUrlHyperlink) GradleVersion(com.android.ide.common.repository.GradleVersion) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Example 37 with NotificationHyperlink

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

the class AndroidGradleProjectComponent method showMigrateToGradleWarning.

private void showMigrateToGradleWarning() {
    String errMsg = "This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system.";
    NotificationHyperlink moreInfoHyperlink = new OpenMigrationToGradleUrlHyperlink().setCloseOnClick(true);
    NotificationHyperlink doNotShowAgainHyperlink = new NotificationHyperlink("do.not.show", "Don't show this message again.") {

        @Override
        protected void execute(@NotNull Project project) {
            PropertiesComponent.getInstance(myProject).setValue(SHOW_MIGRATE_TO_GRADLE_POPUP, Boolean.FALSE.toString());
        }
    };
    AndroidGradleNotification notification = AndroidGradleNotification.getInstance(myProject);
    notification.showBalloon("Migrate Project to Gradle?", errMsg, NotificationType.WARNING, moreInfoHyperlink, doNotShowAgainHyperlink);
}
Also used : Project(com.intellij.openapi.project.Project) ApkProjects.isApkProject(com.android.tools.idea.apk.ApkProjects.isApkProject) OpenMigrationToGradleUrlHyperlink(com.android.tools.idea.gradle.project.importing.OpenMigrationToGradleUrlHyperlink) NotNull(org.jetbrains.annotations.NotNull) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 38 with NotificationHyperlink

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

the class PostProjectBuildTasksExecutor method notifyUnresolvedDependenciesInOfflineMode.

private void notifyUnresolvedDependenciesInOfflineMode() {
    NotificationHyperlink disableOfflineModeHyperlink = new NotificationHyperlink("disable.gradle.offline.mode", "Disable offline mode") {

        @Override
        protected void execute(@NotNull Project project) {
            GradleSettings.getInstance(myProject).setOfflineWork(false);
        }
    };
    String title = "Unresolved Dependencies";
    String text = "Unresolved dependencies detected while building project in offline mode. Please disable offline mode and try again.";
    AndroidGradleNotification.getInstance(myProject).showBalloon(title, text, NotificationType.ERROR, disableOfflineModeHyperlink);
}
Also used : Project(com.intellij.openapi.project.Project) NotNull(org.jetbrains.annotations.NotNull) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 39 with NotificationHyperlink

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

the class ForcedPluginPreviewVersionUpgradeStep method checkAndPerformUpgrade.

@Override
public boolean checkAndPerformUpgrade(@NotNull Project project, @NotNull AndroidPluginInfo pluginInfo) {
    AndroidPluginGeneration pluginGeneration = pluginInfo.getPluginGeneration();
    GradleVersion recommended = GradleVersion.parse(pluginGeneration.getLatestKnownVersion());
    if (!shouldPreviewBeForcedToUpgradePluginVersion(recommended.toString(), pluginInfo.getPluginVersion())) {
        return false;
    }
    GradleSyncState syncState = GradleSyncState.getInstance(project);
    // Update the sync state before starting a new one.
    syncState.syncEnded();
    boolean userAcceptsForcedUpgrade = new ForcedPluginPreviewVersionUpgradeDialog(project, pluginInfo).showAndGet();
    if (userAcceptsForcedUpgrade) {
        AndroidPluginVersionUpdater versionUpdater = AndroidPluginVersionUpdater.getInstance(project);
        versionUpdater.updatePluginVersionAndSync(recommended, GradleVersion.parse(GRADLE_LATEST_VERSION), true);
    } else {
        String[] text = { "The project is using an incompatible version of the " + pluginGeneration.getDescription() + ".", "Please update your project to use version " + pluginGeneration.getLatestKnownVersion() + "." };
        SyncMessage msg = new SyncMessage(SyncMessage.DEFAULT_GROUP, ERROR, text);
        String pluginName = AndroidPluginGeneration.getGroupId() + GRADLE_PATH_SEPARATOR + pluginGeneration.getArtifactId();
        NotificationHyperlink quickFix = new SearchInBuildFilesHyperlink(pluginName);
        msg.add(quickFix);
        SyncMessages.getInstance(project).report(msg);
        syncState.invalidateLastSync("Force plugin upgrade declined");
    }
    return true;
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) SearchInBuildFilesHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.SearchInBuildFilesHyperlink) GradleVersion(com.android.ide.common.repository.GradleVersion) AndroidPluginGeneration(com.android.tools.idea.gradle.plugin.AndroidPluginGeneration) AndroidPluginVersionUpdater(com.android.tools.idea.gradle.plugin.AndroidPluginVersionUpdater) GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 40 with NotificationHyperlink

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

the class UnsupportedGradleReporter method report.

@Override
void report(@NotNull SyncIssue syncIssue, @NotNull Module module, @Nullable VirtualFile buildFile) {
    String text = syncIssue.getMessage();
    MessageType type = getMessageType(syncIssue);
    SyncMessage message = new SyncMessage(DEFAULT_GROUP, type, NonNavigatable.INSTANCE, text);
    String gradleVersion = syncIssue.getData();
    List<NotificationHyperlink> quickFixes = getQuickFixHyperlinks(module.getProject(), gradleVersion);
    message.add(quickFixes);
    getSyncMessages(module).report(message);
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) MessageType(com.android.tools.idea.gradle.project.sync.messages.MessageType) 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