Search in sources :

Example 1 with SingleFilterComponent

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

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

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

Example 4 with SingleFilterComponent

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

the class FilterSupport method refreshConfigurationValuesMap.

@SuppressWarnings({ "unchecked", "rawtypes" })
public void refreshConfigurationValuesMap(Filter.Configuration configuration, Map<String, Object> valuesMap) {
    LogicalFilterComponent rootLogicalComponent = configuration.getRootLogicalFilterComponent();
    for (FilterComponent filterComponent : rootLogicalComponent.getFilterComponents()) {
        if (filterComponent instanceof SingleFilterComponent) {
            String parameterName = ((SingleFilterComponent<?>) filterComponent).getParameterName();
            Object value = valuesMap.get(parameterName);
            Object defaultValue = configuration.getFilterComponentDefaultValue(parameterName);
            if (value == null && defaultValue != null) {
                ((SingleFilterComponent) filterComponent).setValue(defaultValue);
            } else {
                try {
                    ((SingleFilterComponent) filterComponent).setValue(value);
                } catch (ClassCastException e) {
                    ((SingleFilterComponent) filterComponent).setValue(defaultValue);
                }
            }
        }
    }
}
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

FilterComponent (io.jmix.ui.component.FilterComponent)4 LogicalFilterComponent (io.jmix.ui.component.LogicalFilterComponent)4 SingleFilterComponent (io.jmix.ui.component.SingleFilterComponent)4 Filter (io.jmix.ui.component.Filter)1 RunTimeConfiguration (io.jmix.ui.component.filter.configuration.RunTimeConfiguration)1 FilterConverter (io.jmix.ui.component.filter.converter.FilterConverter)1 LogicalFilterCondition (io.jmix.ui.entity.LogicalFilterCondition)1 HashMap (java.util.HashMap)1