use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.
the class WTableRenderer_Test method testDoPainWithRowHeaderColumn.
@Test
public void testDoPainWithRowHeaderColumn() throws IOException, SAXException, XpathException {
WTable table = new WTable();
table.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
table.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
table.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
// set the first column as the row headers
table.setRowHeaders(true);
TableModel tableModel = createTableModel();
table.setTableModel(tableModel);
assertSchemaMatch(table);
assertXpathExists("//ui:table/ui:tbody/ui:tr/ui:th", table);
assertXpathNotExists("//ui:table/ui:tbody/ui:tr/ui:th[2]", table);
}
use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.
the class WTableRenderer_Test method testDoPaintSortableSortModeDynamic.
@Test
public void testDoPaintSortableSortModeDynamic() 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 = createTableModelSortable();
component.setTableModel(tableModel);
component.setVisible(true);
// sortMode dynamic
component.setSortMode(SortMode.DYNAMIC);
assertSchemaMatch(component);
assertXpathEvaluatesTo("dynamic", "//ui:table/ui:sort/@mode", component);
assertXpathEvaluatesTo(TRUE, "//ui:table/ui:thead/ui:th[1]/@sortable", component);
assertXpathNotExists("//ui:table/ui:thead/ui:th[2]/@sortable", component);
assertXpathEvaluatesTo(TRUE, "//ui:table/ui:thead/ui:th[3]/@sortable", component);
}
use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.
the class WTableRenderer_Test method testDoPaintMissingAttributesColumnStripingSeparatorsBoth.
@Test
public void testDoPaintMissingAttributesColumnStripingSeparatorsBoth() 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));
component.setTableModel(createTableModel());
component.setVisible(true);
component.setStripingType(WTable.StripingType.COLUMNS);
component.setSeparatorType(WTable.SeparatorType.BOTH);
assertSchemaMatch(component);
assertXpathNotExists("//ui:table/@caption", component);
assertXpathEvaluatesTo("table", "//ui:table/@type", component);
assertXpathEvaluatesTo("cols", "//ui:table/@striping", component);
assertXpathEvaluatesTo("both", "//ui:table/@separators", component);
}
use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.
the class WTableRenderer_Test method testDoPaintTableActions.
@Test
public void testDoPaintTableActions() 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.addAction(new WButton(TEST_ACTION_ONE));
component.addAction(new WButton(TEST_ACTION_TWO));
assertSchemaMatch(component);
assertXpathExists("//ui:table/ui:actions", component);
assertXpathEvaluatesTo(TEST_ACTION_ONE, "//ui:table/ui:actions/ui:action[1]/html:button", component);
assertXpathEvaluatesTo(TEST_ACTION_TWO, "//ui:table/ui:actions/ui:action[2]/html:button", component);
}
use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.
the class WTableRenderer_Test method testDoPaintAttributesAndContent.
@Test
public void testDoPaintAttributesAndContent() throws IOException, SAXException, XpathException {
WTable component = new WTable();
// renderer class
component.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
// renderer instance
component.addColumn(new WTableColumn(COL2_HEADING_TEST, new WTextField()));
component.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
TableModel tableModel = createTableModel();
component.setTableModel(tableModel);
component.setVisible(true);
component.setCaption(CAPTION_TEST);
component.setType(WTable.Type.HIERARCHIC);
setActiveContext(createUIContext());
assertSchemaMatch(component);
// check ui:table attributes
String tableId = component.getId();
assertXpathEvaluatesTo(tableId, "//ui:table/@id", component);
assertXpathEvaluatesTo(CAPTION_TEST, "//ui:table/@caption", component);
assertXpathEvaluatesTo("hierarchic", "//ui:table/@type", component);
// check header values
String[] colHeaders = { COL1_HEADING_TEST, COL2_HEADING_TEST, COL3_HEADING_TEST };
for (int i = 0; i < component.getColumnCount(); i++) {
assertXpathEvaluatesTo(colHeaders[i], "//ui:table/ui:thead/ui:th[" + (i + 1) + "]/ui:decoratedlabel/ui:labelbody", component);
}
// check table content
for (int i = 0; i < tableModel.getRowCount(); i++) {
List<Integer> row = new ArrayList<>();
row.add(i);
for (int j = 0; j < component.getColumnCount(); j++) {
assertXpathEvaluatesTo((String) tableModel.getValueAt(row, j), "//ui:table/ui:tbody/ui:tr[" + (i + 1) + "]/ui:td[" + (j + 1) + "]/ui:textfield", component);
}
}
}
Aggregations