Search in sources :

Example 1 with TableTreeNode

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

the class TreeTableExample method createTable.

/**
 * Creates and configures the table to be used by the example. The table is configured with global rather than user
 * data. Although this is not a realistic scenario, it will suffice for this example.
 *
 * @return a new configured table.
 */
private WDataTable createTable() {
    WDataTable tbl = new WDataTable();
    tbl.addColumn(new WTableColumn("First name", new WTextField()));
    tbl.addColumn(new WTableColumn("Last name", new WTextField()));
    tbl.addColumn(new WTableColumn("DOB", new WDateField()));
    tbl.setExpandMode(ExpandMode.CLIENT);
    TableTreeNode root = createTree();
    tbl.setDataModel(new ExampleTreeTableModel(root));
    return tbl;
}
Also used : TableTreeNode(com.github.bordertech.wcomponents.TableTreeNode) WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) WDateField(com.github.bordertech.wcomponents.WDateField) WTextField(com.github.bordertech.wcomponents.WTextField)

Example 2 with TableTreeNode

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

the class TreeTableHierarchyExample method createTree.

/**
 * @return a tree containing the data for this example.
 */
private TableTreeNode createTree() {
    TableTreeNode root = new TableTreeNode(null);
    SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy");
    try {
        TableTreeNode joe = new TableTreeNode(new PersonBean("Joe", "Bloggs", sdf.parse("01/02/1934")));
        TableTreeNode jane = new TableTreeNode(new PersonBean("Jane", "Bloggs", sdf.parse("02/03/1935")));
        TableTreeNode child = new TableTreeNode(new PersonBean("Child", "Bloggs", sdf.parse("03/04/1976")));
        TableTreeNode grandChild1 = new TableTreeNode(new PersonBean("Grandchild-One", "Bloggs", sdf.parse("04/05/2006")));
        TableTreeNode grandChild2 = new TableTreeNode(new PersonBean("Grandchild-Two", "Bloggs", sdf.parse("05/06/2007")));
        root.add(joe);
        root.add(jane);
        joe.add(child);
        child.add(grandChild1);
        child.add(grandChild2);
    } catch (ParseException e) {
        LogFactory.getLog(getClass()).error("Failed to create test data", e);
    }
    return root;
}
Also used : TableTreeNode(com.github.bordertech.wcomponents.TableTreeNode) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with TableTreeNode

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

the class TableLoadPerformance method createTree.

/**
 * @param beans the beans to load
 * @return the tree of nodes required by WDataTable
 */
private TableTreeNode createTree(final List<PersonBean> beans) {
    TableTreeNode top = new TableTreeNode(null);
    // Build tree
    for (PersonBean bean : beans) {
        TableTreeNode row = new TableTreeNode(bean);
        List<TravelDoc> docs = bean.getDocuments();
        if (docs != null) {
            for (TravelDoc doc : docs) {
                TableTreeNode expandNode = new ExpandNode(doc);
                row.add(expandNode);
            }
        }
        top.add(row);
    }
    return top;
}
Also used : TableTreeNode(com.github.bordertech.wcomponents.TableTreeNode) TravelDoc(com.github.bordertech.wcomponents.examples.table.PersonBean.TravelDoc)

Example 4 with TableTreeNode

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

the class DataTableOptionsExample method createExpandedDataTable.

/**
 * @return a table that has expanded content.
 */
private WDataTable createExpandedDataTable() {
    WDataTable table = new WDataTable();
    table.setType(WDataTable.Type.TABLE);
    table.addColumn(new WTableColumn("Column1", WText.class));
    table.addColumn(new WTableColumn("Column2", WText.class));
    table.addColumn(new WTableColumn("Column3", WText.class));
    table.setRowsPerPage(DEFAULT_ROWS_PER_PAGE);
    table.setSummary("Expanded content table summary");
    table.setCaption("Expanded content table caption");
    TableTreeNode root = createTree();
    table.setDataModel(new ExampleTreeTableModel(root));
    return table;
}
Also used : TableTreeNode(com.github.bordertech.wcomponents.TableTreeNode) WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WText(com.github.bordertech.wcomponents.WText) WDataTable(com.github.bordertech.wcomponents.WDataTable)

Example 5 with TableTreeNode

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

the class DataTableOptionsExample method createTree.

/**
 * @return a TableTreeNode containing sample data.
 */
private TableTreeNode createTree() {
    TableTreeNode root = new TableTreeNode(null);
    TableTreeNode row1 = new TableTreeNode(new ExampleBean("A1", "H2", "G3"));
    TableTreeNode row2 = new TableTreeNode(new ExampleBean("B1", "G2", "E3"));
    TableTreeNode row3 = new TableTreeNode(new ExampleBean("C1", "F2", "C3"));
    TableTreeNode row4 = new TableTreeNode(new ExampleBean("D1", "E2", "A3"));
    TableTreeNode row5 = new TableTreeNode(new ExampleBean("E1", "D2", "B3"));
    TableTreeNode row6 = new TableTreeNode(new ExampleBean("F1", "C2", "D3"));
    TableTreeNode row7 = new TableTreeNode(new ExampleBean("G1", "B2", "F3"));
    TableTreeNode row8 = new TableTreeNode(new ExampleBean("H1", "A2", "H3"));
    TableTreeNode extra1 = new ExtraDetailsNode(new ExtraBean("X1-A", "X1-B", "X1-C"));
    TableTreeNode extra2 = new ExtraDetailsNode(new ExtraBean("Y1-A", "Y1-B", "Y1-C"));
    TableTreeNode extra3 = new ExtraDetailsNode(new ExtraBean("Y2-A", "Y2-B", "Y2-C"));
    TableTreeNode extra4 = new ExtraDetailsNode(new ExtraBean("Z1-A", "Z1-B", "Z1-C"));
    root.add(row1);
    root.add(row2);
    root.add(row3);
    root.add(row4);
    root.add(row5);
    root.add(row6);
    root.add(row7);
    root.add(row8);
    row1.add(extra1);
    row3.add(extra2);
    row3.add(extra3);
    row7.add(extra4);
    return root;
}
Also used : TableTreeNode(com.github.bordertech.wcomponents.TableTreeNode)

Aggregations

TableTreeNode (com.github.bordertech.wcomponents.TableTreeNode)15 WDataTable (com.github.bordertech.wcomponents.WDataTable)5 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)5 TableDataModel (com.github.bordertech.wcomponents.TableDataModel)3 TreeTableDataModel (com.github.bordertech.wcomponents.TreeTableDataModel)3 WText (com.github.bordertech.wcomponents.WText)3 UIContext (com.github.bordertech.wcomponents.UIContext)2 WComponent (com.github.bordertech.wcomponents.WComponent)2 WDateField (com.github.bordertech.wcomponents.WDateField)2 WRepeater (com.github.bordertech.wcomponents.WRepeater)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 AbstractTableDataModel (com.github.bordertech.wcomponents.AbstractTableDataModel)1 AbstractTreeTableDataModel (com.github.bordertech.wcomponents.AbstractTreeTableDataModel)1 SimpleBeanTreeTableDataModel (com.github.bordertech.wcomponents.SimpleBeanTreeTableDataModel)1 WDataTableRowRenderer (com.github.bordertech.wcomponents.WDataTableRowRenderer)1 SubUIContext (com.github.bordertech.wcomponents.WRepeater.SubUIContext)1 WTextField (com.github.bordertech.wcomponents.WTextField)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1 TravelDoc (com.github.bordertech.wcomponents.examples.table.PersonBean.TravelDoc)1