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