use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.
the class IdeErrorsDialog method updateForeignPluginLabel.
private void updateForeignPluginLabel(AbstractMessage message) {
if (message != null) {
final Throwable throwable = message.getThrowable();
ErrorReportSubmitter submitter = getSubmitter(throwable);
if (submitter == null) {
PluginId pluginId = findPluginId(throwable);
IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
if (plugin == null || PluginManagerMain.isDevelopedByJetBrains(plugin)) {
myForeignPluginWarningPanel.setVisible(false);
return;
}
myForeignPluginWarningPanel.setVisible(true);
String vendor = plugin.getVendor();
String contactInfo = plugin.getVendorUrl();
if (StringUtil.isEmpty(contactInfo)) {
contactInfo = plugin.getVendorEmail();
}
if (StringUtil.isEmpty(vendor)) {
if (StringUtil.isEmpty(contactInfo)) {
myForeignPluginWarningLabel.setText(DiagnosticBundle.message("error.dialog.foreign.plugin.warning.text"));
} else {
myForeignPluginWarningLabel.setHyperlinkText(DiagnosticBundle.message("error.dialog.foreign.plugin.warning.text.vendor") + " ", contactInfo, ".");
myForeignPluginWarningLabel.setHyperlinkTarget(contactInfo);
}
} else {
if (StringUtil.isEmpty(contactInfo)) {
myForeignPluginWarningLabel.setText(DiagnosticBundle.message("error.dialog.foreign.plugin.warning.text.vendor") + " " + vendor + ".");
} else {
myForeignPluginWarningLabel.setHyperlinkText(DiagnosticBundle.message("error.dialog.foreign.plugin.warning.text.vendor") + " " + vendor + " (", contactInfo, ").");
final String target = (StringUtil.equals(contactInfo, plugin.getVendorEmail()) ? "mailto:" : "") + contactInfo;
myForeignPluginWarningLabel.setHyperlinkTarget(target);
}
}
myForeignPluginWarningPanel.setVisible(true);
return;
}
}
myForeignPluginWarningPanel.setVisible(false);
}
use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.
the class ActionsTreeUtil method createPluginActionsMap.
public static Map<String, String> createPluginActionsMap() {
Set<PluginId> visited = ContainerUtil.newHashSet();
Map<String, String> result = ContainerUtil.newHashMap();
for (IdeaPluginDescriptor descriptor : PluginManagerCore.getPlugins()) {
PluginId id = descriptor.getPluginId();
visited.add(id);
if (PluginManagerCore.CORE_PLUGIN_ID.equals(id.getIdString()))
continue;
for (String actionId : ActionManagerEx.getInstanceEx().getPluginActions(id)) {
result.put(actionId, descriptor.getName());
}
}
for (PluginId id : PluginId.getRegisteredIds().values()) {
if (visited.contains(id))
continue;
for (String actionId : ActionManagerEx.getInstanceEx().getPluginActions(id)) {
result.put(actionId, id.getIdString());
}
}
return result;
}
use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.
the class ActionsTreeUtil method createPluginsActionsGroup.
private static Group createPluginsActionsGroup(Condition<AnAction> filtered) {
Group pluginsGroup = new Group(KeyMapBundle.message("plugins.group.title"), null, null);
final KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
ActionManagerEx managerEx = ActionManagerEx.getInstanceEx();
final List<IdeaPluginDescriptor> plugins = new ArrayList<>();
Collections.addAll(plugins, PluginManagerCore.getPlugins());
Collections.sort(plugins, Comparator.comparing(IdeaPluginDescriptor::getName));
List<PluginId> collected = new ArrayList<>();
for (IdeaPluginDescriptor plugin : plugins) {
collected.add(plugin.getPluginId());
Group pluginGroup;
if (plugin.getName().equals("IDEA CORE")) {
continue;
} else {
pluginGroup = new Group(plugin.getName(), null, null);
}
final String[] pluginActions = managerEx.getPluginActions(plugin.getPluginId());
if (pluginActions.length == 0) {
continue;
}
Arrays.sort(pluginActions, Comparator.comparing(ActionsTreeUtil::getTextToCompare));
for (String pluginAction : pluginActions) {
if (keymapManager.getBoundActions().contains(pluginAction))
continue;
final AnAction anAction = managerEx.getActionOrStub(pluginAction);
if (filtered == null || filtered.value(anAction)) {
pluginGroup.addActionId(pluginAction);
}
}
if (pluginGroup.getSize() > 0) {
pluginsGroup.addGroup(pluginGroup);
}
}
for (PluginId pluginId : PluginId.getRegisteredIds().values()) {
if (collected.contains(pluginId))
continue;
Group pluginGroup = new Group(pluginId.getIdString(), null, null);
final String[] pluginActions = managerEx.getPluginActions(pluginId);
if (pluginActions.length == 0) {
continue;
}
for (String pluginAction : pluginActions) {
if (keymapManager.getBoundActions().contains(pluginAction))
continue;
final AnAction anAction = managerEx.getActionOrStub(pluginAction);
if (filtered == null || filtered.value(anAction)) {
pluginGroup.addActionId(pluginAction);
}
}
if (pluginGroup.getSize() > 0) {
pluginsGroup.addGroup(pluginGroup);
}
}
return pluginsGroup;
}
use of com.intellij.ide.plugins.IdeaPluginDescriptor in project android by JetBrains.
the class ErrorReporter method submit.
@Override
public boolean submit(@NotNull IdeaLoggingEvent[] events, @Nullable String description, @Nullable Component parentComponent, @NotNull Consumer<SubmittedReportInfo> callback) {
IdeaLoggingEvent event = events[0];
ErrorBean bean = new ErrorBean(event.getThrowable(), IdeaLogger.ourLastActionId);
final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
bean.setDescription(description);
bean.setMessage(event.getMessage());
Throwable t = event.getThrowable();
if (t != null) {
final PluginId pluginId = IdeErrorsDialog.findPluginId(t);
if (pluginId != null) {
final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
if (ideaPluginDescriptor != null && (!ideaPluginDescriptor.isBundled() || ideaPluginDescriptor.allowBundledUpdate())) {
bean.setPluginName(ideaPluginDescriptor.getName());
bean.setPluginVersion(ideaPluginDescriptor.getVersion());
}
}
}
Object data = event.getData();
// Early escape (and no UI impact) if these are analytics events being pushed from the platform
if (handleAnalyticsReports(t, data)) {
return true;
}
if (data instanceof AbstractMessage) {
bean.setAttachments(((AbstractMessage) data).getIncludedAttachments());
}
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
Consumer<String> successCallback = 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 = e -> {
String message = AndroidBundle.message("error.report.at.b.android", e.getMessage());
ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT, message, NotificationType.ERROR, NotificationListener.URL_OPENING_LISTENER).setImportant(false).notify(project);
};
Task.Backgroundable feedbackTask;
if (data instanceof ErrorReportCustomizer) {
feedbackTask = ((ErrorReportCustomizer) data).makeReportingTask(project, FEEDBACK_TASK_TITLE, true, bean, successCallback, errorCallback);
} else {
List<Pair<String, String>> kv = IdeaITNProxy.getKeyValuePairs(null, null, bean, IdeaLogger.getOurCompilationTimestamp(), ApplicationManager.getApplication(), (ApplicationInfoEx) ApplicationInfo.getInstance(), ApplicationNamesInfo.getInstance(), UpdateSettings.getInstance());
feedbackTask = new SubmitCrashReportTask(project, FEEDBACK_TASK_TITLE, true, t, pair2map(kv), successCallback, errorCallback);
}
if (project == null) {
feedbackTask.run(new EmptyProgressIndicator());
} else {
ProgressManager.getInstance().run(feedbackTask);
}
return true;
}
use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-plugins by StepicOrg.
the class PluginUtils method getVersion.
@NotNull
public static String getVersion() {
PluginId pluginId = PluginId.getId(PLUGIN_ID);
IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
return plugin != null ? plugin.getVersion() : DEFAULT_PLUGIN_VERSION;
}
Aggregations