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;
}
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);
}
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;
}
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;
}
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");
}
Aggregations