Search in sources :

Example 1 with OpenGradleSettingsHyperlink

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

Example 2 with OpenGradleSettingsHyperlink

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

the class UnsupportedGradleVersionErrorHandler method getQuickFixHyperlinks.

@NotNull
public static List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull Project project, @Nullable String gradleVersion) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    GradleWrapper gradleWrapper = GradleWrapper.find(project);
    if (gradleWrapper != null) {
        // It is very likely that we need to fix the model version as well. Do everything in one shot.
        NotificationHyperlink hyperlink = createIfProjectUsesGradleWrapper(project, gradleVersion);
        if (hyperlink != null) {
            hyperlinks.add(hyperlink);
        }
    } else {
        GradleProjectSettings gradleProjectSettings = GradleProjectSettingsFinder.getInstance().findGradleProjectSettings(project);
        if (gradleProjectSettings != null && gradleProjectSettings.getDistributionType() == DistributionType.LOCAL) {
            hyperlinks.add(new CreateGradleWrapperHyperlink());
        }
    }
    hyperlinks.add(new OpenGradleSettingsHyperlink());
    return hyperlinks;
}
Also used : OpenGradleSettingsHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenGradleSettingsHyperlink) GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings) ArrayList(java.util.ArrayList) GradleWrapper(com.android.tools.idea.gradle.util.GradleWrapper) FixGradleVersionInWrapperHyperlink.createIfProjectUsesGradleWrapper(com.android.tools.idea.gradle.project.sync.hyperlink.FixGradleVersionInWrapperHyperlink.createIfProjectUsesGradleWrapper) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) CreateGradleWrapperHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.CreateGradleWrapperHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)2 OpenGradleSettingsHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenGradleSettingsHyperlink)2 GradleWrapper (com.android.tools.idea.gradle.util.GradleWrapper)2 NotNull (org.jetbrains.annotations.NotNull)2 CreateGradleWrapperHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.CreateGradleWrapperHyperlink)1 FixGradleVersionInWrapperHyperlink.createIfProjectUsesGradleWrapper (com.android.tools.idea.gradle.project.sync.hyperlink.FixGradleVersionInWrapperHyperlink.createIfProjectUsesGradleWrapper)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ArrayList (java.util.ArrayList)1 GradleProjectSettings (org.jetbrains.plugins.gradle.settings.GradleProjectSettings)1