Search in sources :

Example 1 with TravelDoc

use of com.github.bordertech.wcomponents.examples.table.PersonBean.TravelDoc in project wcomponents by BorderTech.

the class ExampleDataUtil method createExampleData.

/**
 * Creates the example data.
 *
 * @param rows the number of rows to create
 * @param documents the number of documents to add to each person
 * @return the example data.
 */
public static List<PersonBean> createExampleData(final int rows, final int documents) {
    List<PersonBean> data = new ArrayList<>(rows);
    Date date1 = DateUtilities.createDate(1, 2, 1973);
    Date date2 = DateUtilities.createDate(2, 3, 1985);
    Date date3 = DateUtilities.createDate(3, 4, 2004);
    for (int i = 1; i <= rows; i++) {
        PersonBean bean = new PersonBean("P" + i, "Joe" + i, "Bloggs" + i, date1);
        List<TravelDoc> docs = new ArrayList<>(documents);
        for (int j = 1; j <= documents; j++) {
            String prefix = i + "-" + j;
            TravelDoc doc = new TravelDoc("DOC" + prefix, "Canada" + prefix, "Ottawa" + prefix, date2, date3);
            docs.add(doc);
        }
        bean.setDocuments(docs);
        data.add(bean);
    }
    return data;
}
Also used : ArrayList(java.util.ArrayList) TravelDoc(com.github.bordertech.wcomponents.examples.table.PersonBean.TravelDoc) Date(java.util.Date)

Example 2 with TravelDoc

use of com.github.bordertech.wcomponents.examples.table.PersonBean.TravelDoc 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)

Aggregations

TravelDoc (com.github.bordertech.wcomponents.examples.table.PersonBean.TravelDoc)2 TableTreeNode (com.github.bordertech.wcomponents.TableTreeNode)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1