Search in sources :

Example 6 with NotificationHyperlink

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

the class AndroidGradlePluginVersionReader method getQuickFixes.

@Override
@NotNull
public List<NotificationHyperlink> getQuickFixes(@NotNull Module module, @Nullable VersionRange expectedVersion, @Nullable PositionInFile location) {
    AndroidPluginInfo pluginInfo = AndroidPluginInfo.find(module.getProject());
    if (isSupportedGeneration(pluginInfo)) {
        String version = pluginInfo.getPluginGeneration().getLatestKnownVersion();
        List<NotificationHyperlink> quickFixes = new ArrayList<>();
        quickFixes.add(new FixAndroidGradlePluginVersionHyperlink(GradleVersion.parse(version), GradleVersion.parse(GRADLE_LATEST_VERSION)));
        quickFixes.add(new OpenUrlHyperlink("https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle", "Open Documentation"));
        return quickFixes;
    }
    return emptyList();
}
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) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with NotificationHyperlink

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

the class CachedDependencyNotFoundErrorHandler method getQuickFixHyperlinks.

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

Example 8 with NotificationHyperlink

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

the class ErrorOpeningZipFileErrorHandler method handleError.

@Override
public boolean handleError(@NotNull ExternalSystemException error, @NotNull NotificationData notification, @NotNull Project project) {
    String text = findErrorMessage(getRootCause(error));
    if (text != null) {
        List<NotificationHyperlink> hyperlinks = new ArrayList<>();
        NotificationHyperlink syncProjectHyperlink = SyncProjectWithExtraCommandLineOptionsHyperlink.syncProjectRefreshingDependencies();
        hyperlinks.add(syncProjectHyperlink);
        String newText = text + syncProjectHyperlink.toHtml();
        SyncMessages.getInstance(project).updateNotification(notification, newText, hyperlinks);
        return true;
    }
    return false;
}
Also used : ArrayList(java.util.ArrayList) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 9 with NotificationHyperlink

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

the class GradleDslMethodNotFoundErrorHandler method getApplyGradlePluginHyperlink.

@NotNull
private static NotificationHyperlink getApplyGradlePluginHyperlink(@NotNull final VirtualFile virtualFile, @NotNull final NotificationData notification) {
    return new NotificationHyperlink("apply.gradle.plugin", "Apply Gradle plugin") {

        @Override
        protected void execute(@NotNull Project project) {
            openFile(virtualFile, notification, project);
            ActionManager actionManager = ActionManager.getInstance();
            String actionId = AddGradleDslPluginAction.ID;
            AnAction action = actionManager.getAction(actionId);
            assert action instanceof AddGradleDslPluginAction;
            AddGradleDslPluginAction addPluginAction = (AddGradleDslPluginAction) action;
            actionManager.tryToExecute(addPluginAction, ActionCommand.getInputEvent(actionId), null, ActionPlaces.UNKNOWN, true);
        }
    };
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) Project(com.intellij.openapi.project.Project) AddGradleDslPluginAction(org.jetbrains.plugins.gradle.codeInsight.actions.AddGradleDslPluginAction) NotNull(org.jetbrains.annotations.NotNull) AnAction(com.intellij.openapi.actionSystem.AnAction) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with NotificationHyperlink

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

the class GradleDslMethodNotFoundErrorHandler method getGradleSettingsHyperlink.

@NotNull
private static NotificationHyperlink getGradleSettingsHyperlink(@NotNull Project project) {
    if (isUsingWrapper(project)) {
        GradleWrapper gradleWrapper = GradleWrapper.find(project);
        if (gradleWrapper != null) {
            VirtualFile propertiesFile = gradleWrapper.getPropertiesFile();
            if (propertiesFile != null) {
                return new NotificationHyperlink("open.wrapper.file", "Open Gradle wrapper file") {

                    @Override
                    protected void execute(@NotNull Project project) {
                        OpenFileDescriptor descriptor = new OpenFileDescriptor(project, propertiesFile);
                        FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
                    }
                };
            }
        }
    }
    return new OpenGradleSettingsHyperlink();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) OpenGradleSettingsHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenGradleSettingsHyperlink) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) NotNull(org.jetbrains.annotations.NotNull) GradleWrapper(com.android.tools.idea.gradle.util.GradleWrapper) 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