Search in sources :

Example 36 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project intellij-plugins by JetBrains.

the class DartEditorNotificationsProvider method createNotificationPanel.

@Override
@Nullable
public EditorNotificationPanel createNotificationPanel(@NotNull final VirtualFile vFile, @NotNull final FileEditor fileEditor) {
    if (!vFile.isInLocalFileSystem()) {
        return null;
    }
    if (PubspecYamlUtil.PUBSPEC_YAML.equalsIgnoreCase(vFile.getName())) {
        final Module module = ModuleUtilCore.findModuleForFile(vFile, myProject);
        if (module == null)
            return null;
        // Defer to the Flutter plugin for package management and SDK configuration if appropriate.
        if (FlutterUtil.isFlutterPluginInstalled() && FlutterUtil.isFlutterModule(module))
            return null;
        final DartSdk sdk = DartSdk.getDartSdk(myProject);
        if (sdk != null && DartSdkLibUtil.isDartSdkEnabled(module)) {
            return new PubActionsPanel();
        }
    }
    if (PubspecYamlUtil.PUBSPEC_YAML.equalsIgnoreCase(vFile.getName()) || vFile.getFileType() == DartFileType.INSTANCE) {
        final DartSdk sdk = DartSdk.getDartSdk(myProject);
        final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(vFile);
        if (psiFile == null)
            return null;
        final Module module = ModuleUtilCore.findModuleForPsiElement(psiFile);
        if (module == null)
            return null;
        // no SDK
        if (sdk == null) {
            final String sdkPath = DartSdkUtil.getFirstKnownDartSdkPath();
            if (DartSdkUtil.isDartSdkHome(sdkPath)) {
                return createNotificationToEnableDartSupport(module);
            }
            final String message = DartBundle.message("dart.sdk.is.not.configured");
            final String downloadUrl = DartSdkUpdateChecker.SDK_STABLE_DOWNLOAD_URL;
            final EditorNotificationPanel panel = new EditorNotificationPanel().icon(DartIcons.Dart_16).text(message);
            panel.createActionLabel(DartBundle.message("download.dart.sdk"), new OpenWebPageRunnable(downloadUrl));
            panel.createActionLabel(DartBundle.message("open.dart.settings"), new OpenDartSettingsRunnable(myProject));
            return panel;
        }
        // SDK not enabled for this module
        if (!DartSdkLibUtil.isDartSdkEnabled(module)) {
            return createNotificationToEnableDartSupport(module);
        }
        if (!DartAnalysisServerService.isDartSdkVersionSufficient(sdk)) {
            final String message = DartBundle.message("old.dart.sdk.configured", DartAnalysisServerService.MIN_SDK_VERSION, sdk.getVersion());
            final String downloadUrl = DartSdkUpdateChecker.SDK_STABLE_DOWNLOAD_URL;
            final EditorNotificationPanel panel = new EditorNotificationPanel().icon(DartIcons.Dart_16).text(message);
            panel.createActionLabel(DartBundle.message("download.dart.sdk"), new OpenWebPageRunnable(downloadUrl));
            panel.createActionLabel(DartBundle.message("open.dart.settings"), new OpenDartSettingsRunnable(myProject));
            return panel;
        }
    }
    return null;
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 37 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project android by JetBrains.

the class EditorFixture method awaitNotification.

@NotNull
public EditorNotificationPanelFixture awaitNotification(@NotNull String text) {
    JLabel label = waitUntilShowing(robot, JLabelMatcher.withText(text));
    EditorNotificationPanel notificationPanel = (EditorNotificationPanel) label.getParent().getParent();
    return new EditorNotificationPanelFixture(myFrame, notificationPanel);
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) NotNull(org.jetbrains.annotations.NotNull)

Example 38 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.

the class IdeFrameFixture method findNotificationPanel.

/**
   * Locates an editor notification with the given main message (unless the message is {@code null}, in which case we assert that there are
   * no visible editor notifications. Will fail if the given notification is not found.
   */
@Nullable
private EditorNotificationPanel findNotificationPanel(@Nullable String message) {
    Collection<EditorNotificationPanel> panels = robot().finder().findAll(target(), new GenericTypeMatcher<EditorNotificationPanel>(EditorNotificationPanel.class, true) {

        @Override
        protected boolean isMatching(@NotNull EditorNotificationPanel panel) {
            return panel.isShowing();
        }
    });
    if (message == null) {
        if (!panels.isEmpty()) {
            List<String> labels = new ArrayList<>();
            for (EditorNotificationPanel panel : panels) {
                labels.addAll(getEditorNotificationLabels(panel));
            }
            fail("Found editor notifications when none were expected" + labels);
        }
        return null;
    }
    List<String> labels = new ArrayList<>();
    for (EditorNotificationPanel panel : panels) {
        List<String> found = getEditorNotificationLabels(panel);
        labels.addAll(found);
        for (String label : found) {
            if (label.contains(message)) {
                return panel;
            }
        }
    }
    return null;
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) Nullable(org.jetbrains.annotations.Nullable)

Example 39 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.

the class PluginAdvertiserEditorNotificationProvider method createPanel.

@Nullable
private EditorNotificationPanel createPanel(final String extension, final Set<PluginsAdvertiser.Plugin> plugins) {
    final EditorNotificationPanel panel = new EditorNotificationPanel();
    panel.setText("Plugins supporting " + extension + " files found.");
    final IdeaPluginDescriptor disabledPlugin = PluginsAdvertiser.getDisabledPlugin(plugins);
    if (disabledPlugin != null) {
        panel.createActionLabel("Enable " + disabledPlugin.getName() + " plugin", () -> {
            myEnabledExtensions.add(extension);
            myNotifications.updateAllNotifications();
            PluginsAdvertiser.enablePlugins(myProject, Collections.singletonList(disabledPlugin));
        });
    } else if (hasNonBundledPlugin(plugins)) {
        panel.createActionLabel("Install plugins", () -> {
            Set<String> pluginIds = new HashSet<>();
            for (PluginsAdvertiser.Plugin plugin : plugins) {
                pluginIds.add(plugin.myPluginId);
            }
            PluginsAdvertiser.installAndEnablePlugins(pluginIds, () -> {
                myEnabledExtensions.add(extension);
                myNotifications.updateAllNotifications();
            });
        });
    } else if (PluginsAdvertiser.hasBundledPluginToInstall(plugins) != null) {
        if (PropertiesComponent.getInstance().isTrueValue(PluginsAdvertiser.IGNORE_ULTIMATE_EDITION)) {
            return null;
        }
        panel.setText(extension + " files are supported by " + PluginsAdvertiser.IDEA_ULTIMATE_EDITION);
        panel.createActionLabel(PluginsAdvertiser.CHECK_ULTIMATE_EDITION_TITLE, () -> {
            myEnabledExtensions.add(extension);
            PluginsAdvertiser.openDownloadPage();
        });
        panel.createActionLabel(PluginsAdvertiser.ULTIMATE_EDITION_SUGGESTION, () -> {
            PropertiesComponent.getInstance().setValue(PluginsAdvertiser.IGNORE_ULTIMATE_EDITION, "true");
            myNotifications.updateAllNotifications();
        });
    } else {
        return null;
    }
    panel.createActionLabel("Ignore extension", () -> {
        UnknownFeaturesCollector.getInstance(myProject).ignoreFeature(createExtensionFeature(extension));
        myNotifications.updateAllNotifications();
    });
    return panel;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) Nullable(org.jetbrains.annotations.Nullable)

Example 40 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.

the class SdkSetupNotificationTest method testNoModuleSdk.

public void testNoModuleSdk() throws Exception {
    final EditorNotificationPanel panel = configureBySdkAndText(null, true, "Sample.java", "class Sample {}");
    assertSdkSetupPanelShown(panel, "Module SDK is not defined");
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel)

Aggregations

EditorNotificationPanel (com.intellij.ui.EditorNotificationPanel)56 Nullable (org.jetbrains.annotations.Nullable)20 NotNull (org.jetbrains.annotations.NotNull)13 FileEditor (com.intellij.openapi.fileEditor.FileEditor)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 PsiFile (com.intellij.psi.PsiFile)7 Editor (com.intellij.openapi.editor.Editor)6 TextEditor (com.intellij.openapi.fileEditor.TextEditor)5 Project (com.intellij.openapi.project.Project)4 Module (com.intellij.openapi.module.Module)3 PluginManagerConfigurable (com.intellij.ide.plugins.PluginManagerConfigurable)2 Document (com.intellij.openapi.editor.Document)2 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2 Ref (com.intellij.openapi.util.Ref)2 PerlLocalSettings (com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings)2 File (java.io.File)2 List (java.util.List)2 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 ModelWizardDialog (com.android.tools.idea.wizard.model.ModelWizardDialog)1