} else {
parameters = JsoArray.from(DebuggerApiUtils.createRemoteObject(message.getText()));
}
}
Element messageElement = Elements.createDivElement(css.messageRoot());
// Add message link first.
JsonArray<StackTraceItem> stackTrace = message.getStackTrace();
StackTraceItem topFrame = stackTrace.isEmpty() ? null : stackTrace.get(0);
if (topFrame != null && !StringUtils.isNullOrEmpty(topFrame.getUrl())) {
messageElement.appendChild(formatLocationLink(
topFrame.getUrl(), topFrame.getLineNumber(), topFrame.getColumnNumber()));
} else if (!StringUtils.isNullOrEmpty(message.getUrl())) {
messageElement.appendChild(formatLocationLink(
message.getUrl(), message.getLineNumber(), 0));
}
// Add the Stack Trace expand/collapse controller.
final boolean shouldDisplayStackTrace = !stackTrace.isEmpty() &&
(message.getType() == ConsoleMessageType.TRACE ||
message.getLevel() == ConsoleMessageLevel.ERROR);
if (shouldDisplayStackTrace) {
if (ConsoleMessageType.TRACE.equals(message.getType())) {
messageElement.addClassName(css.consoleStackTraceExpanded());
} else {
messageElement.addClassName(css.consoleStackTraceCollapsed());
}
messageElement.appendChild(Elements.createSpanElement(css.consoleStackTraceController()));
}
// Add all message arguments.
for (int i = 0, n = parameters.size(); i < n; ++i) {
if (i > 0) {
messageElement.appendChild(Elements.createTextNode(" "));
}
messageElement.appendChild(
formatRemoteObjectInConsole(parameters.get(i), debuggerState, forceObjectFormat));
}
if (message.getLevel() != null) {
switch (message.getLevel()) {
case DEBUG:
messageElement.addClassName(css.consoleDebugLevel());
break;
case ERROR:
messageElement.addClassName(css.consoleErrorLevel());
break;
case LOG:
messageElement.addClassName(css.consoleLogLevel());
break;
case TIP:
messageElement.addClassName(css.consoleTipLevel());
break;
case WARNING:
messageElement.addClassName(css.consoleWarningLevel());
break;
}
}
if (shouldDisplayStackTrace) {
messageElement.appendChild(formatStackTrace(stackTrace));
}
updateConsoleMessageCount(messageElement, message.getRepeatCount());
consoleMessages.appendChild(messageElement);
}