Search in sources :

Example 26 with TableModel

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

the class WTableRenderer_Test method testDoPaintSelectModeMultipleSelectAllText.

@Test
public void testDoPaintSelectModeMultipleSelectAllText() 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.setSelectAllMode(WTable.SelectAllType.TEXT);
    assertXpathExists("//ui:table/ui:rowselection", component);
    assertXpathEvaluatesTo(TRUE, "//ui:table/ui:rowselection/@multiple", component);
    assertXpathEvaluatesTo("text", "//ui:table/ui:rowselection/@selectAll", 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)

Example 27 with TableModel

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

the class WTableRenderer_Test method testDoPaintSelectModeMultipleSelectAllControlSubmitOnChangeAndGroupName.

@Test
public void testDoPaintSelectModeMultipleSelectAllControlSubmitOnChangeAndGroupName() 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.setSelectAllMode(WTable.SelectAllType.CONTROL);
    setActiveContext(createUIContext());
    assertXpathExists("//ui:table/ui:rowselection", component);
    assertXpathEvaluatesTo(TRUE, "//ui:table/ui:rowselection/@multiple", component);
    assertXpathEvaluatesTo("control", "//ui:table/ui:rowselection/@selectAll", 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)

Example 28 with TableModel

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

the class WTableRenderer_Test method testDoPaintWithRowsPerPageOptions.

@Test
public void testDoPaintWithRowsPerPageOptions() 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.DYNAMIC);
    component.setRowsPerPageOptions(Arrays.asList(10, 20, 30));
    setActiveContext(createUIContext());
    assertXpathEvaluatesTo("dynamic", "//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);
    assertXpathEvaluatesTo("10", "//ui:table/ui:pagination/ui:rowsselect/ui:option[1]/@value", component);
    assertXpathEvaluatesTo("20", "//ui:table/ui:pagination/ui:rowsselect/ui:option[2]/@value", component);
    assertXpathEvaluatesTo("30", "//ui:table/ui:pagination/ui:rowsselect/ui:option[3]/@value", 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)

Example 29 with TableModel

use of com.github.bordertech.wcomponents.WTable.TableModel 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);
    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);
}
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

TableModel (com.github.bordertech.wcomponents.WTable.TableModel)29 WTable (com.github.bordertech.wcomponents.WTable)25 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)25 Test (org.junit.Test)24 AdapterBasicTableModel (com.github.bordertech.wcomponents.AdapterBasicTableModel)23 SimpleTableModel (com.github.bordertech.wcomponents.SimpleTableModel)23 WTextField (com.github.bordertech.wcomponents.WTextField)22 WButton (com.github.bordertech.wcomponents.WButton)4 ActionConstraint (com.github.bordertech.wcomponents.WTable.ActionConstraint)4 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)4 UIContext (com.github.bordertech.wcomponents.UIContext)2 RowIdWrapper (com.github.bordertech.wcomponents.WTable.RowIdWrapper)2 ArrayList (java.util.ArrayList)2 WComponent (com.github.bordertech.wcomponents.WComponent)1 WRepeater (com.github.bordertech.wcomponents.WRepeater)1 WTableRowRenderer (com.github.bordertech.wcomponents.WTableRowRenderer)1 WText (com.github.bordertech.wcomponents.WText)1 SystemException (com.github.bordertech.wcomponents.util.SystemException)1 MockRequest (com.github.bordertech.wcomponents.util.mock.MockRequest)1