@NotNull private static EditorNotificationPanel createPanel( @NotNull final Project project, @NotNull final Module module) { EditorNotificationPanel panel = new EditorNotificationPanel(); panel.setText( "'" + module.getName() + "' is not a RESOLVE Module, " + "therefore some code insight might not work here"); panel.createActionLabel( "Change module type to RESOLVE and reload project", new Runnable() { @Override public void run() { int message = Messages.showOkCancelDialog( project, "Updating module type requires project reload. " + "Proceed?", "Update Module Type", "Reload project", "Cancel", null); if (message == Messages.YES) { module.setOption(Module.ELEMENT_TYPE, RESOLVEModuleType.getInstance().getId()); project.save(); EditorNotifications.getInstance(project).updateAllNotifications(); ProjectManager.getInstance().reloadProject(project); } } }); panel.createActionLabel( "Don't show again for this module", new Runnable() { @Override public void run() { Set<String> ignoredModules = getIgnoredModules(project); ignoredModules.add(module.getName()); PropertiesComponent.getInstance(project) .setValue(DONT_ASK_TO_CHANGE_MODULE_TYPE_KEY, StringUtil.join(ignoredModules, ",")); EditorNotifications.getInstance(project).updateAllNotifications(); } }); return panel; }
@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; }