use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WTabSetRenderer method doRender.
/**
* Paints the given WTabSet.
*
* @param component the WTabSet to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WTabSet tabSet = (WTabSet) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:tabset");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendAttribute("type", getTypeAsString(tabSet.getType()));
xml.appendOptionalAttribute("disabled", tabSet.isDisabled(), "true");
xml.appendOptionalAttribute("hidden", tabSet.isHidden(), "true");
xml.appendOptionalAttribute("contentHeight", tabSet.getContentHeight());
xml.appendOptionalAttribute("showHeadOnly", tabSet.isShowHeadOnly(), "true");
xml.appendOptionalAttribute("single", TabSetType.ACCORDION.equals(tabSet.getType()) && tabSet.isSingle(), "true");
if (WTabSet.TabSetType.ACCORDION.equals(tabSet.getType())) {
xml.appendOptionalAttribute("groupName", tabSet.getGroupName());
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(tabSet, renderContext);
paintChildren(tabSet, renderContext);
xml.appendEndTag("ui:tabset");
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WTableRenderer method paintColumnHeadings.
/**
* Paints the column headings for the given table.
*
* @param table the table to paint the headings for.
* @param renderContext the RenderContext to paint to.
*/
private void paintColumnHeadings(final WTable table, final WebXmlRenderContext renderContext) {
XmlStringBuilder xml = renderContext.getWriter();
int[] columnOrder = table.getColumnOrder();
TableModel model = table.getTableModel();
final int columnCount = columnOrder == null ? table.getColumnCount() : columnOrder.length;
xml.appendTagOpen("ui:thead");
xml.appendOptionalAttribute("hidden", !table.isShowColumnHeaders(), "true");
xml.appendClose();
for (int i = 0; i < columnCount; i++) {
int colIndex = columnOrder == null ? i : columnOrder[i];
WTableColumn col = table.getColumn(colIndex);
if (col.isVisible()) {
boolean sortable = model.isSortable(colIndex);
paintColumnHeading(col, sortable, renderContext);
}
}
xml.appendEndTag("ui:thead");
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WTableRenderer method doRender.
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WTable table = (WTable) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:table");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", table.isHidden(), "true");
xml.appendOptionalAttribute("caption", table.getCaption());
switch(table.getType()) {
case TABLE:
xml.appendAttribute("type", "table");
break;
case HIERARCHIC:
xml.appendAttribute("type", "hierarchic");
break;
default:
throw new SystemException("Unknown table type: " + table.getType());
}
switch(table.getStripingType()) {
case ROWS:
xml.appendAttribute("striping", "rows");
break;
case COLUMNS:
xml.appendAttribute("striping", "cols");
break;
case NONE:
break;
default:
throw new SystemException("Unknown striping type: " + table.getStripingType());
}
switch(table.getSeparatorType()) {
case HORIZONTAL:
xml.appendAttribute("separators", "horizontal");
break;
case VERTICAL:
xml.appendAttribute("separators", "vertical");
break;
case BOTH:
xml.appendAttribute("separators", "both");
break;
case NONE:
break;
default:
throw new SystemException("Unknown separator type: " + table.getSeparatorType());
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(table, renderContext);
if (table.getPaginationMode() != PaginationMode.NONE) {
paintPaginationDetails(table, xml);
}
if (table.getSelectMode() != SelectMode.NONE) {
paintSelectionDetails(table, xml);
}
if (table.getExpandMode() != ExpandMode.NONE) {
paintExpansionDetails(table, xml);
}
if (table.isSortable()) {
paintSortDetails(table, xml);
}
paintColumnHeadings(table, renderContext);
paintRows(table, renderContext);
paintTableActions(table, renderContext);
xml.appendEndTag("ui:table");
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WTableRenderer method paintColumnHeading.
/**
* Paints a single column heading.
*
* @param col the column to paint.
* @param sortable true if the column is sortable, false otherwise
* @param renderContext the RenderContext to paint to.
*/
private void paintColumnHeading(final WTableColumn col, final boolean sortable, final WebXmlRenderContext renderContext) {
XmlStringBuilder xml = renderContext.getWriter();
int width = col.getWidth();
Alignment align = col.getAlign();
xml.appendTagOpen("ui:th");
xml.appendOptionalAttribute("width", width > 0, width);
xml.appendOptionalAttribute("sortable", sortable, "true");
if (Alignment.RIGHT.equals(align)) {
xml.appendAttribute("align", "right");
} else if (Alignment.CENTER.equals(align)) {
xml.appendAttribute("align", "center");
}
xml.appendClose();
col.paint(renderContext);
xml.appendEndTag("ui:th");
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WTableRenderer method paintTableActions.
/**
* Paints the table actions of the table.
*
* @param table the table to paint the table actions for.
* @param renderContext the RenderContext to paint to.
*/
private void paintTableActions(final WTable table, final WebXmlRenderContext renderContext) {
XmlStringBuilder xml = renderContext.getWriter();
List<WButton> tableActions = table.getActions();
if (!tableActions.isEmpty()) {
boolean hasActions = false;
for (WButton button : tableActions) {
if (!button.isVisible()) {
continue;
}
if (!hasActions) {
hasActions = true;
xml.appendTag("ui:actions");
}
xml.appendTag("ui:action");
List<WTable.ActionConstraint> constraints = table.getActionConstraints(button);
if (constraints != null) {
for (WTable.ActionConstraint constraint : constraints) {
int minRows = constraint.getMinSelectedRowCount();
int maxRows = constraint.getMaxSelectedRowCount();
String message = constraint.getMessage();
String type = constraint.isError() ? "error" : "warning";
xml.appendTagOpen("ui:condition");
xml.appendOptionalAttribute("minSelectedRows", minRows > 0, minRows);
xml.appendOptionalAttribute("maxSelectedRows", maxRows > 0, maxRows);
xml.appendAttribute("selectedOnOther", this.selectedOnOther);
xml.appendAttribute("type", type);
xml.appendAttribute("message", I18nUtilities.format(null, message));
xml.appendEnd();
}
}
button.paint(renderContext);
xml.appendEndTag("ui:action");
}
if (hasActions) {
xml.appendEndTag("ui:actions");
}
}
}
Aggregations