在JFace ErrorDialog中使用换行符 [英] Using newline in JFace ErrorDialog

查看:95
本文介绍了在JFace ErrorDialog中使用换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人设法使用换行符(\ n,\ r)在JFace ErrorDialog中显示详细的错误消息?

Has anybody managed to show a detail error message in the JFace ErrorDialog using newline (\n, \r) character?

我正在尝试将StackTrace显示为详细消息,但只显示在一行中

I'm trying to display the StackTrace as a detail message, but it is only shown in one line

StringBuffer sbStackTrace = new StringBuffer();
for (StackTraceElement ste : throwable.getStackTrace()) {
  sbStackTrace.append(ste.toString()).append('\n');
}

final IStatus status = new Status(IStatus.ERROR, pluginId, statusMsg, new Throwable(sbStackTrace.toString(), throwable));
ErrorDialog dialog = new ErrorDialog(shell, "Error", customMessage, status, IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR)

在打开时,ErrorDialog显示我想要的内容,只是详细消息的格式不正确.

On open the ErrorDialog shows eveything I want, except that the detail message is not properly formatted.

有什么想法吗?

推荐答案

查看ErrorDialog.populateList(List, IStatus, int, boolean)方法.jface/src/org/eclipse/jface/dialogs/ErrorDialog.java?view = markup"rel =" nofollow> ErrorDialog.java的来源,看起来该对话框每行仅包含一个IStatus ,但是如果IStatus有子级,它将在随后的行中包括它们.因此,您将需要构建MultiStatus对象或创建自己的IStatus实现.

Looking at the ErrorDialog.populateList(List, IStatus, int, boolean) method in the source for ErrorDialog.java, it looks like the dialog only includes one IStatus per line, but if that IStatus has children, it will include them on subsequent lines. So you'll need to either build a MultiStatus object or create your own implementation of IStatus.

这篇关于在JFace ErrorDialog中使用换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆