Search in sources :

Example 1 with FilterCondition

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

the class FilterCopyAction method copyConfiguration.

@SuppressWarnings({ "unchecked", "rawtypes" })
public void copyConfiguration(Filter.Configuration sourceConfiguration, Filter.Configuration destConfiguration) {
    destConfiguration.getRootLogicalFilterComponent().removeAll();
    Map<String, Object> valuesMap = filterSupport.initConfigurationValuesMap(sourceConfiguration);
    LogicalFilterComponent sourceRootComponent = sourceConfiguration.getRootLogicalFilterComponent();
    FilterConverter converter = filterComponents.getConverterByComponentClass(sourceRootComponent.getClass(), filter);
    FilterCondition filterCondition = converter.convertToModel(sourceRootComponent);
    filterSupport.resetConfigurationValuesMap(sourceConfiguration, valuesMap);
    LogicalFilterComponent copy = (LogicalFilterComponent) converter.convertToComponent(filterCondition);
    destConfiguration.setRootLogicalFilterComponent(copy);
    filterSupport.refreshConfigurationDefaultValues(destConfiguration);
    filterSupport.resetConfigurationValuesMap(destConfiguration, valuesMap);
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent)

Example 2 with FilterCondition

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

the class AddConditionScreen method search.

protected void search(@Nullable String searchValue) {
    foundConditions.clear();
    boolean loadAllConditions = StringUtils.isEmpty(searchValue) || rootConditions == null;
    if (!loadAllConditions) {
        findConditionsRecursively(rootConditions, searchValue, false);
        List<FilterCondition> exactlyFoundConditions = new ArrayList<>(foundConditions);
        for (FilterCondition condition : exactlyFoundConditions) {
            addParentToExpand(condition);
        }
        filterConditionsTree.expandTree();
    } else {
        foundConditions = new ArrayList<>(conditions);
    }
    filterConditionsDl.load();
    if (loadAllConditions) {
        initFilterConditionsTree();
    }
}
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) ArrayList(java.util.ArrayList)

Example 3 with FilterCondition

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

the class AddConditionScreen method createFilterCondition.

protected FilterCondition createFilterCondition(Class<? extends FilterCondition> modelClass) {
    FilterCondition newCondition = metadata.create(modelClass);
    if (newCondition instanceof AbstractSingleFilterCondition) {
        FilterValueComponent filterValueComponent = metadata.create(FilterValueComponent.class);
        ((AbstractSingleFilterCondition) newCondition).setValueComponent(filterValueComponent);
    }
    return newCondition;
}
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) AbstractSingleFilterCondition(io.jmix.ui.entity.AbstractSingleFilterCondition) FilterValueComponent(io.jmix.ui.entity.FilterValueComponent)

Example 4 with FilterCondition

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

the class LogicalFilterConditionEdit method afterActionPerformedHandler.

protected void afterActionPerformedHandler(RemoveOperation.AfterActionPerformedEvent<FilterCondition> event) {
    event.getItems().forEach(filterCondition -> {
        FilterCondition removedCondition = logicalFilterSupport.findSelectedConditionFromRootFilterCondition(getEditedEntity(), filterCondition);
        if (removedCondition != null) {
            FilterCondition parent = removedCondition.getParent();
            if (parent instanceof LogicalFilterCondition) {
                ((LogicalFilterCondition) parent).getOwnFilterConditions().remove(filterCondition);
            }
            removedCondition.setParent(null);
        }
    });
    refreshChildrenConditions();
}
Also used : FilterCondition(io.jmix.ui.entity.FilterCondition) PropertyFilterCondition(io.jmix.ui.entity.PropertyFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition)

Example 5 with FilterCondition

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

the class LogicalFilterConditionEdit method editActionAfterCloseHandler.

protected void editActionAfterCloseHandler(AfterCloseEvent afterCloseEvent) {
    Screen screen = afterCloseEvent.getSource();
    if (afterCloseEvent.closedWith(StandardOutcome.COMMIT) && screen instanceof EditorScreen && getListComponent() != null) {
        FilterCondition singleSelected = logicalFilterSupport.findSelectedConditionFromRootFilterCondition(getEditedEntity(), getListComponent().getSingleSelected());
        if (singleSelected != null && singleSelected.getParent() instanceof LogicalFilterCondition) {
            LogicalFilterCondition parent = (LogicalFilterCondition) singleSelected.getParent();
            int index = parent.getOwnFilterConditions().indexOf(singleSelected);
            FilterCondition editedCondition = (FilterCondition) ((EditorScreen<?>) screen).getEditedEntity();
            parent.getOwnFilterConditions().set(index, editedCondition);
            editedCondition.setParent(parent);
            refreshChildrenConditions();
            expandItems();
        }
    }
}
Also used : EditorScreen(io.jmix.ui.screen.EditorScreen) FilterCondition(io.jmix.ui.entity.FilterCondition) PropertyFilterCondition(io.jmix.ui.entity.PropertyFilterCondition) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition)

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