use of org.activityinfo.ui.client.analysis.viewModel.PivotTable in project activityinfo by bedatadriven.
the class PivotTableView method buildColumnModel.
private ColumnModel<PivotRow> buildColumnModel(PivotTable pivotTable) {
List<ColumnConfig<PivotRow, ?>> columns = new ArrayList<>();
List<EffectiveDimension> rowDimensions = pivotTable.getRowDimensions();
for (int i = 0; i < rowDimensions.size(); i++) {
EffectiveDimension rowDim = rowDimensions.get(i);
ColumnConfig<PivotRow, String> column = new ColumnConfig<>(new PivotRowHeaderProvider(i));
column.setSortable(false);
column.setHideable(false);
column.setHeader(rowDim.getLabel());
column.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
columns.add(column);
}
List<PivotTable.Node> leafColumns = pivotTable.getRootColumn().getLeaves();
for (PivotTable.Node leafColumn : leafColumns) {
ColumnConfig<PivotRow, String> column = new ColumnConfig<>(new PivotValueProvider(leafColumn));
if (leafColumn.getCategoryLabel() == null) {
column.setHeader(I18N.CONSTANTS.value());
} else {
column.setHeader(leafColumn.getCategoryLabel());
}
column.setSortable(false);
column.setHideable(false);
column.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LOCALE_END);
columns.add(column);
}
ColumnModel<PivotRow> columnModel = new ColumnModel<>(columns);
if (pivotTable.getColumnDimensions().size() > 0) {
int startRow = 0;
int startCol = pivotTable.getRowDimensions().size();
addHeaderGroups(columnModel, pivotTable.getRootColumn(), startRow, startCol);
}
return columnModel;
}
Aggregations