use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.
the class GroupFilterConverter method convertToComponent.
@Override
public GroupFilter convertToComponent(GroupFilterCondition model) {
GroupFilter groupFilter = super.convertToComponent(model);
groupFilter.setOperation(model.getOperation());
groupFilter.setCaption(model.getCaption());
groupFilter.setOperationCaptionVisible(model.getOperationCaptionVisible());
if (model.getOwnFilterConditions() != null) {
for (FilterCondition ownFilterCondition : model.getOwnFilterConditions()) {
FilterConverter ownFilterConverter = filterComponents.getConverterByModelClass(ownFilterCondition.getClass(), filter);
groupFilter.add(ownFilterConverter.convertToComponent(ownFilterCondition));
}
}
return groupFilter;
}
use of io.jmix.ui.entity.FilterCondition 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.FilterCondition in project jmix by jmix-framework.
the class AddConditionScreen method findConditionsRecursively.
protected void findConditionsRecursively(List<FilterCondition> conditions, String searchValue, boolean addChildrenAutomatically) {
for (FilterCondition condition : conditions) {
boolean conditionFound = addChildrenAutomatically || StringUtils.containsIgnoreCase(condition.getLocalizedCaption(), searchValue);
if (conditionFound) {
foundConditions.add(condition);
}
List<FilterCondition> children = searchChildren(condition);
if (!children.isEmpty()) {
findConditionsRecursively(children, searchValue, conditionFound);
}
}
}
use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.
the class AddConditionScreen method onEditScreenAfterCommit.
protected void onEditScreenAfterCommit(AfterCloseEvent afterCloseEvent) {
if (afterCloseEvent.closedWith(StandardOutcome.COMMIT)) {
FilterCondition filterCondition = (FilterCondition) ((FilterConditionEdit) afterCloseEvent.getSource()).getInstanceContainer().getItem();
select(Lists.newArrayList(filterCondition));
}
}
use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.
the class GroupFilterConditionEdit method onConditionsTreeMoveUp.
@Subscribe("conditionsTree.moveUp")
protected void onConditionsTreeMoveUp(Action.ActionPerformedEvent event) {
FilterCondition selectedCondition = conditionsTree.getSingleSelected();
if (selectedCondition != null) {
FilterCondition parent = selectedCondition.getParent();
if (parent instanceof LogicalFilterCondition) {
List<FilterCondition> items = getCollectionContainer().getMutableItems();
List<FilterCondition> ownConditions = ((LogicalFilterCondition) parent).getOwnFilterConditions();
int selectedItemIndex = items.indexOf(selectedCondition);
int selectedOwnItemIndex = ownConditions.indexOf(selectedCondition);
FilterCondition replacedCondition = ownConditions.get(selectedOwnItemIndex - 1);
Collections.swap(items, selectedItemIndex, items.indexOf(replacedCondition));
Collections.swap(ownConditions, selectedOwnItemIndex, selectedOwnItemIndex - 1);
refreshMoveButtonsState(selectedCondition);
}
}
}
Aggregations