String className = "element";
boolean woTag = WodHtmlUtils.isWOTag(nodeName);
boolean woSimpleString = false;
IWodElement wodElement = null;
if (woTag) {
className = className + " wo";
try {
BuildProperties buildProperties = (BuildProperties)_editor.getParserCache().getProject().getAdapter(BuildProperties.class);
wodElement = WodHtmlUtils.getWodElement(element, buildProperties, true, cache);
}
catch (Throwable t) {
// IGNORE
t.printStackTrace();
}
if (wodElement != null) {
className = className + " " + wodElement.getElementType();
if ("WOString".equals(wodElement.getElementType()) || "ERXLocalizedString".equals(wodElement.getElementType())) {
if (wodElement.getBindingNamed("value") != null) {
if (wodElement.getBindingNamed("escapeHTML") != null && wodElement.getBindings().size() == 2) {
woSimpleString = true;
}
else if (wodElement.getBindings().size() == 1) {
woSimpleString = true;
}
}
// MS: FORCE OFF FOR NOW
//woSimpleString = false;
if (woSimpleString) {
className = className + " simple";
}
}
}
}
else {
className = className + " " + nodeName.toLowerCase();
}
boolean showExpandCollapse = !empty;
if ("script".equalsIgnoreCase(nodeName)) {
// don't show script
showExpandCollapse = false;
}
else if ("style".equalsIgnoreCase(nodeName)) {
// don't show style
showExpandCollapse = false;
}
if (!showExpandCollapse) {
className += " empty";
}
//renderBuffer.append("<div id = \"" + nodeID + "\" class = \"" + className + "\" onmouseover = \"window.status = 'over:" + nodeID + "';\" onmouseout = \"window.status = 'out:" + nodeID + "';\" >");
renderBuffer.append("<div id = \"" + nodeID + "\" class = \"" + className + "\">");
if (showExpandCollapse) {
renderBuffer.append("<div id = \"" + nodeID + "_toggle\" class = \"expandcollapse\" onclick = \"expandCollapse('" + nodeID + "')\">");
if (_collapsedIDs.contains(nodeID)) {
renderBuffer.append(TemplateOutlinePage.EXPAND_STRING);
}
else {
renderBuffer.append(TemplateOutlinePage.COLLAPSE_STRING);
}
renderBuffer.append("</div>");
}
renderBuffer.append("<div class = \"summary\" onclick = \"window.status = 'select:" + nodeID + "'\">");
// ... a simple string tag
if (woSimpleString) {
IWodBinding valueBinding = wodElement.getBindingNamed("value");
String text = valueBinding.getValue();
String textClassName;
if (valueBinding.isLiteral()) {
//text = text.replaceAll("^\"([^\"]+)\"", "$1");
textClassName = "text literal";
}
else if (valueBinding.isOGNL()) {
textClassName = "text ognl";
}
else {
textClassName = "text keypath";
}
renderBuffer.append("<div class = \"title\"></div> <div class = \"" + textClassName + "\">[" + text + "]</div>");
}
// ... a WO tag
else if (woTag) {
if (wodElement != null) {
if (WodHtmlUtils.isInline(nodeName)) {
String summaryName = wodElement.getElementType();
renderBuffer.append("<div class = \"title\"><span class = \"nodeName verbose\">" + summaryName + "</span></div>");
// Special case for the compact display of a conditional
if ("WOConditional".equals(summaryName)) {
String conditionValue = wodElement.getBindingValue("condition");
if (conditionValue != null) {
summaryName = conditionValue;
boolean negated = false;
IWodBinding negateBinding = wodElement.getBindingNamed("negate");
if (negateBinding != null) {
if (negateBinding.isTrueValue()) {
negated = true;
}
}
else if (nodeName.equals("wo:not")) {
negated = true;
}
if (negated) {
summaryName = "<span class = \"negate\">not</span> " + summaryName;
}
else if (negateBinding != null) {
summaryName = summaryName + " <span class = \"negate\">not = " + negateBinding.getValue() + "</span>";
}
}
}
// Special case for the compact display of a string
else if ("WOString".equals(summaryName)) {
String value = wodElement.getBindingValue("value");
if (value != null) {
summaryName = "WOString: " + value;
}
}
// Special case for the compact display of a localized string
else if ("ERXLocalizedString".equals(summaryName)) {
String value = wodElement.getBindingValue("value");
if (value != null) {
summaryName = "ERXLocalizedString: " + value;
}
}
// Special case for the compact display of links, buttons, etc
else if (wodElement.getBindingNamed("action") != null) {
String action = wodElement.getBindingValue("action");
summaryName = wodElement.getElementType() + ": " + action;
}
// Special case for the compact display of form fields
else if (wodElement.getBindingNamed("value") != null) {
String value = wodElement.getBindingValue("value");
summaryName = wodElement.getElementType() + ": " + value;
}
// Special case for the compact display of checkboxes
else if (wodElement.getBindingNamed("checked") != null) {
String checked = wodElement.getBindingValue("checked");
summaryName = wodElement.getElementType() + ": " + checked;
}
// Special case for the compact display of repetitions and popup buttons
else if (wodElement.getBindingNamed("list") != null) {
String list = wodElement.getBindingValue("list");
summaryName = wodElement.getElementType() + ": " + list;
}
renderBuffer.append("<div class = \"title\"><span class = \"nodeName compact\">" + summaryName + "</span></div>");
}
else {
renderBuffer.append("<div class = \"title\"><span class = \"nodeName\">" + wodElement.getElementName() + "</span> <span class = \"type\">: " + wodElement.getElementType() + "</span></div>");
}
// WO bindings
List<IWodBinding> wodBindings = wodElement.getBindings();
if (wodBindings.size() > 0) {
renderBuffer.append("<table class = \"bindings\">");
for (IWodBinding wodBinding : wodBindings) {
renderBuffer.append("<tr>");
renderBuffer.append("<th>" + wodBinding.getName() + "</th>");