Search in sources :

Example 11 with TableModel

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

the class WTableRenderer_Test method testDoPaintExpandModeDynamic.

@Test
public void testDoPaintExpandModeDynamic() 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.setExpandMode(ExpandMode.DYNAMIC);
    assertXpathEvaluatesTo("dynamic", "//ui:table/ui:rowexpansion/@mode", 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 12 with TableModel

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

the class WTableRenderer_Test method testDoPaintSelectModeSingle.

@Test
public void testDoPaintSelectModeSingle() 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.SINGLE);
    assertXpathExists("//ui:table/ui:rowselection", 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 13 with TableModel

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

the class WTableRenderer_Test method testDoPaintTableActionsWithConstraints.

@Test
public void testDoPaintTableActionsWithConstraints() throws IOException, SAXException, XpathException {
    final int minSelectedRowCount1 = 1;
    final int maxSelectedRowCount1 = 2;
    final int selectedOnOther1 = 0;
    final String message1 = "message1";
    final int minSelectedRowCount2 = 1;
    final int maxSelectedRowCount2 = 2;
    final int selectedOnOther2 = 0;
    final String message2 = "message2";
    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 buttonOne = new WButton(TEST_ACTION_ONE);
    WButton buttonTwo = new WButton(TEST_ACTION_TWO);
    component.addAction(buttonOne);
    component.addAction(buttonTwo);
    component.addActionConstraint(buttonOne, new ActionConstraint(minSelectedRowCount1, maxSelectedRowCount1, true, message1));
    component.addActionConstraint(buttonTwo, new ActionConstraint(minSelectedRowCount2, maxSelectedRowCount2, false, message2));
    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);
    String expectedWarning = "error";
    assertXpathEvaluatesTo(((new Integer(minSelectedRowCount1))).toString(), "//ui:table/ui:actions/ui:action[1]/ui:condition/@minSelectedRows", component);
    assertXpathEvaluatesTo(((new Integer(maxSelectedRowCount1))).toString(), "//ui:table/ui:actions/ui:action[1]/ui:condition/@maxSelectedRows", component);
    assertXpathEvaluatesTo(((new Integer(selectedOnOther1))).toString(), "//ui:table/ui:actions/ui:action[1]/ui:condition/@selectedOnOther", component);
    assertXpathEvaluatesTo(expectedWarning, "//ui:table/ui:actions/ui:action[1]/ui:condition/@type", component);
    assertXpathEvaluatesTo(message1, "//ui:table/ui:actions/ui:action[1]/ui:condition/@message", component);
    expectedWarning = "warning";
    assertXpathEvaluatesTo(((new Integer(minSelectedRowCount2))).toString(), "//ui:table/ui:actions/ui:action[2]/ui:condition/@minSelectedRows", component);
    assertXpathEvaluatesTo(((new Integer(maxSelectedRowCount2))).toString(), "//ui:table/ui:actions/ui:action[2]/ui:condition/@maxSelectedRows", component);
    assertXpathEvaluatesTo(((new Integer(selectedOnOther2))).toString(), "//ui:table/ui:actions/ui:action[1]/ui:condition/@selectedOnOther", component);
    assertXpathEvaluatesTo(expectedWarning, "//ui:table/ui:actions/ui:action[2]/ui:condition/@type", component);
    assertXpathEvaluatesTo(message2, "//ui:table/ui:actions/ui:action[2]/ui:condition/@message", component);
}
Also used : WTable(com.github.bordertech.wcomponents.WTable) WTableColumn(com.github.bordertech.wcomponents.WTableColumn) ActionConstraint(com.github.bordertech.wcomponents.WTable.ActionConstraint) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) ActionConstraint(com.github.bordertech.wcomponents.WTable.ActionConstraint) TableModel(com.github.bordertech.wcomponents.WTable.TableModel) AdapterBasicTableModel(com.github.bordertech.wcomponents.AdapterBasicTableModel) SimpleTableModel(com.github.bordertech.wcomponents.SimpleTableModel) Test(org.junit.Test)

Example 14 with TableModel

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

the class WTableRenderer_Test method testDoPaintSortableSortModeDynamicClientSettings.

@Test
public void testDoPaintSortableSortModeDynamicClientSettings() 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));
    // sortable data model
    TableModel tableModel = createTableModelSortable();
    component.setTableModel(tableModel);
    component.setVisible(true);
    component.setSortMode(SortMode.DYNAMIC);
    setActiveContext(createUIContext());
    MockRequest request = new MockRequest();
    String colIndexStr = "0";
    request.setParameter(component.getId() + "-h", "x");
    request.setParameter(component.getId() + ".sort", colIndexStr);
    request.setParameter(component.getId() + ".sortDesc", TRUE);
    component.handleRequest(request);
    assertXpathEvaluatesTo("dynamic", "//ui:table/ui:sort/@mode", component);
    assertXpathEvaluatesTo(colIndexStr, "//ui:table/ui:sort/@col", component);
    assertXpathEvaluatesTo(TRUE, "//ui:table/ui:sort/@descending", 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) MockRequest(com.github.bordertech.wcomponents.util.mock.MockRequest) 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 15 with TableModel

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

the class WTable_Test method testDataModelAccessors.

@Test
public void testDataModelAccessors() {
    TableModel model1 = createModel(new String[0][0]);
    TableModel model2 = createModel(new String[0][0]);
    assertAccessorsCorrect(new WTable(), "tableModel", EmptyTableModel.INSTANCE, model1, model2);
}
Also used : TableModel(com.github.bordertech.wcomponents.WTable.TableModel) 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