Search in sources :

Example 1 with LogicalFilterCondition

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

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

Example 3 with LogicalFilterCondition

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

the class FilterConfigurationConverter method toConfiguration.

public Filter.Configuration toConfiguration(FilterConfiguration configurationModel, Filter filter) {
    String id = configurationModel.getConfigurationId();
    LogicalFilterCondition rootCondition = configurationModel.getRootCondition();
    FilterConverter converter = filterComponents.getConverterByModelClass(rootCondition.getClass(), filter);
    LogicalFilterComponent logicalFilterComponent = (LogicalFilterComponent) converter.convertToComponent(rootCondition);
    Filter.Configuration configuration = new RunTimeConfiguration(id, logicalFilterComponent, filter);
    configuration.setName(configurationModel.getName());
    for (FilterComponent filterComponent : logicalFilterComponent.getFilterComponents()) {
        if (filterComponent instanceof SingleFilterComponent) {
            configuration.setFilterComponentDefaultValue(((SingleFilterComponent<?>) filterComponent).getParameterName(), ((SingleFilterComponent<?>) filterComponent).getValue());
        }
    }
    return configuration;
}
Also used : Filter(io.jmix.ui.component.Filter) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) SingleFilterComponent(io.jmix.ui.component.SingleFilterComponent) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent) FilterComponent(io.jmix.ui.component.FilterComponent) RunTimeConfiguration(io.jmix.ui.component.filter.configuration.RunTimeConfiguration) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent) SingleFilterComponent(io.jmix.ui.component.SingleFilterComponent)

Example 4 with LogicalFilterCondition

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

the class FilterSaveAsAction method copyConfiguration.

@SuppressWarnings({ "rawtypes", "unchecked" })
protected Filter.Configuration copyConfiguration(String newId, Filter.Configuration existingConfiguration) {
    LogicalFilterComponent rootLogicalFilterComponent = existingConfiguration.getRootLogicalFilterComponent();
    FilterConverter converter = filterComponents.getConverterByComponentClass(rootLogicalFilterComponent.getClass(), filter);
    Map<String, Object> valuesMap = filterSupport.initConfigurationValuesMap(existingConfiguration);
    LogicalFilterCondition logicalFilterCondition = (LogicalFilterCondition) converter.convertToModel(rootLogicalFilterComponent);
    filterSupport.resetConfigurationValuesMap(existingConfiguration, valuesMap);
    LogicalFilterComponent logicalFilterComponent = (LogicalFilterComponent) converter.convertToComponent(logicalFilterCondition);
    Filter.Configuration newConfiguration = new RunTimeConfiguration(newId, logicalFilterComponent, existingConfiguration.getOwner());
    filterSupport.refreshConfigurationDefaultValues(newConfiguration);
    filterSupport.resetConfigurationValuesMap(newConfiguration, valuesMap);
    return newConfiguration;
}
Also used : Filter(io.jmix.ui.component.Filter) LogicalFilterCondition(io.jmix.ui.entity.LogicalFilterCondition) RunTimeConfiguration(io.jmix.ui.component.filter.configuration.RunTimeConfiguration) FilterConverter(io.jmix.ui.component.filter.converter.FilterConverter) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent)

Example 5 with LogicalFilterCondition

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

Aggregations

LogicalFilterCondition (io.jmix.ui.entity.LogicalFilterCondition)13 FilterCondition (io.jmix.ui.entity.FilterCondition)10 FilterConverter (io.jmix.ui.component.filter.converter.FilterConverter)5 LogicalFilterComponent (io.jmix.ui.component.LogicalFilterComponent)4 HeaderFilterCondition (io.jmix.ui.entity.HeaderFilterCondition)4 ArrayList (java.util.ArrayList)4 Filter (io.jmix.ui.component.Filter)3 GroupFilterCondition (io.jmix.ui.entity.GroupFilterCondition)3 PropertyFilterCondition (io.jmix.ui.entity.PropertyFilterCondition)3 FilterComponent (io.jmix.ui.component.FilterComponent)2 RunTimeConfiguration (io.jmix.ui.component.filter.configuration.RunTimeConfiguration)2 Screen (io.jmix.ui.screen.Screen)2 Subscribe (io.jmix.ui.screen.Subscribe)2 FilterConditionEdit (io.jmix.ui.app.filter.condition.FilterConditionEdit)1 GroupFilterConditionEdit (io.jmix.ui.app.filter.condition.GroupFilterConditionEdit)1 Component (io.jmix.ui.component.Component)1 Fragment (io.jmix.ui.component.Fragment)1 SingleFilterComponent (io.jmix.ui.component.SingleFilterComponent)1 EditorScreen (io.jmix.ui.screen.EditorScreen)1 ScreenFragment (io.jmix.ui.screen.ScreenFragment)1