Search in sources :

Example 6 with FilterCondition

use of io.jmix.ui.entity.FilterCondition 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 7 with FilterCondition

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

the class FilterAddConditionAction method openAddConditionScreen.

protected void openAddConditionScreen(List<FilterCondition> filterConditions) {
    if (filter.getFrame() == null) {
        throw new IllegalStateException("Filter component is not attached to the Frame");
    }
    AddConditionScreen addConditionScreen = screenBuilders.lookup(FilterCondition.class, filter.getFrame().getFrameOwner()).withOpenMode(OpenMode.DIALOG).withScreenClass(AddConditionScreen.class).withSelectValidator(selectValidator).withSelectHandler(selectHandler).build();
    addConditionScreen.setConditions(filterConditions);
    addConditionScreen.setCurrentFilterConfiguration(filter.getCurrentConfiguration());
    addConditionScreen.show();
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) AddConditionScreen(io.jmix.ui.app.filter.condition.AddConditionScreen)

Example 8 with FilterCondition

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

the class PredefinedConditionBuilder method createFilterConditionsByLogicalFilterCondition.

public List<FilterCondition> createFilterConditionsByLogicalFilterCondition(LogicalFilterCondition logicalFilterCondition, FilterCondition parent, boolean isRootGroupFilterComponent) {
    List<FilterCondition> conditions = new ArrayList<>();
    if (!isRootGroupFilterComponent) {
        logicalFilterCondition.setParent(parent);
        conditions.add(logicalFilterCondition);
    }
    if (logicalFilterCondition.getOwnFilterConditions() != null) {
        for (FilterCondition ownFilterCondition : logicalFilterCondition.getOwnFilterConditions()) {
            FilterCondition parentCondition = isRootGroupFilterComponent ? parent : logicalFilterCondition;
            if (ownFilterCondition instanceof LogicalFilterCondition) {
                List<FilterCondition> children = createFilterConditionsByLogicalFilterCondition((LogicalFilterCondition) ownFilterCondition, parentCondition, false);
                conditions.addAll(children);
            } else {
                ownFilterCondition.setParent(parentCondition);
                conditions.add(ownFilterCondition);
            }
        }
    }
    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)

Example 9 with FilterCondition

use of io.jmix.ui.entity.FilterCondition 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 10 with FilterCondition

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

Aggregations

FilterCondition (io.jmix.ui.entity.FilterCondition)25 HeaderFilterCondition (io.jmix.ui.entity.HeaderFilterCondition)14 LogicalFilterCondition (io.jmix.ui.entity.LogicalFilterCondition)13 ArrayList (java.util.ArrayList)8 FilterConverter (io.jmix.ui.component.filter.converter.FilterConverter)6 GroupFilterCondition (io.jmix.ui.entity.GroupFilterCondition)6 PropertyFilterCondition (io.jmix.ui.entity.PropertyFilterCondition)6 AbstractSingleFilterCondition (io.jmix.ui.entity.AbstractSingleFilterCondition)4 JpqlFilterCondition (io.jmix.ui.entity.JpqlFilterCondition)4 FilterComponent (io.jmix.ui.component.FilterComponent)3 LogicalFilterComponent (io.jmix.ui.component.LogicalFilterComponent)3 Subscribe (io.jmix.ui.screen.Subscribe)3 Filter (io.jmix.ui.component.Filter)2 FilterValueComponent (io.jmix.ui.entity.FilterValueComponent)2 MetaClass (io.jmix.core.metamodel.model.MetaClass)1 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 AddConditionScreen (io.jmix.ui.app.filter.condition.AddConditionScreen)1 GroupFilter (io.jmix.ui.component.GroupFilter)1 HasValue (io.jmix.ui.component.HasValue)1 PropertyFilter (io.jmix.ui.component.PropertyFilter)1