use of io.jmix.ui.component.FilterComponent in project jmix by jmix-framework.
the class GroupFilterConverter method convertToModel.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public GroupFilterCondition convertToModel(GroupFilter groupFilter) {
GroupFilterCondition groupFilterCondition = super.convertToModel(groupFilter);
groupFilterCondition.setOperation(groupFilter.getOperation());
groupFilterCondition.setCaption(groupFilter.getCaption());
groupFilterCondition.setLocalizedCaption(getLocalizedModelCaption(groupFilter));
groupFilterCondition.setOperationCaptionVisible(groupFilter.isOperationCaptionVisible());
List<FilterCondition> ownFilterConditions = new ArrayList<>();
for (FilterComponent ownFilterComponent : groupFilter.getOwnFilterComponents()) {
FilterConverter ownFilterConverter = filterComponents.getConverterByComponentClass(ownFilterComponent.getClass(), filter);
FilterCondition ownFilterCondition = ownFilterConverter.convertToModel(ownFilterComponent);
ownFilterCondition.setParent(groupFilterCondition);
ownFilterConditions.add(ownFilterCondition);
}
if (!ownFilterConditions.isEmpty()) {
groupFilterCondition.setOwnFilterConditions(ownFilterConditions);
}
return groupFilterCondition;
}
use of io.jmix.ui.component.FilterComponent in project jmix by jmix-framework.
the class GroupFilterLoader method loadSubFilterComponents.
protected void loadSubFilterComponents(GroupFilter component, Element element) {
for (Element filterElement : element.elements()) {
ComponentLoader<?> filterComponentLoader = getLayoutLoader().createComponent(filterElement);
((FilterComponent) filterComponentLoader.getResultComponent()).setConditionModificationDelegated(true);
((FilterComponent) filterComponentLoader.getResultComponent()).setDataLoader(resultComponent.getDataLoader());
filterComponentLoader.loadComponent();
component.add((FilterComponent) filterComponentLoader.getResultComponent());
}
}
use of io.jmix.ui.component.FilterComponent in project jmix by jmix-framework.
the class FilterAddConditionAction method initDefaultSelectHandler.
protected void initDefaultSelectHandler() {
selectHandler = selectedConditions -> {
if (!selectedConditions.isEmpty()) {
Filter.Configuration currentConfiguration = filter.getCurrentConfiguration();
boolean dataLoadNeeded = false;
for (FilterCondition selectedCondition : selectedConditions) {
FilterConverter converter = filterComponents.getConverterByModelClass(selectedCondition.getClass(), filter);
FilterCondition parent = selectedCondition.getParent();
if (parent instanceof HeaderFilterCondition) {
selectedCondition.setParent(null);
}
FilterComponent filterComponent = converter.convertToComponent(selectedCondition);
currentConfiguration.getRootLogicalFilterComponent().add(filterComponent);
currentConfiguration.setFilterComponentModified(filterComponent, true);
boolean nonNullDefaultValue = setFilterComponentDefaultValue(filterComponent, currentConfiguration);
if (nonNullDefaultValue) {
dataLoadNeeded = true;
}
}
filter.setCurrentConfiguration(currentConfiguration);
if (dataLoadNeeded) {
filter.apply();
}
}
};
}
Aggregations