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;
}
Aggregations