Search in sources :

Example 1 with SearchInBuildFilesHyperlink

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

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

Aggregations

NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)2 SearchInBuildFilesHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.SearchInBuildFilesHyperlink)2 GradleVersion (com.android.ide.common.repository.GradleVersion)1 AndroidPluginGeneration (com.android.tools.idea.gradle.plugin.AndroidPluginGeneration)1 AndroidPluginVersionUpdater (com.android.tools.idea.gradle.plugin.AndroidPluginVersionUpdater)1 GradleSyncState (com.android.tools.idea.gradle.project.sync.GradleSyncState)1 ToggleOfflineModeHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.ToggleOfflineModeHyperlink)1 SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)1 ArrayList (java.util.ArrayList)1