Search in sources :

Example 21 with ApplicationInfoEx

use of com.intellij.openapi.application.ex.ApplicationInfoEx in project google-cloud-intellij by GoogleCloudPlatform.

the class GoogleFeedbackErrorReporter method doSubmit.

private static boolean doSubmit(final IdeaLoggingEvent event, final Component parentComponent, final Consumer<SubmittedReportInfo> callback, final ErrorBean error, final String description) {
    error.setDescription(description);
    error.setMessage(event.getMessage());
    configureErrorFromEvent(event, error);
    ApplicationNamesInfo intelliJAppNameInfo = ApplicationNamesInfo.getInstance();
    ApplicationInfoEx intelliJAppExtendedInfo = ApplicationInfoEx.getInstanceEx();
    Map<String, String> params = buildKeyValuesMap(error, intelliJAppNameInfo, intelliJAppExtendedInfo, ApplicationManager.getApplication());
    DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
    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 ex) {
            String message = ErrorReporterBundle.message("error.googlefeedback.error", ex.getMessage());
            ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT, message, NotificationType.ERROR, NotificationListener.URL_OPENING_LISTENER).setImportant(false).notify(project);
        }
    };
    GoogleAnonymousFeedbackTask task = new GoogleAnonymousFeedbackTask(project, "Submitting error report", true, event.getThrowable(), params, error.getMessage(), error.getDescription(), ApplicationInfo.getInstance().getFullVersion(), successCallback, errorCallback);
    if (project == null) {
        task.run(new EmptyProgressIndicator());
    } else {
        ProgressManager.getInstance().run(task);
    }
    return true;
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) ApplicationNamesInfo(com.intellij.openapi.application.ApplicationNamesInfo) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) Consumer(com.intellij.util.Consumer) SubmittedReportInfo(com.intellij.openapi.diagnostic.SubmittedReportInfo)

Aggregations

ApplicationInfoEx (com.intellij.openapi.application.ex.ApplicationInfoEx)21 ApplicationNamesInfo (com.intellij.openapi.application.ApplicationNamesInfo)4 NotNull (org.jetbrains.annotations.NotNull)4 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)3 UpdateSettings (com.intellij.openapi.updateSettings.impl.UpdateSettings)3 IOException (java.io.IOException)3 DataContext (com.intellij.openapi.actionSystem.DataContext)2 Application (com.intellij.openapi.application.Application)2 Attachment (com.intellij.openapi.diagnostic.Attachment)2 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)2 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)2 Project (com.intellij.openapi.project.Project)2 BuildNumber (com.intellij.openapi.util.BuildNumber)2 Consumer (com.intellij.util.Consumer)2 URL (java.net.URL)2 Nullable (com.android.annotations.Nullable)1 CrashReport (com.android.tools.idea.diagnostics.crash.CrashReport)1 CrashReporter (com.android.tools.idea.diagnostics.crash.CrashReporter)1 Maps (com.google.common.collect.Maps)1 JsonWriter (com.google.gson.stream.JsonWriter)1