在JFace ErrorDialog中使用换行符 [英] Using newline in 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.
有什么想法吗?
推荐答案
查看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屋!