Search in sources :

Example 1 with EffectiveDimension

use of org.activityinfo.ui.client.analysis.viewModel.EffectiveDimension in project activityinfo by bedatadriven.

the class DimensionPane method onDimensionsDropped.

private void onDimensionsDropped(int insertIndex, List<EffectiveDimension> dropped) {
    List<DimensionModel> dims = new ArrayList<>();
    for (EffectiveDimension effectiveDimension : dropped) {
        dims.add(ImmutableDimensionModel.builder().from(effectiveDimension.getModel()).axis(this.axis).build());
    }
    String afterDimId = null;
    EffectiveDimension afterItem = listStore.get(insertIndex);
    if (afterItem != null) {
        afterDimId = afterItem.getId();
    }
    viewModel.updateModel(viewModel.getWorkingModel().reorderDimensions(afterDimId, dims));
}
Also used : DimensionModel(org.activityinfo.ui.client.analysis.model.DimensionModel) ImmutableDimensionModel(org.activityinfo.ui.client.analysis.model.ImmutableDimensionModel) ArrayList(java.util.ArrayList) EffectiveDimension(org.activityinfo.ui.client.analysis.viewModel.EffectiveDimension)

Example 2 with EffectiveDimension

use of org.activityinfo.ui.client.analysis.viewModel.EffectiveDimension 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;
}
Also used : ArrayList(java.util.ArrayList) PivotTable(org.activityinfo.ui.client.analysis.viewModel.PivotTable) EffectiveDimension(org.activityinfo.ui.client.analysis.viewModel.EffectiveDimension)

Aggregations

ArrayList (java.util.ArrayList)2 EffectiveDimension (org.activityinfo.ui.client.analysis.viewModel.EffectiveDimension)2 DimensionModel (org.activityinfo.ui.client.analysis.model.DimensionModel)1 ImmutableDimensionModel (org.activityinfo.ui.client.analysis.model.ImmutableDimensionModel)1 PivotTable (org.activityinfo.ui.client.analysis.viewModel.PivotTable)1