if (scanner == null) {
return;
}
Range range = new Range(new Text(id));
scanner.setRange(range);
SpanTree tree = new SpanTree();
long start = Long.MAX_VALUE;
for (Entry<Key,Value> entry : scanner) {
RemoteSpan span = TraceFormatter.getRemoteSpan(entry);
tree.addNode(span);
start = min(start, span.start);
}
sb.append("<style>\n");
sb.append(" td.right { text-align: right }\n");
sb.append(" table.indent { position: relative; left: 10% }\n");
sb.append(" td.left { text-align: left }\n");
sb.append("</style>\n");
sb.append("<script language='javascript'>\n");
sb.append("function toggle(id) {\n");
sb.append(" var elt = document.getElementById(id);\n");
sb.append(" if (elt.style.display=='none') {\n");
sb.append(" elt.style.display='table-row';\n");
sb.append(" } else { \n");
sb.append(" elt.style.display='none';\n ");
sb.append(" }\n");
sb.append("}\n");
sb.append("function ").append(pageLoadFunctionName).append("() {\n");
sb.append(" var checkboxes = document.getElementsByTagName('input');\n");
sb.append(" for (var i = 0; i < checkboxes.length; i++) {\n");
sb.append(" if (checkboxes[i].checked) {\n");
sb.append(" var idSuffixOffset = checkboxes[i].id.indexOf('").append(checkboxIdSuffix).append("');\n");
sb.append(" var id = checkboxes[i].id.substring(0, idSuffixOffset);\n");
sb.append(" document.getElementById(id).style.display='table-row';\n");
sb.append(" }\n");
sb.append(" }\n");
sb.append("}\n");
sb.append("</script>\n");
sb.append("<div>");
sb.append("<table><caption>");
sb.append(String.format("<span class='table-caption'>Trace %s started at<br>%s</span></caption>", id, dateString(start)));
sb.append("<tr><th>Time</th><th>Start</th><th>Service@Location</th><th>Name</th><th>Addl Data</th></tr>");
final long finalStart = start;
Set<Long> visited = tree.visit(new SpanTreeVisitor() {
@Override
public void visit(int level, RemoteSpan parent, RemoteSpan node, Collection<RemoteSpan> children) {
sb.append("<tr>\n");
sb.append(String.format("<td class='right'>%d+</td><td class='left'>%d</td>%n", node.stop - node.start, node.start - finalStart));
sb.append(String.format("<td style='text-indent: %dpx'>%s@%s</td>%n", level * 5, node.svc, node.sender));