use of io.jmix.ui.entity.FilterCondition 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.FilterCondition in project jmix by jmix-framework.
the class FilterAddConditionAction method openAddConditionScreen.
protected void openAddConditionScreen(List<FilterCondition> filterConditions) {
if (filter.getFrame() == null) {
throw new IllegalStateException("Filter component is not attached to the Frame");
}
AddConditionScreen addConditionScreen = screenBuilders.lookup(FilterCondition.class, filter.getFrame().getFrameOwner()).withOpenMode(OpenMode.DIALOG).withScreenClass(AddConditionScreen.class).withSelectValidator(selectValidator).withSelectHandler(selectHandler).build();
addConditionScreen.setConditions(filterConditions);
addConditionScreen.setCurrentFilterConfiguration(filter.getCurrentConfiguration());
addConditionScreen.show();
}
use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.
the class PredefinedConditionBuilder method createFilterConditionsByLogicalFilterCondition.
public List<FilterCondition> createFilterConditionsByLogicalFilterCondition(LogicalFilterCondition logicalFilterCondition, FilterCondition parent, boolean isRootGroupFilterComponent) {
List<FilterCondition> conditions = new ArrayList<>();
if (!isRootGroupFilterComponent) {
logicalFilterCondition.setParent(parent);
conditions.add(logicalFilterCondition);
}
if (logicalFilterCondition.getOwnFilterConditions() != null) {
for (FilterCondition ownFilterCondition : logicalFilterCondition.getOwnFilterConditions()) {
FilterCondition parentCondition = isRootGroupFilterComponent ? parent : logicalFilterCondition;
if (ownFilterCondition instanceof LogicalFilterCondition) {
List<FilterCondition> children = createFilterConditionsByLogicalFilterCondition((LogicalFilterCondition) ownFilterCondition, parentCondition, false);
conditions.addAll(children);
} else {
ownFilterCondition.setParent(parentCondition);
conditions.add(ownFilterCondition);
}
}
}
return conditions;
}
use of io.jmix.ui.entity.FilterCondition 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.FilterCondition in project jmix by jmix-framework.
the class GroupFilterConverter method convertToModel.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public GroupFilterCondition convertToModel(GroupFilter groupFilter) {
GroupFilterCondition groupFilterCondition = super.convertToModel(groupFilter);
groupFilterCondition.setOperation(groupFilter.getOperation());
groupFilterCondition.setCaption(groupFilter.getCaption());
groupFilterCondition.setLocalizedCaption(getLocalizedModelCaption(groupFilter));
groupFilterCondition.setOperationCaptionVisible(groupFilter.isOperationCaptionVisible());
List<FilterCondition> ownFilterConditions = new ArrayList<>();
for (FilterComponent ownFilterComponent : groupFilter.getOwnFilterComponents()) {
FilterConverter ownFilterConverter = filterComponents.getConverterByComponentClass(ownFilterComponent.getClass(), filter);
FilterCondition ownFilterCondition = ownFilterConverter.convertToModel(ownFilterComponent);
ownFilterCondition.setParent(groupFilterCondition);
ownFilterConditions.add(ownFilterCondition);
}
if (!ownFilterConditions.isEmpty()) {
groupFilterCondition.setOwnFilterConditions(ownFilterConditions);
}
return groupFilterCondition;
}
Aggregations