Search in sources :

Example 6 with FilterComponent

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;
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) GroupFilterCondition(io.jmix.ui.entity.GroupFilterCondition) ArrayList(java.util.ArrayList) GroupFilterCondition(io.jmix.ui.entity.GroupFilterCondition) FilterComponent(io.jmix.ui.component.FilterComponent) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter)

Example 7 with FilterComponent

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());
    }
}
Also used : Element(org.dom4j.Element) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent) FilterComponent(io.jmix.ui.component.FilterComponent)

Example 8 with FilterComponent

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();
            }
        }
    };
}
Also used : Filter(io.jmix.ui.component.Filter) FilterCondition(io.jmix.ui.entity.FilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent) FilterComponent(io.jmix.ui.component.FilterComponent) SingleFilterComponent(io.jmix.ui.component.SingleFilterComponent) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition)

Aggregations

FilterComponent (io.jmix.ui.component.FilterComponent)8 LogicalFilterComponent (io.jmix.ui.component.LogicalFilterComponent)6 SingleFilterComponent (io.jmix.ui.component.SingleFilterComponent)5 FilterConverter (io.jmix.ui.component.filter.converter.FilterConverter)4 FilterCondition (io.jmix.ui.entity.FilterCondition)3 Filter (io.jmix.ui.component.Filter)2 HeaderFilterCondition (io.jmix.ui.entity.HeaderFilterCondition)2 LogicalFilterCondition (io.jmix.ui.entity.LogicalFilterCondition)2 ArrayList (java.util.ArrayList)2 RunTimeConfiguration (io.jmix.ui.component.filter.configuration.RunTimeConfiguration)1 GroupFilterCondition (io.jmix.ui.entity.GroupFilterCondition)1 HashMap (java.util.HashMap)1 Element (org.dom4j.Element)1