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);
}
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;
}
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;
}
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;
}
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());
}
}
}
Aggregations