use of com.github.bordertech.wcomponents.WTable.TableModel 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.WTable.TableModel in project wcomponents by BorderTech.
the class WTableRenderer method paintColumnHeaderFooter.
/**
* Paints the column headings for the given table.
*
* @param table the table to paint the headings for.
* @param renderContext the RenderContext to paint to.
* @param renderHeaders true if rendering headers otherwise render footers
*/
private void paintColumnHeaderFooter(final WTable table, final WebXmlRenderContext renderContext, final boolean renderHeaders) {
XmlStringBuilder xml = renderContext.getWriter();
int[] columnOrder = table.getColumnOrder();
TableModel model = table.getTableModel();
final int columnCount = columnOrder == null ? table.getColumnCount() : columnOrder.length;
if (renderHeaders) {
// Headers
xml.appendTagOpen("ui:thead");
xml.appendOptionalAttribute("hidden", !table.isShowColumnHeaders(), "true");
xml.appendClose();
} else {
// Footers
xml.appendTag("tfoot");
xml.appendTag("tr");
// Allow for expandable column
if (table.getExpandMode() != ExpandMode.NONE) {
xml.appendTag("td");
xml.appendEndTag("td");
}
// Allow for selectable column
if (table.getSelectMode() != SelectMode.NONE) {
xml.appendTag("td");
xml.appendEndTag("td");
}
}
for (int i = 0; i < columnCount; i++) {
int colIndex = columnOrder == null ? i : columnOrder[i];
WTableColumn col = table.getColumn(colIndex);
if (col.isVisible()) {
if (renderHeaders) {
// Header
boolean sortable = model.isSortable(colIndex);
paintColumnHeading(col, sortable, renderContext);
} else {
// Footer
paintColumnFooting(col, renderContext);
}
}
}
if (renderHeaders) {
xml.appendEndTag("ui:thead");
} else {
xml.appendEndTag("tr");
xml.appendEndTag("tfoot");
}
}
use of com.github.bordertech.wcomponents.WTable.TableModel in project wcomponents by BorderTech.
the class WTableRenderer_Test method testDoPaintExpandModeDynamic.
@Test
public void testDoPaintExpandModeDynamic() throws IOException, SAXException, XpathException {
WTable component = new WTable();
component.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
component.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
component.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
TableModel tableModel = createTableModel();
component.setTableModel(tableModel);
component.setVisible(true);
component.setExpandMode(ExpandMode.DYNAMIC);
assertSchemaMatch(component);
assertXpathEvaluatesTo("dynamic", "//ui:table/ui:rowexpansion/@mode", component);
}
use of com.github.bordertech.wcomponents.WTable.TableModel in project wcomponents by BorderTech.
the class WTableRenderer_Test method testDoPaintToggleSubRowSelection.
@Test
public void testDoPaintToggleSubRowSelection() throws IOException, SAXException, XpathException {
WTable component = new WTable();
component.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
component.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
component.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
TableModel tableModel = createTableModel();
component.setTableModel(tableModel);
component.setVisible(true);
component.setSelectMode(WTable.SelectMode.MULTIPLE);
component.setToggleSubRowSelection(true);
component.setExpandMode(ExpandMode.CLIENT);
assertSchemaMatch(component);
assertXpathExists("//ui:table/ui:rowselection", component);
assertXpathEvaluatesTo(TRUE, "//ui:table/ui:rowselection/@toggle", component);
}
use of com.github.bordertech.wcomponents.WTable.TableModel in project wcomponents by BorderTech.
the class WTableRenderer_Test method testDoPaintSelectModeSingle.
@Test
public void testDoPaintSelectModeSingle() throws IOException, SAXException, XpathException {
WTable component = new WTable();
component.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
component.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
component.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
TableModel tableModel = createTableModel();
component.setTableModel(tableModel);
component.setVisible(true);
component.setSelectMode(WTable.SelectMode.SINGLE);
assertSchemaMatch(component);
assertXpathExists("//ui:table/ui:rowselection", component);
}
Aggregations