@Override
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
TreeColumn treeColumn = ((TreeColumn) component);
ResponseWriter writer = context.getResponseWriter();
AbstractTable table = getTable(treeColumn);
if (!treeColumn.getShowAsTree()) {
super.encodeChildren(context, component);
return;
}
int level = table.getNodeLevel();
String indentStyle = null;
String levelIndent = treeColumn.getLevelIndent();
if (!Rendering.isNullOrEmpty(levelIndent)) {
indentStyle = "width: " + levelIndent;
}
String indentClass = Styles.getCSSClass(context, table, indentStyle, DEFAULT_INDENT_CLASS);
writer.startElement("table", treeColumn);
writer.writeAttribute("cellspacing", "0", null);
writer.writeAttribute("cellpadding", "0", null);
writer.writeAttribute("class", "o_cellWrapper", null);
writer.startElement("tr", treeColumn);
writer.startElement("td", treeColumn);
for (int i = 0; i < level; i++) {
writer.writeAttribute("class", indentClass, null);
if (Environment.isOpera() && indentStyle != null)
writer.writeAttribute("style", indentStyle, null);
writer.startElement("div", treeColumn);
writer.writeAttribute("class", indentClass, null);
if ((Environment.isOpera() || Environment.isMozilla()) && indentStyle != null)
writer.writeAttribute("style", indentStyle, null);
writer.endElement("div");
writer.endElement("td");
writer.startElement("td", treeColumn);
}
boolean showTreeStructure = false;
String treeStructureStyle = showTreeStructure
? "background: url('" + Resources.internalURL(context, "table/treeStructureSolid.png") +
"') no-repeat left center;"
: null;
if (Environment.isOpera() && indentStyle != null)
writer.writeAttribute("style", indentStyle + (treeStructureStyle != null ? treeStructureStyle : ""), null);
else if (treeStructureStyle != null) {
writer.writeAttribute("style", treeStructureStyle, null);
}
boolean nodeHasChildren = table.getNodeHasChildren();
if (nodeHasChildren) {
String expansionToggleCellClass = Styles.getCSSClass(
context, table, treeColumn.getExpansionToggleCellStyle(),
DEFAULT_EXPANSION_TOGGLE_CELL_CLASS, treeColumn.getExpansionToggleCellClass());
expansionToggleCellClass = Styles.mergeClassNames(expansionToggleCellClass, indentClass);