Search in sources :

Example 66 with WTableColumn

use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.

the class WDataTableRenderer_Test method testDoPaintWithColWidth.

@Test
public void testDoPaintWithColWidth() throws IOException, SAXException, XpathException {
    WDataTable table = new WDataTable();
    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));
    table.getColumn(0).setWidth(0);
    table.getColumn(1).setWidth(1);
    table.getColumn(2).setWidth(100);
    TableDataModel tableModel = createTableModel();
    table.setDataModel(tableModel);
    assertXpathNotExists("//ui:table/ui:thead/ui:th[1]/@width", table);
    assertXpathEvaluatesTo("1", "//ui:table/ui:thead/ui:th[2]/@width", table);
    assertXpathEvaluatesTo("100", "//ui:table/ui:thead/ui:th[3]/@width", table);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 67 with WTableColumn

use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.

the class WDataTableRenderer_Test method testDoPaintWithInvisibleColumnAndNoColumnHeaders.

@Test
public void testDoPaintWithInvisibleColumnAndNoColumnHeaders() throws IOException, SAXException, XpathException {
    WDataTable component = new WDataTable();
    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));
    TableDataModel tableDataModel = createTableModel();
    component.setDataModel(tableDataModel);
    component.setVisible(true);
    final int testColIndex = 1;
    final boolean testShowColHeaders = false;
    component.getColumn(testColIndex).setVisible(false);
    component.setShowColumnHeaders(testShowColHeaders);
    // head hidden=true
    assertXpathEvaluatesTo(TRUE, "//ui:table/ui:thead/@hidden", component);
    // column headers - only COL1 and COL3 showing - in positions 1 and 2 respectively - only 2 cols
    assertXpathEvaluatesTo(COL1_HEADING_TEST, "//ui:table/ui:thead/ui:th[1]/ui:decoratedlabel/ui:labelbody", component);
    assertXpathEvaluatesTo(COL3_HEADING_TEST, "//ui:table/ui:thead/ui:th[2]/ui:decoratedlabel/ui:labelbody", component);
    assertXpathNotExists("//ui:table/ui:thead/ui:th[3]/ui:decoratedlabel/ui:labelbody", component);
    // first row - col1 and col3 from model in positions 1 and 2 respectively - only 2 cols showing
    String firstName = (String) tableDataModel.getValueAt(0, 0);
    String entryDate = (String) tableDataModel.getValueAt(0, 2);
    assertXpathEvaluatesTo(firstName, "//ui:table/ui:tbody/ui:tr[1]/ui:td[1]/ui:textfield", component);
    assertXpathEvaluatesTo(entryDate, "//ui:table/ui:tbody/ui:tr[1]/ui:td[2]/ui:textfield", component);
    assertXpathNotExists("//ui:table/ui:tbody/ui:tr[1]/ui:td[3]/ui:textfield", component);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) WTextField(com.github.bordertech.wcomponents.WTextField) ActionConstraint(com.github.bordertech.wcomponents.WDataTable.ActionConstraint) Test(org.junit.Test)

Example 68 with WTableColumn

use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.

the class WDataTableRenderer_Test method testDoPaintTableActions.

@Test
public void testDoPaintTableActions() throws IOException, SAXException, XpathException {
    WDataTable component = new WDataTable();
    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));
    TableDataModel tableModel = createTableModel();
    component.setDataModel(tableModel);
    component.setVisible(true);
    component.addAction(new WButton(TEST_ACTION_ONE));
    component.addAction(new WButton(TEST_ACTION_TWO));
    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);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 69 with WTableColumn

use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.

the class WDataTableRenderer_Test method testDoPaintSelectModeMultipleSelectAllControlSubmitOnChangeAndGroupName.

@Test
public void testDoPaintSelectModeMultipleSelectAllControlSubmitOnChangeAndGroupName() throws IOException, SAXException, XpathException {
    WDataTable component = new WDataTable();
    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));
    TableDataModel tableModel = createTableModel();
    component.setDataModel(tableModel);
    component.setVisible(true);
    component.setSelectMode(WDataTable.SelectMode.MULTIPLE);
    component.setSelectAllMode(WDataTable.SelectAllType.CONTROL);
    component.setSelectGroup("TEST GROUP NAME");
    component.setSubmitOnRowSelect(true);
    setActiveContext(createUIContext());
    assertXpathExists("//ui:table/ui:rowselection", component);
    assertXpathEvaluatesTo(TRUE, "//ui:table/ui:rowselection/@multiple", component);
    assertXpathEvaluatesTo("control", "//ui:table/ui:rowselection/@selectAll", component);
    assertXpathEvaluatesTo(component.getSelectGroup(), "//ui:table/ui:rowselection/@groupName", component);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 70 with WTableColumn

use of com.github.bordertech.wcomponents.WTableColumn in project wcomponents by BorderTech.

the class WDataTableRenderer_Test method testDoPaintMissingAttributesRowStriping.

@Test
public void testDoPaintMissingAttributesRowStriping() throws IOException, SAXException, XpathException {
    WDataTable component = new WDataTable();
    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.setDataModel(createTableModel());
    component.setVisible(true);
    component.setStripingType(WDataTable.StripingType.ROWS);
    component.setSeparatorType(WDataTable.SeparatorType.HORIZONTAL);
    assertXpathNotExists("//ui:table/@caption", component);
    assertXpathEvaluatesTo("table", "//ui:table/@type", component);
    assertXpathEvaluatesTo("rows", "//ui:table/@striping", component);
    assertXpathEvaluatesTo("horizontal", "//ui:table/@separators", component);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Aggregations

WTableColumn (com.github.bordertech.wcomponents.WTableColumn)76 WTextField (com.github.bordertech.wcomponents.WTextField)62 Test (org.junit.Test)57 WDataTable (com.github.bordertech.wcomponents.WDataTable)38 WTable (com.github.bordertech.wcomponents.WTable)32 TableModel (com.github.bordertech.wcomponents.WTable.TableModel)27 AdapterBasicTableModel (com.github.bordertech.wcomponents.AdapterBasicTableModel)24 SimpleTableModel (com.github.bordertech.wcomponents.SimpleTableModel)24 TableDataModel (com.github.bordertech.wcomponents.TableDataModel)24 SimpleTableDataModel (com.github.bordertech.wcomponents.SimpleTableDataModel)23 WText (com.github.bordertech.wcomponents.WText)11 WButton (com.github.bordertech.wcomponents.WButton)8 WDateField (com.github.bordertech.wcomponents.WDateField)7 TableTreeNode (com.github.bordertech.wcomponents.TableTreeNode)5 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)5 ActionConstraint (com.github.bordertech.wcomponents.WDataTable.ActionConstraint)4 ActionConstraint (com.github.bordertech.wcomponents.WTable.ActionConstraint)4 UIContext (com.github.bordertech.wcomponents.UIContext)3 TreeTableDataModel (com.github.bordertech.wcomponents.TreeTableDataModel)2 MockRequest (com.github.bordertech.wcomponents.util.mock.MockRequest)2