private Map<String, String> getPluginNameByIdMap() { if (myPluginNameById == null) { myPluginNameById = new HashMap<String, String>(); for (IdeaPluginDescriptor descriptor : PluginManagerCore.getPlugins()) { myPluginNameById.put(descriptor.getPluginId().getIdString(), descriptor.getName()); } } return myPluginNameById; }
@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; }
private static boolean doSubmit( final IdeaLoggingEvent event, final Component parentComponent, final Consumer<SubmittedReportInfo> callback, final ErrorBean bean, final String description) { final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent); bean.setDescription(description); bean.setMessage(event.getMessage()); Throwable throwable = event.getThrowable(); if (throwable != null) { final PluginId pluginId = IdeErrorsDialog.findPluginId(throwable); if (pluginId != null) { final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId); if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) { bean.setPluginName(ideaPluginDescriptor.getName()); bean.setPluginVersion(ideaPluginDescriptor.getVersion()); } } } Object data = event.getData(); if (data instanceof LogMessageEx) { bean.setAttachments(((LogMessageEx) data).getAttachments()); } LinkedHashMap<String, String> reportValues = IdeaITNProxy.getKeyValuePairs( bean, ApplicationManager.getApplication(), (ApplicationInfoEx) ApplicationInfo.getInstance(), ApplicationNamesInfo.getInstance()); final Project project = CommonDataKeys.PROJECT.getData(dataContext); Consumer<String> successCallback = new Consumer<String>() { @Override public void consume(String token) { final SubmittedReportInfo reportInfo = new SubmittedReportInfo( null, "Issue " + token, SubmittedReportInfo.SubmissionStatus.NEW_ISSUE); callback.consume(reportInfo); ReportMessages.GROUP .createNotification( ReportMessages.ERROR_REPORT, "Submitted", NotificationType.INFORMATION, null) .setImportant(false) .notify(project); } }; Consumer<Exception> errorCallback = new Consumer<Exception>() { @Override public void consume(Exception e) { String message = GoBundle.message("go.error.report.message", e.getMessage()); ReportMessages.GROUP .createNotification( ReportMessages.ERROR_REPORT, message, NotificationType.ERROR, NotificationListener.URL_OPENING_LISTENER) .setImportant(false) .notify(project); } }; AnonymousFeedbackTask task = new AnonymousFeedbackTask( project, "Submitting error report", true, reportValues, successCallback, errorCallback); if (project == null) { task.run(new EmptyProgressIndicator()); } else { ProgressManager.getInstance().run(task); } return true; }
public static void runCheck(@NotNull final Project project) { List<DependencyOnPlugin> dependencies = ExternalDependenciesManager.getInstance(project).getDependencies(DependencyOnPlugin.class); if (dependencies.isEmpty()) return; List<String> customRepositories = UpdateSettings.getInstance().getStoredPluginHosts(); final List<String> errorMessages = new ArrayList<String>(); final List<String> missingCustomRepositories = new ArrayList<String>(); final List<IdeaPluginDescriptor> disabled = new ArrayList<IdeaPluginDescriptor>(); final List<PluginId> notInstalled = new ArrayList<PluginId>(); for (DependencyOnPlugin dependency : dependencies) { PluginId pluginId = PluginId.getId(dependency.getPluginId()); String channel = dependency.getChannel(); String customRepository = getCustomRepository(pluginId, channel); if (!StringUtil.isEmpty(channel) && customRepositoryNotSpecified(customRepositories, customRepository)) { errorMessages.add( "Custom repository '" + customRepository + "' required for '" + project.getName() + "' project isn't installed."); missingCustomRepositories.add(customRepository); } IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId); if (plugin == null) { errorMessages.add( "Plugin '" + dependency.getPluginId() + "' required for '" + project.getName() + "' project isn't installed."); notInstalled.add(pluginId); continue; } if (!plugin.isEnabled()) { errorMessages.add( "Plugin '" + plugin.getName() + "' required for '" + project.getName() + "' project is disabled."); disabled.add(plugin); continue; } String minVersion = dependency.getMinVersion(); if (minVersion != null && VersionComparatorUtil.compare(plugin.getVersion(), minVersion) < 0) { errorMessages.add( "Project '" + project.getName() + "' requires plugin '" + plugin.getName() + "' version '" + minVersion + "' or higher, but '" + plugin.getVersion() + "' is installed."); } String maxVersion = dependency.getMaxVersion(); if (maxVersion != null && VersionComparatorUtil.compare(plugin.getVersion(), maxVersion) > 0) { errorMessages.add( "Project '" + project.getName() + "' requires plugin '" + plugin.getName() + "' version '" + minVersion + "' or lower, but '" + plugin.getVersion() + "' is installed."); } } if (!errorMessages.isEmpty()) { if (!missingCustomRepositories.isEmpty()) { errorMessages.add( "<a href=\"addRepositories\">Add custom repositories and install required plugins</a>"); } else if (!disabled.isEmpty() && notInstalled.isEmpty()) { String plugins = disabled.size() == 1 ? disabled.get(0).getName() : "required plugins"; errorMessages.add("<a href=\"enable\">Enable " + plugins + "</a>"); } else if (!disabled.isEmpty() || !notInstalled.isEmpty()) { errorMessages.add("<a href=\"install\">Install required plugins</a>"); } NOTIFICATION_GROUP .createNotification( "Required plugins weren't loaded", StringUtil.join(errorMessages, "<br>"), NotificationType.ERROR, new NotificationListener() { @Override public void hyperlinkUpdate( @NotNull final Notification notification, @NotNull HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if ("addRepositories".equals(event.getDescription())) { UpdateSettings.getInstance() .getStoredPluginHosts() .addAll(missingCustomRepositories); } if ("enable".equals(event.getDescription())) { notification.expire(); for (IdeaPluginDescriptor descriptor : disabled) { PluginManagerCore.enablePlugin(descriptor.getPluginId().getIdString()); } PluginManagerMain.notifyPluginsUpdated(project); } else if ("install".equals(event.getDescription()) || "addRepositories".equals(event.getDescription())) { Set<String> pluginIds = new HashSet<String>(); for (IdeaPluginDescriptor descriptor : disabled) { pluginIds.add(descriptor.getPluginId().getIdString()); } for (PluginId pluginId : notInstalled) { pluginIds.add(pluginId.getIdString()); } PluginsAdvertiser.installAndEnablePlugins( pluginIds, () -> notification.expire()); } } } }) .notify(project); } }