Search in sources :

Example 1 with HeaderFilterCondition

use of io.jmix.ui.entity.HeaderFilterCondition in project jmix by jmix-framework.

the class FilterAddConditionAction method initDefaultSelectValidator.

protected void initDefaultSelectValidator() {
    selectValidator = context -> {
        for (FilterCondition selectedCondition : context.getSelectedItems()) {
            if (selectedCondition instanceof HeaderFilterCondition) {
                String caption = String.format(messages.getMessage(FilterAddConditionAction.class, "addConditionAction.invalidCondition"), selectedCondition.getLocalizedCaption());
                notifications.create(Notifications.NotificationType.WARNING).withCaption(caption).show();
                return false;
            }
        }
        return true;
    };
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition)

Example 2 with HeaderFilterCondition

use of io.jmix.ui.entity.HeaderFilterCondition in project jmix by jmix-framework.

the class AbstractConditionBuilder method createHeaderFilterCondition.

protected HeaderFilterCondition createHeaderFilterCondition(String caption) {
    HeaderFilterCondition headerFilterCondition = metadata.create(HeaderFilterCondition.class);
    headerFilterCondition.setLocalizedCaption(caption);
    return headerFilterCondition;
}
Also used : HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition)

Example 3 with HeaderFilterCondition

use of io.jmix.ui.entity.HeaderFilterCondition in project jmix by jmix-framework.

the class PredefinedConditionBuilder method createFilterConditions.

protected List<FilterCondition> createFilterConditions(Filter filter) {
    List<FilterComponent> components = filter.getConditions();
    List<FilterCondition> conditions = new ArrayList<>();
    HeaderFilterCondition conditionsHeaderCondition = createHeaderFilterCondition(messages.getMessage(PredefinedConditionBuilder.class, "predefinedConditionBuilder.headerCaption"));
    conditions.add(conditionsHeaderCondition);
    for (FilterComponent component : components) {
        FilterConverter converter = filterComponents.getConverterByComponentClass(component.getClass(), filter);
        FilterCondition condition = converter.convertToModel(component);
        condition.setParent(conditionsHeaderCondition);
        conditions.add(condition);
        if (condition instanceof LogicalFilterCondition) {
            List<FilterCondition> children = createFilterConditionsByLogicalFilterCondition((LogicalFilterCondition) condition, condition, true);
            conditions.addAll(children);
        }
    }
    return conditions;
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) ArrayList(java.util.ArrayList) FilterComponent(io.jmix.ui.component.FilterComponent) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter)

Example 4 with HeaderFilterCondition

use of io.jmix.ui.entity.HeaderFilterCondition 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)

Example 5 with HeaderFilterCondition

use of io.jmix.ui.entity.HeaderFilterCondition in project jmix by jmix-framework.

the class ConfigurationConditionBuilder method createFilterConditionsByConfigurations.

protected List<FilterCondition> createFilterConditionsByConfigurations(List<Filter.Configuration> configurations) {
    List<FilterCondition> conditions = new ArrayList<>();
    HeaderFilterCondition configurationsHeaderCondition = createHeaderFilterCondition(messages.getMessage(ConfigurationConditionBuilder.class, "configurationConditionBuilder.headerCaption"));
    conditions.add(configurationsHeaderCondition);
    for (Filter.Configuration configuration : configurations) {
        conditions.addAll(createFilterConditionsByConfiguration(configuration, configurationsHeaderCondition, true));
    }
    return conditions;
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) Filter(io.jmix.ui.component.Filter) ArrayList(java.util.ArrayList) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition)

Aggregations

HeaderFilterCondition (io.jmix.ui.entity.HeaderFilterCondition)6 FilterCondition (io.jmix.ui.entity.FilterCondition)5 ArrayList (java.util.ArrayList)3 Filter (io.jmix.ui.component.Filter)2 FilterComponent (io.jmix.ui.component.FilterComponent)2 FilterConverter (io.jmix.ui.component.filter.converter.FilterConverter)2 LogicalFilterCondition (io.jmix.ui.entity.LogicalFilterCondition)2 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 LogicalFilterComponent (io.jmix.ui.component.LogicalFilterComponent)1 SingleFilterComponent (io.jmix.ui.component.SingleFilterComponent)1 PropertyFilterCondition (io.jmix.ui.entity.PropertyFilterCondition)1