Search in sources :

Example 1 with RunTimeConfiguration

use of io.jmix.ui.component.filter.configuration.RunTimeConfiguration 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 RunTimeConfiguration

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

use of io.jmix.ui.component.filter.configuration.RunTimeConfiguration in project jmix by jmix-framework.

the class FilterSupport method initFilterConfiguration.

protected Filter.Configuration initFilterConfiguration(String id, String name, Filter.Configuration existedConfiguration, boolean isNewConfiguration, LogicalFilterComponent rootFilterComponent) {
    Filter.Configuration resultConfiguration;
    if (isNewConfiguration) {
        resultConfiguration = new RunTimeConfiguration(id, rootFilterComponent, existedConfiguration.getOwner());
    } else if (!existedConfiguration.getId().equals(id)) {
        Filter owner = existedConfiguration.getOwner();
        resultConfiguration = new RunTimeConfiguration(id, rootFilterComponent, owner);
        owner.removeConfiguration(existedConfiguration);
    } else {
        resultConfiguration = existedConfiguration;
        resultConfiguration.setRootLogicalFilterComponent(rootFilterComponent);
    }
    resultConfiguration.setName(name);
    return resultConfiguration;
}
Also used : Filter(io.jmix.ui.component.Filter) RunTimeConfiguration(io.jmix.ui.component.filter.configuration.RunTimeConfiguration)

Example 4 with RunTimeConfiguration

use of io.jmix.ui.component.filter.configuration.RunTimeConfiguration in project jmix by jmix-framework.

the class FilterImpl method initEmptyConfiguration.

protected void initEmptyConfiguration() {
    LogicalFilterComponent configurationLogicalComponent = createConfigurationRootLogicalFilterComponent(LogicalFilterComponent.Operation.AND);
    emptyConfiguration = new RunTimeConfiguration("empty_configuration", configurationLogicalComponent, this);
    String emptyConfigurationName = StringUtils.isNotEmpty(getCaption()) ? getCaption() : messages.getMessage("filter.emptyConfiguration.name");
    emptyConfiguration.setName(emptyConfigurationName);
    setCurrentConfiguration(emptyConfiguration);
}
Also used : RunTimeConfiguration(io.jmix.ui.component.filter.configuration.RunTimeConfiguration)

Aggregations

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