use of io.jmix.ui.component.Filter 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;
}
use of io.jmix.ui.component.Filter 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.component.Filter in project jmix by jmix-framework.
the class UiDataFilterSupport method getConfigurationsMap.
@Override
public Map<Filter.Configuration, Boolean> getConfigurationsMap(Filter filter) {
Map<Filter.Configuration, Boolean> map = new TreeMap<>();
List<FilterConfiguration> configurationModels = loadFilterConfigurationModels(filter);
for (FilterConfiguration configurationModel : configurationModels) {
Filter.Configuration configuration = filterConfigurationConverter.toConfiguration(configurationModel, filter);
map.put(configuration, configurationModel.getDefaultForAll());
}
return map;
}
use of io.jmix.ui.component.Filter 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.component.Filter in project jmix by jmix-framework.
the class FilterConfigurationConverter method toConfigurationModel.
public FilterConfiguration toConfigurationModel(Filter.Configuration configuration, FilterConfiguration configurationModel) {
Filter filter = configuration.getOwner();
String filterComponentId = generateFilterPath(filter);
configurationModel.setComponentId(filterComponentId);
LogicalFilterComponent rootLogicalFilterComponent = configuration.getRootLogicalFilterComponent();
FilterConverter converter = filterComponents.getConverterByComponentClass(rootLogicalFilterComponent.getClass(), configuration.getOwner());
configurationModel.setRootCondition((GroupFilterCondition) converter.convertToModel(rootLogicalFilterComponent));
return configurationModel;
}
Aggregations