use of io.jmix.ui.component.filter.configuration.DesignTimeConfiguration in project jmix by jmix-framework.
the class FilterImpl method addConfiguration.
@Override
public DesignTimeConfiguration addConfiguration(String id, @Nullable String name, LogicalFilterComponent.Operation rootOperation) {
LogicalFilterComponent rootComponent = createConfigurationRootLogicalFilterComponent(rootOperation);
DesignTimeConfiguration newConfiguration = new DesignTimeConfiguration(id, name, rootComponent, this);
addConfiguration(newConfiguration);
return newConfiguration;
}
use of io.jmix.ui.component.filter.configuration.DesignTimeConfiguration in project jmix by jmix-framework.
the class RelatedEntitiesSupportImpl method buildScreen.
protected Screen buildScreen(RelatedEntitiesBuilder builder) {
MetaClass metaClass = getMetaClass(builder);
MetaProperty metaProperty = getMetaProperty(builder, metaClass);
Screen screen = createScreen(builder, metaClass, metaProperty);
boolean found = ComponentsHelper.walkComponents(screen.getWindow(), screenComponent -> {
if (screenComponent instanceof Filter) {
Filter filter = (Filter) screenComponent;
DataLoader dataLoader = filter.getDataLoader();
MetaClass actualMetaClass = dataLoader.getContainer().getEntityMetaClass();
MetaClass relatedMetaClass = metaProperty.getRange().asClass();
MetaClass effectiveMetaClass = extendedEntities.getEffectiveMetaClass(relatedMetaClass);
if (Objects.equals(actualMetaClass, effectiveMetaClass)) {
Collection selectedEntities = builder.getSelectedEntities() == null ? Collections.emptyList() : builder.getSelectedEntities();
String configurationName = generateConfigurationName(builder, metaProperty);
DesignTimeConfiguration configuration = createFilterConfiguration((Filter) screenComponent, configurationName);
JpqlFilter jpqlFilter = createJpqlFilter(filter.getDataLoader(), metaProperty, metaClass, selectedEntities);
configuration.getRootLogicalFilterComponent().add(jpqlFilter);
configuration.setFilterComponentDefaultValue(jpqlFilter.getParameterName(), jpqlFilter.getValue());
filter.setCurrentConfiguration(configuration);
return true;
}
}
return false;
});
if (!found) {
screen.addAfterShowListener(event -> {
ScreenContext screenContext = UiControllerUtils.getScreenContext(event.getSource());
screenContext.getNotifications().create(Notifications.NotificationType.WARNING).withCaption(messages.getMessage("actions.Related.FilterNotFound")).show();
});
}
return screen;
}
Aggregations