use of com.github.bordertech.wcomponents.TableTreeNode in project wcomponents by BorderTech.
the class TreeTableExample 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/1973")));
TableTreeNode jane = new TableTreeNode(new PersonBean("Jane", "Bloggs", sdf.parse("04/05/1976")));
TableTreeNode kid = new TableTreeNode(new PersonBean("Kid", "Bloggs", sdf.parse("31/12/1999")));
TableTreeNode doc1 = new TravelDocNode(new TravelDoc("12345", "Canada", "Ottawa", sdf.parse("01/01/1990"), sdf.parse("01/01/1983")));
TableTreeNode doc2 = new TravelDocNode(new TravelDoc("23456", "New Zealand", "Wellington", sdf.parse("01/01/1999"), sdf.parse("01/01/2009")));
TableTreeNode doc3 = new TravelDocNode(new TravelDoc("78901", "New Zealand", "Wellington", sdf.parse("01/01/2005"), sdf.parse("01/01/2015")));
root.add(joe);
root.add(jane);
root.add(kid);
joe.add(doc1);
joe.add(doc2);
jane.add(doc3);
} catch (ParseException e) {
LogFactory.getLog(getClass()).error("Failed to create test data", e);
}
return root;
}
use of com.github.bordertech.wcomponents.TableTreeNode in project wcomponents by BorderTech.
the class TreeTableHierarchyExample 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.setType(WDataTable.Type.HIERARCHIC);
tbl.addColumn(new WTableColumn("First name", new WText()));
tbl.addColumn(new WTableColumn("Last name", new WText()));
tbl.addColumn(new WTableColumn("DOB", new WDateField()));
tbl.setExpandMode(ExpandMode.CLIENT);
tbl.setStripingType(WDataTable.StripingType.ROWS);
TableTreeNode root = createTree();
tbl.setDataModel(new ExampleTreeTableModel(root));
return tbl;
}
use of com.github.bordertech.wcomponents.TableTreeNode in project wcomponents by BorderTech.
the class TreeTableHierarchyExample method preparePaintComponent.
/**
* {@inheritDoc}
*/
@Override
protected void preparePaintComponent(final Request request) {
super.preparePaintComponent(request);
if (!isInitialised()) {
TableTreeNode root = createTree();
table.setDataModel(new ExampleTreeTableModel(root));
setInitialised(true);
}
}
use of com.github.bordertech.wcomponents.TableTreeNode in project wcomponents by BorderTech.
the class TableLoadPerformance method startLoad.
/**
* Start load.
*/
private void startLoad() {
tableLayout.setVisible(true);
List<PersonBean> beans = ExampleDataUtil.createExampleData(numRows.getNumber().intValue(), numDocs.getNumber().intValue());
if (isLoadWTable()) {
table.setBean(beans);
}
if (isLoadWDataTable()) {
TableTreeNode tree = createTree(beans);
datatable.setDataModel(new SimpleBeanTreeTableDataModel(new String[] { "firstName", "lastName", "dateOfBirth" }, tree));
}
if (isLoadWTable()) {
ajax2.setVisible(true);
tableShim.setVisible(isLoadWTable());
} else {
ajax4.setVisible(true);
dataShim.setVisible(isLoadWDataTable());
}
}
use of com.github.bordertech.wcomponents.TableTreeNode in project wcomponents by BorderTech.
the class WDataTableRenderer method doPaintRows.
/**
* Override paintRow so that we only paint the first-level nodes for tree-tables.
*
* @param table the table to paint the rows for.
* @param renderContext the RenderContext to paint to.
*/
private void doPaintRows(final WDataTable table, final WebXmlRenderContext renderContext) {
TableDataModel model = table.getDataModel();
WRepeater repeater = table.getRepeater();
List<?> beanList = repeater.getBeanList();
final int rowCount = beanList.size();
WComponent row = repeater.getRepeatedComponent();
for (int i = 0; i < rowCount; i++) {
if (model instanceof TreeTableDataModel) {
Integer nodeIdx = (Integer) beanList.get(i);
TableTreeNode node = ((TreeTableDataModel) model).getNodeAtLine(nodeIdx);
if (node.getLevel() != 1) {
// Handled by the layout, so don't paint the row.
continue;
}
}
// Each row has its own context. This is why we can reuse the same
// WComponent instance for each row.
UIContext rowContext = repeater.getRowContext(beanList.get(i), i);
UIContextHolder.pushContext(rowContext);
try {
row.paint(renderContext);
} finally {
UIContextHolder.popContext();
}
}
}
Aggregations