use of io.jmix.ui.component.FilterComponent 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.FilterComponent 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.FilterComponent 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.FilterComponent 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);
}
}
}
}
}
use of io.jmix.ui.component.FilterComponent in project jmix by jmix-framework.
the class PredefinedConditionBuilder method createFilterConditions.
protected List<FilterCondition> createFilterConditions(Filter filter) {
List<FilterComponent> components = filter.getConditions();
List<FilterCondition> conditions = new ArrayList<>();
HeaderFilterCondition conditionsHeaderCondition = createHeaderFilterCondition(messages.getMessage(PredefinedConditionBuilder.class, "predefinedConditionBuilder.headerCaption"));
conditions.add(conditionsHeaderCondition);
for (FilterComponent component : components) {
FilterConverter converter = filterComponents.getConverterByComponentClass(component.getClass(), filter);
FilterCondition condition = converter.convertToModel(component);
condition.setParent(conditionsHeaderCondition);
conditions.add(condition);
if (condition instanceof LogicalFilterCondition) {
List<FilterCondition> children = createFilterConditionsByLogicalFilterCondition((LogicalFilterCondition) condition, condition, true);
conditions.addAll(children);
}
}
return conditions;
}
Aggregations