Search in sources :

Example 1 with ImmutableMeasureModel

use of org.activityinfo.ui.client.analysis.model.ImmutableMeasureModel in project activityinfo by bedatadriven.

the class MeasurePane method updateMeasureLabel.

private void updateMeasureLabel(MeasureModel measureModel, String newLabel) {
    ImmutableMeasureModel updatedMeasure = ImmutableMeasureModel.builder().from(measureModel).label(newLabel).build();
    viewModel.updateModel(viewModel.getWorkingModel().withMeasure(updatedMeasure));
}
Also used : ImmutableMeasureModel(org.activityinfo.ui.client.analysis.model.ImmutableMeasureModel)

Example 2 with ImmutableMeasureModel

use of org.activityinfo.ui.client.analysis.model.ImmutableMeasureModel in project activityinfo by bedatadriven.

the class MeasurePane method updateMeasureFormula.

private void updateMeasureFormula(MeasureModel measure, String formula) {
    ImmutableMeasureModel updatedMeasure = ImmutableMeasureModel.builder().from(measure).formula(formula).build();
    viewModel.updateModel(viewModel.getWorkingModel().withMeasure(updatedMeasure));
}
Also used : ImmutableMeasureModel(org.activityinfo.ui.client.analysis.model.ImmutableMeasureModel)

Example 3 with ImmutableMeasureModel

use of org.activityinfo.ui.client.analysis.model.ImmutableMeasureModel in project activityinfo by bedatadriven.

the class MeasurePane method updateStatistic.

private void updateStatistic(MeasureModel measureModel, Statistic statistic, Tree.CheckState checked) {
    Set<Statistic> newSelection = new HashSet<>(measureModel.getStatistics());
    if (checked == Tree.CheckState.CHECKED) {
        newSelection.add(statistic);
    } else {
        newSelection.remove(statistic);
    }
    ImmutableMeasureModel updatedMeasure = ImmutableMeasureModel.builder().from(measureModel).statistics(newSelection).build();
    viewModel.updateModel(viewModel.getWorkingModel().withMeasure(updatedMeasure));
}
Also used : Statistic(org.activityinfo.ui.client.analysis.model.Statistic) HashSet(java.util.HashSet) ImmutableMeasureModel(org.activityinfo.ui.client.analysis.model.ImmutableMeasureModel)

Example 4 with ImmutableMeasureModel

use of org.activityinfo.ui.client.analysis.model.ImmutableMeasureModel in project activityinfo by bedatadriven.

the class MeasureDialog method onCalculate.

private void onCalculate(SelectEvent event) {
    ResourceId selectedFormId = model.getSelectedForms().getList().get(0);
    FormulaDialog dialog = new FormulaDialog(model.getFormStore(), selectedFormId);
    dialog.show(null, expr -> {
        ImmutableMeasureModel measure = ImmutableMeasureModel.builder().formId(selectedFormId).formula(expr.getFormula()).label(expr.getFormula()).addStatistics(Statistic.SUM).build();
        select(measure);
    });
}
Also used : ResourceId(org.activityinfo.model.resource.ResourceId) FormulaDialog(org.activityinfo.ui.client.formulaDialog.FormulaDialog) ImmutableMeasureModel(org.activityinfo.ui.client.analysis.model.ImmutableMeasureModel)

Aggregations

ImmutableMeasureModel (org.activityinfo.ui.client.analysis.model.ImmutableMeasureModel)4 HashSet (java.util.HashSet)1 ResourceId (org.activityinfo.model.resource.ResourceId)1 Statistic (org.activityinfo.ui.client.analysis.model.Statistic)1 FormulaDialog (org.activityinfo.ui.client.formulaDialog.FormulaDialog)1