private void showDetail(final Message msg) {
msg.setNew(false);
final DefaultWindow window = new DefaultWindow(Console.CONSTANTS.common_label_messageDetailTitle());
window.setWidth(480);
window.setHeight(360);
window.setGlassEnabled(true);
ImageResource icon = MessageCenterView.getSeverityIcon(msg.getSeverity());
AbstractImagePrototype prototype = AbstractImagePrototype.create(icon);
SafeHtmlBuilder html = new SafeHtmlBuilder();
// TODO: XSS prevention?
html.appendHtmlConstant(prototype.getHTML());
html.appendHtmlConstant(" ");
html.appendHtmlConstant(msg.getFired().toString());
html.appendHtmlConstant("<h3 id='consise-message'>");
html.appendHtmlConstant(msg.getConciseMessage());
html.appendHtmlConstant("</h3>");
html.appendHtmlConstant("<p/>");
String detail = msg.getDetailedMessage() != null ? msg.getDetailedMessage() : "";
html.appendHtmlConstant("<pre style='font-family:tahoma, verdana, sans-serif;' id='detail-message'>");
html.appendHtmlConstant(detail);
html.appendHtmlConstant("</pre>");
final HTML widget = new HTML(html.toSafeHtml());
widget.getElement().setAttribute("style", "margin:5px");
DialogueOptions options = new DialogueOptions(
"OK",
new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
window.hide();
}
},
Console.CONSTANTS.common_label_cancel(),
new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
window.hide();
}
}
);
options.getSubmit().setAttribute("aria-describedby", "consise-message detail-message");
Widget windowContent = new WindowContentBuilder(widget, options).build();
TrappedFocusPanel trap = new TrappedFocusPanel(windowContent)
{
@Override
protected void onAttach() {
super.onAttach();
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
getFocus().onFirstButton();
}
});
}
};
window.setWidget(trap);
window.addCloseHandler(new CloseHandler<PopupPanel>() {
@Override
public void onClose(CloseEvent<PopupPanel> event) {
messagePopup.getMessageList().getSelectionModel().setSelected(msg, false);
messagePopup.hide();
}
});
messagePopup.hide();
window.center();
}