Search in sources :

Example 1 with GroupAggregationInputValueChangeContext

use of com.haulmont.cuba.web.widgets.CubaGroupTable.GroupAggregationInputValueChangeContext in project cuba by cuba-platform.

the class WebGroupTable method distributeGroupAggregation.

@SuppressWarnings("unchecked")
protected boolean distributeGroupAggregation(AggregationInputValueChangeContext context) {
    if (distributionProvider != null) {
        String value = context.getValue();
        Object columnId = context.getColumnId();
        GroupInfo groupInfo = null;
        try {
            Object parsedValue = getParsedAggregationValue(value, columnId);
            Collection<E> scope = Collections.emptyList();
            if (context.isTotalAggregation()) {
                TableItems<E> tableItems = getItems();
                scope = tableItems == null ? Collections.emptyList() : tableItems.getItems();
            } else if (context instanceof GroupAggregationInputValueChangeContext) {
                Object groupId = ((GroupAggregationInputValueChangeContext) context).getGroupInfo();
                if (groupId instanceof GroupInfo) {
                    groupInfo = (GroupInfo) groupId;
                    scope = ((GroupTableItems) getItems()).getChildItems(groupInfo);
                }
            }
            GroupAggregationDistributionContext<E> aggregationDistribution = new GroupAggregationDistributionContext(getColumnNN(columnId.toString()), parsedValue, scope, groupInfo, context.isTotalAggregation());
            distributionProvider.onDistribution(aggregationDistribution);
        } catch (ValueConversionException e) {
            showParseErrorNotification(e.getLocalizedMessage());
            // rollback to previous value
            return false;
        } catch (ParseException e) {
            showParseErrorNotification(messages.getMainMessage("validationFail"));
            // rollback to previous value
            return false;
        }
    }
    return true;
}
Also used : GroupInfo(com.haulmont.cuba.gui.data.GroupInfo) GroupAggregationInputValueChangeContext(com.haulmont.cuba.web.widgets.CubaGroupTable.GroupAggregationInputValueChangeContext) ParseException(java.text.ParseException) GroupTableItems(com.haulmont.cuba.gui.components.data.GroupTableItems) ValueConversionException(com.haulmont.chile.core.datatypes.ValueConversionException)

Aggregations

ValueConversionException (com.haulmont.chile.core.datatypes.ValueConversionException)1 GroupTableItems (com.haulmont.cuba.gui.components.data.GroupTableItems)1 GroupInfo (com.haulmont.cuba.gui.data.GroupInfo)1 GroupAggregationInputValueChangeContext (com.haulmont.cuba.web.widgets.CubaGroupTable.GroupAggregationInputValueChangeContext)1 ParseException (java.text.ParseException)1