assert (myElem == null) : "Render called twice for StackFrameRenderer!";
myElem = parentElem.getOwnerDocument().createDivElement();
Document document = myElem.getOwnerDocument();
final Url resource = new Url(stackFrame.getUrl());
String resourceName = resource.getLastPathComponent();
resourceName = ("".equals(resourceName)) ? resource.getPath()
: resourceName;
// If we still don't have anything, replace with [unknown]
String symbolName = (stackFrame.getFunctionName().equals(""))
? "[anonymous] " : stackFrame.getFunctionName() + "() ";
myElem.appendChild(document.createTextNode(resourceName + "::"));
myElem.appendChild(document.createTextNode(symbolName));
// We make a link out of the line number which should pop open
// the Source Viewer when clicked.
AnchorElement lineLink = document.createAnchorElement();
lineLink.getStyle().setProperty("whiteSpace", "nowrap");
String columnStr = (stackFrame.getColumnOffset() > 0) ? " Col "
+ stackFrame.getColumnOffset() : "";
lineLink.setInnerText("Line " + stackFrame.getLineNumber() + columnStr);
lineLink.setHref("javascript:;");
myElem.appendChild(lineLink);
myElem.appendChild(document.createBRElement());
stackTraceRenderer.getListenerManager().manageEventListener(
ClickEvent.addClickListener(lineLink, lineLink, new ClickListener() {
public void onClick(ClickEvent event) {
stackTraceRenderer.getSourceClickListener().onSymbolClicked(
resource.getUrl(), null, stackFrame.getLineNumber(),
stackFrame.getColumnOffset(), null);
}
}));
myElem.setClassName(stackTraceRenderer.getResources().stackFrameRendererCss().stackFrame());
parentElem.appendChild(myElem);
if (attemptResymbolization) {
// Add resymbolized data to frame/profile if it is available.
SymbolServerController ssController = SymbolServerService.getSymbolServerController(new Url(
stackTraceRenderer.getCurrentAppUrl()));
if (ssController != null) {
ssController.attemptResymbolization(
resource.getUrl(), stackFrame.getFunctionName(),
this, stackTraceRenderer.getSourcePresenter());
}
}
}