Search in sources :

Example 16 with ApplicationInfoEx

use of com.intellij.openapi.application.ex.ApplicationInfoEx in project intellij-community by JetBrains.

the class ITNProxy method createParameters.

@NotNull
private static Multimap<String, String> createParameters(String login, String password, @NotNull ErrorBean error) {
    Multimap<String, String> params = ArrayListMultimap.create(40, 1);
    params.put("protocol.version", "1");
    params.put("user.login", login);
    params.put("user.password", password);
    params.put("os.name", SystemProperties.getOsName());
    params.put("java.version", SystemProperties.getJavaVersion());
    params.put("java.vm.vendor", SystemProperties.getJavaVmVendor());
    ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
    ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
    Application application = ApplicationManager.getApplication();
    params.put("app.name", namesInfo.getProductName());
    params.put("app.name.full", namesInfo.getFullProductName());
    params.put("app.name.version", appInfo.getVersionName());
    params.put("app.eap", Boolean.toString(appInfo.isEAP()));
    params.put("app.internal", Boolean.toString(application.isInternal()));
    params.put("app.build", appInfo.getApiVersion());
    params.put("app.version.major", appInfo.getMajorVersion());
    params.put("app.version.minor", appInfo.getMinorVersion());
    params.put("app.build.date", format(appInfo.getBuildDate()));
    params.put("app.build.date.release", format(appInfo.getMajorReleaseBuildDate()));
    params.put("app.compilation.timestamp", IdeaLogger.getOurCompilationTimestamp());
    BuildNumber build = appInfo.getBuild();
    String buildNumberWithAllDetails = build.asString();
    params.put("app.product.code", build.getProductCode());
    if (StringUtil.startsWith(buildNumberWithAllDetails, build.getProductCode() + "-")) {
        buildNumberWithAllDetails = buildNumberWithAllDetails.substring(build.getProductCode().length() + 1);
    }
    params.put("app.build.number", buildNumberWithAllDetails);
    UpdateSettings updateSettings = UpdateSettings.getInstance();
    params.put("update.channel.status", updateSettings.getSelectedChannelStatus().getCode());
    params.put("update.ignored.builds", StringUtil.join(updateSettings.getIgnoredBuildNumbers(), ","));
    params.put("plugin.name", error.getPluginName());
    params.put("plugin.version", error.getPluginVersion());
    params.put("last.action", error.getLastAction());
    params.put("previous.exception", error.getPreviousException() == null ? null : Integer.toString(error.getPreviousException()));
    params.put("error.message", error.getMessage());
    params.put("error.stacktrace", error.getStackTrace());
    params.put("error.description", error.getDescription());
    params.put("assignee.id", error.getAssigneeId() == null ? null : Integer.toString(error.getAssigneeId()));
    for (Attachment attachment : error.getAttachments()) {
        params.put("attachment.name", attachment.getName());
        params.put("attachment.value", attachment.getEncodedBytes());
    }
    return params;
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) BuildNumber(com.intellij.openapi.util.BuildNumber) ApplicationNamesInfo(com.intellij.openapi.application.ApplicationNamesInfo) Attachment(com.intellij.openapi.diagnostic.Attachment) UpdateSettings(com.intellij.openapi.updateSettings.impl.UpdateSettings) Application(com.intellij.openapi.application.Application) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with ApplicationInfoEx

use of com.intellij.openapi.application.ex.ApplicationInfoEx in project intellij-community by JetBrains.

the class AppUIUtil method getAppIconImages.

@SuppressWarnings({ "UnnecessaryFullyQualifiedName", "deprecation" })
private static List<Image> getAppIconImages() {
    ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
    List<Image> images = ContainerUtil.newArrayListWithCapacity(3);
    if (SystemInfo.isUnix) {
        //MacOS is Unix too
        String bigIconUrl = appInfo.getBigIconUrl();
        if (bigIconUrl != null) {
            images.add(com.intellij.util.ImageLoader.loadFromResource(bigIconUrl));
        }
    }
    images.add(com.intellij.util.ImageLoader.loadFromResource(appInfo.getIconUrl()));
    images.add(com.intellij.util.ImageLoader.loadFromResource(appInfo.getSmallIconUrl()));
    for (int i = 0; i < images.size(); i++) {
        Image image = images.get(i);
        if (image instanceof JBHiDPIScaledImage) {
            images.set(i, ((JBHiDPIScaledImage) image).getDelegate());
        }
    }
    return images;
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx)

Example 18 with ApplicationInfoEx

use of com.intellij.openapi.application.ex.ApplicationInfoEx in project intellij-community by JetBrains.

the class MacMainFrameDecorator method createProtocolHandler.

private static void createProtocolHandler() {
    if (ourProtocolHandler == null) {
        // install uri handler
        final ID mainBundle = invoke("NSBundle", "mainBundle");
        final ID urlTypes = invoke(mainBundle, "objectForInfoDictionaryKey:", Foundation.nsString("CFBundleURLTypes"));
        final ApplicationInfoEx info = ApplicationInfoImpl.getShadowInstance();
        final BuildNumber build = info != null ? info.getBuild() : null;
        if (urlTypes.equals(ID.NIL) && build != null && !build.isSnapshot()) {
            LOG.warn("no url bundle present. \n" + "To use platform protocol handler to open external links specify required protocols in the mac app layout section of the build file\n" + "Example: args.urlSchemes = [\"your-protocol\"] will handle following links: your-protocol://open?file=file&line=line");
            return;
        }
        ourProtocolHandler = new CustomProtocolHandler();
        Application.getApplication().setOpenURIHandler(new OpenURIHandler() {

            @Override
            public void openURI(AppEvent.OpenURIEvent event) {
                ourProtocolHandler.openLink(event.getURI());
            }
        });
    }
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) BuildNumber(com.intellij.openapi.util.BuildNumber) CustomProtocolHandler(com.intellij.ui.CustomProtocolHandler) ID(com.intellij.ui.mac.foundation.ID)

Example 19 with ApplicationInfoEx

use of com.intellij.openapi.application.ex.ApplicationInfoEx 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;
}
Also used : SubmittedReportInfo(com.intellij.openapi.diagnostic.SubmittedReportInfo) DataContext(com.intellij.openapi.actionSystem.DataContext) IdeErrorsDialog(com.intellij.diagnostic.IdeErrorsDialog) ReportMessages(com.intellij.diagnostic.ReportMessages) Task(com.intellij.openapi.progress.Task) CrashReport(com.android.tools.idea.diagnostics.crash.CrashReport) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) Map(java.util.Map) ApplicationNamesInfo(com.intellij.openapi.application.ApplicationNamesInfo) Project(com.intellij.openapi.project.Project) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) ErrorReportSubmitter(com.intellij.openapi.diagnostic.ErrorReportSubmitter) DataManager(com.intellij.ide.DataManager) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginManager(com.intellij.ide.plugins.PluginManager) ProgressManager(com.intellij.openapi.progress.ProgressManager) AndroidBundle(org.jetbrains.android.util.AndroidBundle) IdeaLogger(com.intellij.idea.IdeaLogger) IdeaLoggingEvent(com.intellij.openapi.diagnostic.IdeaLoggingEvent) Nullable(com.android.annotations.Nullable) Maps(com.google.common.collect.Maps) NotificationListener(com.intellij.notification.NotificationListener) NotificationType(com.intellij.notification.NotificationType) java.awt(java.awt) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) ErrorBean(com.intellij.errorreport.bean.ErrorBean) List(java.util.List) AbstractMessage(com.intellij.diagnostic.AbstractMessage) CrashReporter(com.android.tools.idea.diagnostics.crash.CrashReporter) UpdateSettings(com.intellij.openapi.updateSettings.impl.UpdateSettings) Pair(com.intellij.openapi.util.Pair) ApplicationManager(com.intellij.openapi.application.ApplicationManager) IdeaITNProxy(org.jetbrains.android.diagnostics.error.IdeaITNProxy) NotNull(org.jetbrains.annotations.NotNull) PluginId(com.intellij.openapi.extensions.PluginId) Consumer(com.intellij.util.Consumer) Task(com.intellij.openapi.progress.Task) AbstractMessage(com.intellij.diagnostic.AbstractMessage) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) IdeaLoggingEvent(com.intellij.openapi.diagnostic.IdeaLoggingEvent) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) ErrorBean(com.intellij.errorreport.bean.ErrorBean) SubmittedReportInfo(com.intellij.openapi.diagnostic.SubmittedReportInfo) Pair(com.intellij.openapi.util.Pair)

Example 20 with ApplicationInfoEx

use of com.intellij.openapi.application.ex.ApplicationInfoEx in project intellij-plugins by JetBrains.

the class DefaultDartFeedbackBuilder method sendFeedback.

public void sendFeedback(@NotNull Project project, @Nullable String errorMessage, @Nullable String serverLog) {
    final ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
    boolean eap = appInfo.isEAP();
    String ijBuild = eap ? appInfo.getBuild().asStringWithoutProductCode() : appInfo.getBuild().asString();
    String sdkVsn = getSdkVersion(project);
    String platDescr = StringUtil.replace(SendFeedbackAction.getDescription(), ";", " ").trim();
    String template = DartBundle.message("dart.feedback.url.template", ijBuild, sdkVsn, platDescr);
    if (errorMessage != null) {
        errorMessage = "```\n" + errorMessage + "```";
        try {
            File file = FileUtil.createTempFile("report", ".txt");
            FileUtil.writeToFile(file, errorMessage);
            if (serverLog != null) {
                // Assume serverLog is never long enough that opening and closing the file is cheaper than copying it.
                FileUtil.writeToFile(file, "\n\n" + serverLog, true);
            }
            String potentialTemplate = template + "\n\n" + DartBundle.message("dart.error.file.instructions", file.getAbsolutePath()) + "\n\n" + errorMessage;
            template = potentialTemplate.substring(0, Math.min(potentialTemplate.length(), MAX_URL_LENGTH));
        } catch (IOException e) {
        // ignore it
        }
    }
    openBrowserOnFeedbackForm(template, project);
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) IOException(java.io.IOException) File(java.io.File)

Aggregations

ApplicationInfoEx (com.intellij.openapi.application.ex.ApplicationInfoEx)20 NotNull (org.jetbrains.annotations.NotNull)4 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)3 ApplicationNamesInfo (com.intellij.openapi.application.ApplicationNamesInfo)3 UpdateSettings (com.intellij.openapi.updateSettings.impl.UpdateSettings)3 IOException (java.io.IOException)3 Application (com.intellij.openapi.application.Application)2 Attachment (com.intellij.openapi.diagnostic.Attachment)2 BuildNumber (com.intellij.openapi.util.BuildNumber)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 AbstractMessage (com.intellij.diagnostic.AbstractMessage)1 IdeErrorsDialog (com.intellij.diagnostic.IdeErrorsDialog)1 ReportMessages (com.intellij.diagnostic.ReportMessages)1 ErrorBean (com.intellij.errorreport.bean.ErrorBean)1 DataManager (com.intellij.ide.DataManager)1