use of io.jmix.ui.entity.LogicalFilterCondition 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.LogicalFilterCondition 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();
}
}
}
use of io.jmix.ui.entity.LogicalFilterCondition 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.entity.LogicalFilterCondition in project jmix by jmix-framework.
the class FilterSaveAsAction method copyConfiguration.
@SuppressWarnings({ "rawtypes", "unchecked" })
protected Filter.Configuration copyConfiguration(String newId, Filter.Configuration existingConfiguration) {
LogicalFilterComponent rootLogicalFilterComponent = existingConfiguration.getRootLogicalFilterComponent();
FilterConverter converter = filterComponents.getConverterByComponentClass(rootLogicalFilterComponent.getClass(), filter);
Map<String, Object> valuesMap = filterSupport.initConfigurationValuesMap(existingConfiguration);
LogicalFilterCondition logicalFilterCondition = (LogicalFilterCondition) converter.convertToModel(rootLogicalFilterComponent);
filterSupport.resetConfigurationValuesMap(existingConfiguration, valuesMap);
LogicalFilterComponent logicalFilterComponent = (LogicalFilterComponent) converter.convertToComponent(logicalFilterCondition);
Filter.Configuration newConfiguration = new RunTimeConfiguration(newId, logicalFilterComponent, existingConfiguration.getOwner());
filterSupport.refreshConfigurationDefaultValues(newConfiguration);
filterSupport.resetConfigurationValuesMap(newConfiguration, valuesMap);
return newConfiguration;
}
use of io.jmix.ui.entity.LogicalFilterCondition 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;
}
Aggregations