use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.
the class FilterCopyAction method copyConfiguration.
@SuppressWarnings({ "unchecked", "rawtypes" })
public void copyConfiguration(Filter.Configuration sourceConfiguration, Filter.Configuration destConfiguration) {
destConfiguration.getRootLogicalFilterComponent().removeAll();
Map<String, Object> valuesMap = filterSupport.initConfigurationValuesMap(sourceConfiguration);
LogicalFilterComponent sourceRootComponent = sourceConfiguration.getRootLogicalFilterComponent();
FilterConverter converter = filterComponents.getConverterByComponentClass(sourceRootComponent.getClass(), filter);
FilterCondition filterCondition = converter.convertToModel(sourceRootComponent);
filterSupport.resetConfigurationValuesMap(sourceConfiguration, valuesMap);
LogicalFilterComponent copy = (LogicalFilterComponent) converter.convertToComponent(filterCondition);
destConfiguration.setRootLogicalFilterComponent(copy);
filterSupport.refreshConfigurationDefaultValues(destConfiguration);
filterSupport.resetConfigurationValuesMap(destConfiguration, valuesMap);
}
use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.
the class AddConditionScreen method search.
protected void search(@Nullable String searchValue) {
foundConditions.clear();
boolean loadAllConditions = StringUtils.isEmpty(searchValue) || rootConditions == null;
if (!loadAllConditions) {
findConditionsRecursively(rootConditions, searchValue, false);
List<FilterCondition> exactlyFoundConditions = new ArrayList<>(foundConditions);
for (FilterCondition condition : exactlyFoundConditions) {
addParentToExpand(condition);
}
filterConditionsTree.expandTree();
} else {
foundConditions = new ArrayList<>(conditions);
}
filterConditionsDl.load();
if (loadAllConditions) {
initFilterConditionsTree();
}
}
use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.
the class AddConditionScreen method createFilterCondition.
protected FilterCondition createFilterCondition(Class<? extends FilterCondition> modelClass) {
FilterCondition newCondition = metadata.create(modelClass);
if (newCondition instanceof AbstractSingleFilterCondition) {
FilterValueComponent filterValueComponent = metadata.create(FilterValueComponent.class);
((AbstractSingleFilterCondition) newCondition).setValueComponent(filterValueComponent);
}
return newCondition;
}
use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.
the class LogicalFilterConditionEdit method afterActionPerformedHandler.
protected void afterActionPerformedHandler(RemoveOperation.AfterActionPerformedEvent<FilterCondition> event) {
event.getItems().forEach(filterCondition -> {
FilterCondition removedCondition = logicalFilterSupport.findSelectedConditionFromRootFilterCondition(getEditedEntity(), filterCondition);
if (removedCondition != null) {
FilterCondition parent = removedCondition.getParent();
if (parent instanceof LogicalFilterCondition) {
((LogicalFilterCondition) parent).getOwnFilterConditions().remove(filterCondition);
}
removedCondition.setParent(null);
}
});
refreshChildrenConditions();
}
use of io.jmix.ui.entity.FilterCondition in project jmix by jmix-framework.
the class LogicalFilterConditionEdit method editActionAfterCloseHandler.
protected void editActionAfterCloseHandler(AfterCloseEvent afterCloseEvent) {
Screen screen = afterCloseEvent.getSource();
if (afterCloseEvent.closedWith(StandardOutcome.COMMIT) && screen instanceof EditorScreen && getListComponent() != null) {
FilterCondition singleSelected = logicalFilterSupport.findSelectedConditionFromRootFilterCondition(getEditedEntity(), getListComponent().getSingleSelected());
if (singleSelected != null && singleSelected.getParent() instanceof LogicalFilterCondition) {
LogicalFilterCondition parent = (LogicalFilterCondition) singleSelected.getParent();
int index = parent.getOwnFilterConditions().indexOf(singleSelected);
FilterCondition editedCondition = (FilterCondition) ((EditorScreen<?>) screen).getEditedEntity();
parent.getOwnFilterConditions().set(index, editedCondition);
editedCondition.setParent(parent);
refreshChildrenConditions();
expandItems();
}
}
}
Aggregations