Search in sources :

Example 1 with LogicalFilterComponent

use of io.jmix.ui.component.LogicalFilterComponent 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 LogicalFilterComponent

use of io.jmix.ui.component.LogicalFilterComponent 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 3 with LogicalFilterComponent

use of io.jmix.ui.component.LogicalFilterComponent 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 4 with LogicalFilterComponent

use of io.jmix.ui.component.LogicalFilterComponent in project jmix by jmix-framework.

the class FilterSupport method initConfigurationValuesMap.

@SuppressWarnings({ "unchecked", "rawtypes" })
public Map<String, Object> initConfigurationValuesMap(Filter.Configuration configuration) {
    Map<String, Object> valuesMap = new HashMap<>();
    LogicalFilterComponent rootLogicalComponent = configuration.getRootLogicalFilterComponent();
    for (FilterComponent filterComponent : rootLogicalComponent.getFilterComponents()) {
        if (filterComponent instanceof SingleFilterComponent) {
            String parameterName = ((SingleFilterComponent<?>) filterComponent).getParameterName();
            valuesMap.put(parameterName, ((SingleFilterComponent<?>) filterComponent).getValue());
            ((SingleFilterComponent) filterComponent).setValue(configuration.getFilterComponentDefaultValue(parameterName));
        }
    }
    return valuesMap;
}
Also used : HashMap(java.util.HashMap) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent) FilterComponent(io.jmix.ui.component.FilterComponent) SingleFilterComponent(io.jmix.ui.component.SingleFilterComponent) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent) SingleFilterComponent(io.jmix.ui.component.SingleFilterComponent)

Example 5 with LogicalFilterComponent

use of io.jmix.ui.component.LogicalFilterComponent in project jmix by jmix-framework.

the class FilterSupport method refreshConfigurationDefaultValues.

public void refreshConfigurationDefaultValues(Filter.Configuration configuration) {
    configuration.resetAllDefaultValues();
    LogicalFilterComponent rootLogicalComponent = configuration.getRootLogicalFilterComponent();
    for (FilterComponent filterComponent : rootLogicalComponent.getFilterComponents()) {
        if (filterComponent instanceof SingleFilterComponent) {
            configuration.setFilterComponentDefaultValue(((SingleFilterComponent<?>) filterComponent).getParameterName(), ((SingleFilterComponent<?>) filterComponent).getValue());
        }
    }
}
Also used : LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent) FilterComponent(io.jmix.ui.component.FilterComponent) SingleFilterComponent(io.jmix.ui.component.SingleFilterComponent) LogicalFilterComponent(io.jmix.ui.component.LogicalFilterComponent) SingleFilterComponent(io.jmix.ui.component.SingleFilterComponent)

Aggregations

LogicalFilterComponent (io.jmix.ui.component.LogicalFilterComponent)10 FilterConverter (io.jmix.ui.component.filter.converter.FilterConverter)6 Filter (io.jmix.ui.component.Filter)5 FilterComponent (io.jmix.ui.component.FilterComponent)4 SingleFilterComponent (io.jmix.ui.component.SingleFilterComponent)4 LogicalFilterCondition (io.jmix.ui.entity.LogicalFilterCondition)4 RunTimeConfiguration (io.jmix.ui.component.filter.configuration.RunTimeConfiguration)2 FilterCondition (io.jmix.ui.entity.FilterCondition)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 HeaderFilterCondition (io.jmix.ui.entity.HeaderFilterCondition)1 Screen (io.jmix.ui.screen.Screen)1 ScreenFragment (io.jmix.ui.screen.ScreenFragment)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1