Search in sources :

Example 41 with NotificationHyperlink

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

the class ConflictSet method showSelectionConflicts.

/**
   * Shows the "variant selection" conflicts in the "Build Variant" and "Messages" windows.
   */
public void showSelectionConflicts() {
    SyncMessages messages = SyncMessages.getInstance(myProject);
    String groupName = VARIANT_SELECTION_CONFLICTS;
    messages.removeMessages(groupName);
    for (Conflict conflict : mySelectionConflicts) {
        // Creates the "Select in 'Build Variants' window" hyperlink.
        Module source = conflict.getSource();
        String hyperlinkText = String.format("Select '%1$s' in \"Build Variants\" window", source.getName());
        NotificationHyperlink selectInBuildVariantsWindowHyperlink = new NotificationHyperlink("select.conflict.in.variants.window", hyperlinkText) {

            @Override
            protected void execute(@NotNull Project project) {
                BuildVariantView.getInstance(project).findAndSelect(source);
            }
        };
        // Creates the "Fix problem" hyperlink.
        NotificationHyperlink quickFixHyperlink = new NotificationHyperlink("fix.conflict", "Fix problem") {

            @Override
            protected void execute(@NotNull Project project) {
                boolean solved = solveSelectionConflict(conflict);
                if (solved) {
                    ConflictSet conflicts = findConflicts(project);
                    conflicts.showSelectionConflicts();
                }
            }
        };
        SyncMessage msg = new SyncMessage(groupName, MessageType.WARNING, conflict.toString());
        msg.add(selectInBuildVariantsWindowHyperlink);
        msg.add(quickFixHyperlink);
        messages.report(msg);
    }
    BuildVariantView.getInstance(myProject).updateContents(mySelectionConflicts);
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) SyncMessages(com.android.tools.idea.gradle.project.sync.messages.SyncMessages) Project(com.intellij.openapi.project.Project) ConflictResolution.solveSelectionConflict(com.android.tools.idea.gradle.variant.conflict.ConflictResolution.solveSelectionConflict) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 42 with NotificationHyperlink

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

the class NdkIntegrationDeprecatedErrorHandler 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://developer.android.com/studio/build/experimental-plugin.html", "Consider trying the new experimental plugin"));
    hyperlinks.add(new SetUseDeprecatedNdkHyperlink());
    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 43 with NotificationHyperlink

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

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

the class SdkBuildToolsTooLowErrorHandler method getQuickFixHyperlinks.

@NotNull
public List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull String minimumVersion, @NotNull Project project, @Nullable Module module) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    boolean buildToolInstalled = false;
    AndroidSdkHandler sdkHandler = null;
    AndroidSdkData androidSdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
    if (androidSdkData != null) {
        sdkHandler = androidSdkData.getSdkHandler();
    }
    if (sdkHandler != null) {
        ProgressIndicator progress = new StudioLoggerProgressIndicator(SdkBuildToolsTooLowErrorHandler.class);
        RepositoryPackages packages = sdkHandler.getSdkManager(progress).getPackages();
        LocalPackage buildTool = packages.getLocalPackages().get(getBuildToolsPath(parseRevision(minimumVersion)));
        buildToolInstalled = buildTool != null;
    }
    if (module != null) {
        VirtualFile buildFile = getGradleBuildFile(module);
        AndroidPluginInfo androidPluginInfo = AndroidPluginInfo.find(project);
        if (!buildToolInstalled) {
            if (androidPluginInfo != null && androidPluginInfo.isExperimental()) {
                hyperlinks.add(new InstallBuildToolsHyperlink(minimumVersion, null));
            } else {
                hyperlinks.add(new InstallBuildToolsHyperlink(minimumVersion, buildFile));
            }
        } else if (buildFile != null && androidPluginInfo != null && !androidPluginInfo.isExperimental()) {
            hyperlinks.add(new FixBuildToolsVersionHyperlink(buildFile, minimumVersion));
        }
        if (buildFile != null) {
            hyperlinks.add(new OpenFileHyperlink(buildFile.getPath()));
        }
    }
    return hyperlinks;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalPackage(com.android.repository.api.LocalPackage) FixBuildToolsVersionHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FixBuildToolsVersionHyperlink) ArrayList(java.util.ArrayList) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) InstallBuildToolsHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.InstallBuildToolsHyperlink) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) AndroidSdkData(org.jetbrains.android.sdk.AndroidSdkData) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) AndroidPluginInfo(com.android.tools.idea.gradle.plugin.AndroidPluginInfo) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) 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 45 with NotificationHyperlink

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

the class UnexpectedErrorHandler 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 FileBugHyperlink());
    hyperlinks.add(new ShowLogHyperlink());
    return hyperlinks;
}
Also used : FileBugHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FileBugHyperlink) ShowLogHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.ShowLogHyperlink) ArrayList(java.util.ArrayList) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) 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