Search in sources :

Example 1 with PropertyFilterCondition

use of io.jmix.ui.entity.PropertyFilterCondition in project jmix by jmix-framework.

the class LogicalFilterConditionEdit method updatePropertyConditionLocalizedCaption.

protected void updatePropertyConditionLocalizedCaption(FilterCondition condition) {
    if (condition instanceof PropertyFilterCondition && Strings.isNullOrEmpty(condition.getCaption())) {
        PropertyFilterCondition propertyFilterCondition = (PropertyFilterCondition) condition;
        MetaClass metaClass = currentConfiguration.getOwner().getDataLoader().getContainer().getEntityMetaClass();
        String property = propertyFilterCondition.getProperty();
        PropertyFilter.Operation operation = propertyFilterCondition.getOperation();
        boolean operationCaptionVisible = propertyFilterCondition.getOperationCaptionVisible() && !propertyFilterCondition.getOperationEditable();
        String localizedCaption = propertyFilterSupport.getPropertyFilterCaption(metaClass, property, operation, operationCaptionVisible);
        propertyFilterCondition.setLocalizedCaption(localizedCaption);
    }
}
Also used : PropertyFilterCondition(io.jmix.ui.entity.PropertyFilterCondition) MetaClass(io.jmix.core.metamodel.model.MetaClass) PropertyFilter(io.jmix.ui.component.PropertyFilter)

Example 2 with PropertyFilterCondition

use of io.jmix.ui.entity.PropertyFilterCondition in project jmix by jmix-framework.

the class PropertyConditionBuilder method createFilterConditionByPath.

protected FilterCondition createFilterConditionByPath(MetaPropertyPath metaPropertyPath) {
    Class modelClass = filterComponents.getModelClass(PropertyFilter.class);
    FilterCondition filterCondition = (FilterCondition) metadata.create(modelClass);
    MetaClass metaClass = metaPropertyPath.getMetaClass();
    if (PropertyFilterCondition.class.isAssignableFrom(modelClass)) {
        String property = metaPropertyPath.toPathString();
        ((PropertyFilterCondition) filterCondition).setProperty(property);
        ((PropertyFilterCondition) filterCondition).setParameterName(PropertyConditionUtils.generateParameterName(property));
        ((PropertyFilterCondition) filterCondition).setCaptionPosition(SupportsCaptionPosition.CaptionPosition.LEFT);
        String localizedCaption = messageTools.getPropertyCaption(metaClass, property);
        filterCondition.setLocalizedCaption(localizedCaption);
        String propertyFilterPrefix = propertyFilterSupport.getPropertyFilterPrefix(null, property);
        filterCondition.setComponentId(propertyFilterPrefix.substring(0, propertyFilterPrefix.length() - 1));
        PropertyFilter.Operation operation = propertyFilterSupport.getDefaultOperation(metaClass, property);
        ((PropertyFilterCondition) filterCondition).setOperation(operation);
        FilterValueComponent modelValueComponent = metadata.create(FilterValueComponent.class);
        HasValue valueComponent = singleFilterSupport.generateValueComponent(metaClass, property, operation);
        modelValueComponent.setComponentId(valueComponent.getId());
        modelValueComponent.setComponentName(singleFilterSupport.getValueComponentName(valueComponent));
        ((PropertyFilterCondition) filterCondition).setValueComponent(modelValueComponent);
    }
    return filterCondition;
}
Also used : PropertyFilterCondition(io.jmix.ui.entity.PropertyFilterCondition) MetaClass(io.jmix.core.metamodel.model.MetaClass) FilterCondition(io.jmix.ui.entity.FilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) PropertyFilterCondition(io.jmix.ui.entity.PropertyFilterCondition) FilterValueComponent(io.jmix.ui.entity.FilterValueComponent) MetaClass(io.jmix.core.metamodel.model.MetaClass) PropertyFilter(io.jmix.ui.component.PropertyFilter) HasValue(io.jmix.ui.component.HasValue)

Example 3 with PropertyFilterCondition

use of io.jmix.ui.entity.PropertyFilterCondition in project jmix by jmix-framework.

the class PropertyFilterConverter method convertToModel.

@Override
public PropertyFilterCondition convertToModel(PropertyFilter propertyFilter) {
    PropertyFilterCondition condition = super.convertToModel(propertyFilter);
    condition.setCaption(propertyFilter.getCaption());
    condition.setLocalizedCaption(getLocalizedModelCaption(propertyFilter));
    condition.setCaptionPosition(propertyFilter.getCaptionPosition());
    condition.setRequired(propertyFilter.isRequired());
    condition.setProperty(propertyFilter.getProperty());
    condition.setOperation(propertyFilter.getOperation());
    condition.setOperationEditable(propertyFilter.isOperationEditable());
    condition.setOperationCaptionVisible(propertyFilter.isOperationCaptionVisible());
    condition.setParameterName(propertyFilter.getParameterName());
    FilterValueComponent valueComponent = convertValueComponentToModel(propertyFilter);
    String modelDefaultValue = convertDefaultValueToModel(propertyFilter);
    valueComponent.setDefaultValue(modelDefaultValue);
    condition.setValueComponent(valueComponent);
    return condition;
}
Also used : PropertyFilterCondition(io.jmix.ui.entity.PropertyFilterCondition) FilterValueComponent(io.jmix.ui.entity.FilterValueComponent)

Aggregations

PropertyFilterCondition (io.jmix.ui.entity.PropertyFilterCondition)3 MetaClass (io.jmix.core.metamodel.model.MetaClass)2 PropertyFilter (io.jmix.ui.component.PropertyFilter)2 FilterValueComponent (io.jmix.ui.entity.FilterValueComponent)2 HasValue (io.jmix.ui.component.HasValue)1 FilterCondition (io.jmix.ui.entity.FilterCondition)1 HeaderFilterCondition (io.jmix.ui.entity.HeaderFilterCondition)1