Search in sources :

Example 1 with TableRepeater

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

the class WTableRenderer 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 WTable table, final WebXmlRenderContext renderContext) {
    TableRepeater repeater = table.getRepeater();
    WComponent row = repeater.getRepeatedComponent();
    List<RowIdWrapper> wrappers = repeater.getBeanList();
    Set<?> otherSelectedRows = new HashSet<>(table.getSelectedRows());
    int index = -1;
    for (RowIdWrapper wrapper : wrappers) {
        index++;
        Object rowKey = wrapper.getRowKey();
        if (table.getSelectedRows().contains(rowKey)) {
            otherSelectedRows.remove(rowKey);
        }
        // Child rows handled by the layout, so dont paint the row
        if (wrapper.getParent() != null) {
            continue;
        }
        // Each row has its own context. This is why we can reuse the same
        // WComponent instance for each row.
        UIContext rowContext = repeater.getRowContext(wrapper, index);
        UIContextHolder.pushContext(rowContext);
        try {
            row.paint(renderContext);
        } finally {
            UIContextHolder.popContext();
        }
    }
    this.selectedOnOther = otherSelectedRows.size();
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) TableRepeater(com.github.bordertech.wcomponents.WTable.TableRepeater) RowIdWrapper(com.github.bordertech.wcomponents.WTable.RowIdWrapper) UIContext(com.github.bordertech.wcomponents.UIContext) HashSet(java.util.HashSet)

Aggregations

UIContext (com.github.bordertech.wcomponents.UIContext)1 WComponent (com.github.bordertech.wcomponents.WComponent)1 RowIdWrapper (com.github.bordertech.wcomponents.WTable.RowIdWrapper)1 TableRepeater (com.github.bordertech.wcomponents.WTable.TableRepeater)1 HashSet (java.util.HashSet)1