Search in sources :

Example 26 with WTable

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

the class WTableRenderer_Test method testDoPaintMissingAttributesRowStriping.

@Test
public void testDoPaintMissingAttributesRowStriping() 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.ROWS);
    component.setSeparatorType(WTable.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 : WTable(com.github.bordertech.wcomponents.WTable) WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 27 with WTable

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

the class WTableRenderer_Test method testDoPaintTableActionsInvisibleButton.

@Test
public void testDoPaintTableActionsInvisibleButton() 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);
    WButton button1 = new WButton(TEST_ACTION_ONE);
    component.addAction(button1);
    // Visible
    assertXpathExists("//ui:table/ui:actions", component);
    // Not Visible
    button1.setVisible(false);
    assertXpathNotExists("//ui:table/ui:actions", component);
}
Also used : WTable(com.github.bordertech.wcomponents.WTable) WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) TableModel(com.github.bordertech.wcomponents.WTable.TableModel) AdapterBasicTableModel(com.github.bordertech.wcomponents.AdapterBasicTableModel) SimpleTableModel(com.github.bordertech.wcomponents.SimpleTableModel) Test(org.junit.Test)

Example 28 with WTable

use of com.github.bordertech.wcomponents.WTable 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());
    // 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);
        }
    }
}
Also used : WTable(com.github.bordertech.wcomponents.WTable) WTableColumn(com.github.bordertech.wcomponents.WTableColumn) ArrayList(java.util.ArrayList) WTextField(com.github.bordertech.wcomponents.WTextField) TableModel(com.github.bordertech.wcomponents.WTable.TableModel) AdapterBasicTableModel(com.github.bordertech.wcomponents.AdapterBasicTableModel) SimpleTableModel(com.github.bordertech.wcomponents.SimpleTableModel) ActionConstraint(com.github.bordertech.wcomponents.WTable.ActionConstraint) Test(org.junit.Test)

Example 29 with WTable

use of com.github.bordertech.wcomponents.WTable 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);
    assertXpathNotExists("//ui:table/@caption", component);
    assertXpathEvaluatesTo("table", "//ui:table/@type", component);
    assertXpathEvaluatesTo("cols", "//ui:table/@striping", component);
    assertXpathEvaluatesTo("both", "//ui:table/@separators", component);
}
Also used : WTable(com.github.bordertech.wcomponents.WTable) WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 30 with WTable

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

the class WTableRenderer_Test method testDoPaintPaginatedClient.

@Test
public void testDoPaintPaginatedClient() 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.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);
    assertXpathNotExists("//ui:table/ui:pagination/@controls", component);
    component.setPaginationLocation(PaginationLocation.BOTTOM);
    assertXpathEvaluatesTo("bottom", "//ui:table/ui:pagination/@controls", component);
}
Also used : WTable(com.github.bordertech.wcomponents.WTable) WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WTextField(com.github.bordertech.wcomponents.WTextField) TableModel(com.github.bordertech.wcomponents.WTable.TableModel) AdapterBasicTableModel(com.github.bordertech.wcomponents.AdapterBasicTableModel) SimpleTableModel(com.github.bordertech.wcomponents.SimpleTableModel) Test(org.junit.Test)

Aggregations

WTable (com.github.bordertech.wcomponents.WTable)38 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)30 Test (org.junit.Test)30 WTextField (com.github.bordertech.wcomponents.WTextField)28 TableModel (com.github.bordertech.wcomponents.WTable.TableModel)25 AdapterBasicTableModel (com.github.bordertech.wcomponents.AdapterBasicTableModel)23 SimpleTableModel (com.github.bordertech.wcomponents.SimpleTableModel)23 WButton (com.github.bordertech.wcomponents.WButton)5 ActionConstraint (com.github.bordertech.wcomponents.WTable.ActionConstraint)4 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)4 UIContext (com.github.bordertech.wcomponents.UIContext)3 RowIdWrapper (com.github.bordertech.wcomponents.WTable.RowIdWrapper)3 ArrayList (java.util.ArrayList)2 Margin (com.github.bordertech.wcomponents.Margin)1 LevelDetails (com.github.bordertech.wcomponents.SimpleBeanBoundTableModel.LevelDetails)1 WComponent (com.github.bordertech.wcomponents.WComponent)1 WRepeater (com.github.bordertech.wcomponents.WRepeater)1 SubUIContext (com.github.bordertech.wcomponents.WRepeater.SubUIContext)1 WTableRowRenderer (com.github.bordertech.wcomponents.WTableRowRenderer)1 WText (com.github.bordertech.wcomponents.WText)1