Search in sources :

Example 36 with WDataTable

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

the class WDataTableRenderer_Test method testDoPaintSelectModeMultipleSelectAllControl.

@Test
public void testDoPaintSelectModeMultipleSelectAllControl() 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);
    assertXpathExists("//ui:table/ui:rowselection", component);
    assertXpathEvaluatesTo(TRUE, "//ui:table/ui:rowselection/@multiple", component);
    assertXpathEvaluatesTo("control", "//ui:table/ui:rowselection/@selectAll", 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 37 with WDataTable

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

the class WDataTableRenderer_Test method testDoPaintPaginatedClient.

@Test
public void testDoPaintPaginatedClient() 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.setPaginationMode(PaginationMode.CLIENT);
    setActiveContext(createUIContext());
    assertXpathEvaluatesTo("client", "//ui:table/ui:pagination/@mode", component);
    assertXpathEvaluatesTo((new Integer(component.getCurrentPage())).toString(), "//ui:table/ui:pagination/@currentPage", component);
    assertXpathEvaluatesTo((new Integer(component.getRowsPerPage())).toString(), "//ui:table/ui:pagination/@rowsPerPage", component);
    assertXpathEvaluatesTo((new Integer(tableModel.getRowCount())).toString(), "//ui:table/ui:pagination/@rows", 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 38 with WDataTable

use of com.github.bordertech.wcomponents.WDataTable 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)

Example 39 with WDataTable

use of com.github.bordertech.wcomponents.WDataTable 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 40 with WDataTable

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

the class WDataTableRenderer_Test method testDoPaintAttributesAndContent.

@Test
public void testDoPaintAttributesAndContent() throws IOException, SAXException, XpathException {
    WDataTable component = new WDataTable();
    // 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));
    TableDataModel tableModel = createTableModel();
    component.setDataModel(tableModel);
    component.setVisible(true);
    component.setSummary(TABLE_SUMMARY_TEST);
    component.setCaption(CAPTION_TEST);
    component.setType(WDataTable.Type.HIERARCHIC);
    setActiveContext(createUIContext());
    // 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++) {
        for (int j = 0; j < component.getColumnCount(); j++) {
            assertXpathEvaluatesTo((String) tableModel.getValueAt(i, j), "//ui:table/ui:tbody/ui:tr[" + (i + 1) + "]/ui:td[" + (j + 1) + "]/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)

Aggregations

WDataTable (com.github.bordertech.wcomponents.WDataTable)41 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)38 WTextField (com.github.bordertech.wcomponents.WTextField)29 Test (org.junit.Test)28 SimpleTableDataModel (com.github.bordertech.wcomponents.SimpleTableDataModel)23 TableDataModel (com.github.bordertech.wcomponents.TableDataModel)23 WText (com.github.bordertech.wcomponents.WText)8 TableTreeNode (com.github.bordertech.wcomponents.TableTreeNode)5 WButton (com.github.bordertech.wcomponents.WButton)5 ActionConstraint (com.github.bordertech.wcomponents.WDataTable.ActionConstraint)4 WDateField (com.github.bordertech.wcomponents.WDateField)4 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)3 UIContext (com.github.bordertech.wcomponents.UIContext)2 TreeTableDataModel (com.github.bordertech.wcomponents.TreeTableDataModel)1 WComponent (com.github.bordertech.wcomponents.WComponent)1 WDataTableRowRenderer (com.github.bordertech.wcomponents.WDataTableRowRenderer)1 WRepeater (com.github.bordertech.wcomponents.WRepeater)1 SubUIContext (com.github.bordertech.wcomponents.WRepeater.SubUIContext)1 SystemException (com.github.bordertech.wcomponents.util.SystemException)1 TreeNode (com.github.bordertech.wcomponents.util.TreeNode)1