use of io.jmix.ui.entity.HeaderFilterCondition in project jmix by jmix-framework.
the class FilterAddConditionAction method initDefaultSelectValidator.
protected void initDefaultSelectValidator() {
selectValidator = context -> {
for (FilterCondition selectedCondition : context.getSelectedItems()) {
if (selectedCondition instanceof HeaderFilterCondition) {
String caption = String.format(messages.getMessage(FilterAddConditionAction.class, "addConditionAction.invalidCondition"), selectedCondition.getLocalizedCaption());
notifications.create(Notifications.NotificationType.WARNING).withCaption(caption).show();
return false;
}
}
return true;
};
}
use of io.jmix.ui.entity.HeaderFilterCondition in project jmix by jmix-framework.
the class AbstractConditionBuilder method createHeaderFilterCondition.
protected HeaderFilterCondition createHeaderFilterCondition(String caption) {
HeaderFilterCondition headerFilterCondition = metadata.create(HeaderFilterCondition.class);
headerFilterCondition.setLocalizedCaption(caption);
return headerFilterCondition;
}
use of io.jmix.ui.entity.HeaderFilterCondition 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;
}
use of io.jmix.ui.entity.HeaderFilterCondition in project jmix by jmix-framework.
the class FilterAddConditionAction method initDefaultSelectHandler.
protected void initDefaultSelectHandler() {
selectHandler = selectedConditions -> {
if (!selectedConditions.isEmpty()) {
Filter.Configuration currentConfiguration = filter.getCurrentConfiguration();
boolean dataLoadNeeded = false;
for (FilterCondition selectedCondition : selectedConditions) {
FilterConverter converter = filterComponents.getConverterByModelClass(selectedCondition.getClass(), filter);
FilterCondition parent = selectedCondition.getParent();
if (parent instanceof HeaderFilterCondition) {
selectedCondition.setParent(null);
}
FilterComponent filterComponent = converter.convertToComponent(selectedCondition);
currentConfiguration.getRootLogicalFilterComponent().add(filterComponent);
currentConfiguration.setFilterComponentModified(filterComponent, true);
boolean nonNullDefaultValue = setFilterComponentDefaultValue(filterComponent, currentConfiguration);
if (nonNullDefaultValue) {
dataLoadNeeded = true;
}
}
filter.setCurrentConfiguration(currentConfiguration);
if (dataLoadNeeded) {
filter.apply();
}
}
};
}
use of io.jmix.ui.entity.HeaderFilterCondition in project jmix by jmix-framework.
the class ConfigurationConditionBuilder method createFilterConditionsByConfigurations.
protected List<FilterCondition> createFilterConditionsByConfigurations(List<Filter.Configuration> configurations) {
List<FilterCondition> conditions = new ArrayList<>();
HeaderFilterCondition configurationsHeaderCondition = createHeaderFilterCondition(messages.getMessage(ConfigurationConditionBuilder.class, "configurationConditionBuilder.headerCaption"));
conditions.add(configurationsHeaderCondition);
for (Filter.Configuration configuration : configurations) {
conditions.addAll(createFilterConditionsByConfiguration(configuration, configurationsHeaderCondition, true));
}
return conditions;
}
Aggregations