Search in sources :

Example 11 with FilterCondition

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

the class GroupFilterConverter method convertToComponent.

@Override
public GroupFilter convertToComponent(GroupFilterCondition model) {
    GroupFilter groupFilter = super.convertToComponent(model);
    groupFilter.setOperation(model.getOperation());
    groupFilter.setCaption(model.getCaption());
    groupFilter.setOperationCaptionVisible(model.getOperationCaptionVisible());
    if (model.getOwnFilterConditions() != null) {
        for (FilterCondition ownFilterCondition : model.getOwnFilterConditions()) {
            FilterConverter ownFilterConverter = filterComponents.getConverterByModelClass(ownFilterCondition.getClass(), filter);
            groupFilter.add(ownFilterConverter.convertToComponent(ownFilterCondition));
        }
    }
    return groupFilter;
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) GroupFilterCondition(io.jmix.ui.entity.GroupFilterCondition) GroupFilter(io.jmix.ui.component.GroupFilter) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter)

Example 12 with FilterCondition

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

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

the class AddConditionScreen method findConditionsRecursively.

protected void findConditionsRecursively(List<FilterCondition> conditions, String searchValue, boolean addChildrenAutomatically) {
    for (FilterCondition condition : conditions) {
        boolean conditionFound = addChildrenAutomatically || StringUtils.containsIgnoreCase(condition.getLocalizedCaption(), searchValue);
        if (conditionFound) {
            foundConditions.add(condition);
        }
        List<FilterCondition> children = searchChildren(condition);
        if (!children.isEmpty()) {
            findConditionsRecursively(children, searchValue, conditionFound);
        }
    }
}
Also used : AbstractSingleFilterCondition(io.jmix.ui.entity.AbstractSingleFilterCondition) FilterCondition(io.jmix.ui.entity.FilterCondition) JpqlFilterCondition(io.jmix.ui.entity.JpqlFilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition)

Example 14 with FilterCondition

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

the class AddConditionScreen method onEditScreenAfterCommit.

protected void onEditScreenAfterCommit(AfterCloseEvent afterCloseEvent) {
    if (afterCloseEvent.closedWith(StandardOutcome.COMMIT)) {
        FilterCondition filterCondition = (FilterCondition) ((FilterConditionEdit) afterCloseEvent.getSource()).getInstanceContainer().getItem();
        select(Lists.newArrayList(filterCondition));
    }
}
Also used : AbstractSingleFilterCondition(io.jmix.ui.entity.AbstractSingleFilterCondition) FilterCondition(io.jmix.ui.entity.FilterCondition) JpqlFilterCondition(io.jmix.ui.entity.JpqlFilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition)

Example 15 with FilterCondition

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

the class GroupFilterConditionEdit method onConditionsTreeMoveUp.

@Subscribe("conditionsTree.moveUp")
protected void onConditionsTreeMoveUp(Action.ActionPerformedEvent event) {
    FilterCondition selectedCondition = conditionsTree.getSingleSelected();
    if (selectedCondition != null) {
        FilterCondition parent = selectedCondition.getParent();
        if (parent instanceof LogicalFilterCondition) {
            List<FilterCondition> items = getCollectionContainer().getMutableItems();
            List<FilterCondition> ownConditions = ((LogicalFilterCondition) parent).getOwnFilterConditions();
            int selectedItemIndex = items.indexOf(selectedCondition);
            int selectedOwnItemIndex = ownConditions.indexOf(selectedCondition);
            FilterCondition replacedCondition = ownConditions.get(selectedOwnItemIndex - 1);
            Collections.swap(items, selectedItemIndex, items.indexOf(replacedCondition));
            Collections.swap(ownConditions, selectedOwnItemIndex, selectedOwnItemIndex - 1);
            refreshMoveButtonsState(selectedCondition);
        }
    }
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) GroupFilterCondition(io.jmix.ui.entity.GroupFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) Subscribe(io.jmix.ui.screen.Subscribe)

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