Search in sources :

Example 1 with FilterValueComponent

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

the class FullTextFilterConverter method convertValueComponentToComponent.

protected HasValue<String> convertValueComponentToComponent(FullTextFilterCondition model) {
    HasValue<String> valueComponent = uiComponents.create(TextField.TYPE_STRING);
    FilterValueComponent filterValueComponent = model.getValueComponent();
    if (filterValueComponent != null) {
        valueComponent.setId(filterValueComponent.getComponentId());
        valueComponent.setStyleName(filterValueComponent.getStyleName());
    }
    return valueComponent;
}
Also used : FilterValueComponent(io.jmix.ui.entity.FilterValueComponent)

Example 2 with FilterValueComponent

use of io.jmix.ui.entity.FilterValueComponent 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;
}
Also used : AbstractSingleFilterCondition(io.jmix.ui.entity.AbstractSingleFilterCondition) FilterCondition(io.jmix.ui.entity.FilterCondition) JpqlFilterCondition(io.jmix.ui.entity.JpqlFilterCondition) HeaderFilterCondition(io.jmix.ui.entity.HeaderFilterCondition) AbstractSingleFilterCondition(io.jmix.ui.entity.AbstractSingleFilterCondition) FilterValueComponent(io.jmix.ui.entity.FilterValueComponent)

Example 3 with FilterValueComponent

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

the class JpqlFilterConditionEdit method onBeforeCommitChanges.

@SuppressWarnings("rawtypes")
@Subscribe
protected void onBeforeCommitChanges(BeforeCommitChangesEvent event) {
    if (defaultValueField != null && getEditedEntity().getParameterClass() != null && getEditedEntity().getValueComponent() != null) {
        Class parameterClass = classManager.loadClass(getEditedEntity().getParameterClass());
        String modelDefaultValue = jpqlFilterSupport.formatDefaultValue(parameterClass, getEditedEntity().getHasInExpression(), defaultValueField.getValue());
        FilterValueComponent valueComponent = getEditedEntity().getValueComponent();
        valueComponent.setDefaultValue(modelDefaultValue);
        valueComponent.setComponentName(singleFilterSupport.getValueComponentName(defaultValueField));
    }
    String caption = getEditedEntity().getCaption();
    if (!Strings.isNullOrEmpty(caption)) {
        getEditedEntity().setLocalizedCaption(caption);
    }
}
Also used : FilterValueComponent(io.jmix.ui.entity.FilterValueComponent) MetaClass(io.jmix.core.metamodel.model.MetaClass) Subscribe(io.jmix.ui.screen.Subscribe)

Example 4 with FilterValueComponent

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

the class JpqlFilterConverter method convertValueComponentToComponent.

protected HasValue convertValueComponentToComponent(JpqlFilter component, JpqlFilterCondition model) {
    HasValue valueComponent = generateValueComponent(component, model);
    FilterValueComponent filterValueComponent = model.getValueComponent();
    if (filterValueComponent != null) {
        String componentName = filterValueComponent.getComponentName();
        if (componentName != null) {
            String defaultName = singleFilterSupport.getValueComponentName(valueComponent);
            if (!Objects.equals(defaultName, componentName)) {
                valueComponent = uiComponents.create(componentName);
            }
        }
        valueComponent.setId(filterValueComponent.getComponentId());
        valueComponent.setStyleName(filterValueComponent.getStyleName());
    }
    return valueComponent;
}
Also used : FilterValueComponent(io.jmix.ui.entity.FilterValueComponent) HasValue(io.jmix.ui.component.HasValue)

Example 5 with FilterValueComponent

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

the class JpqlFilterConverter method convertToModel.

@Override
public JpqlFilterCondition convertToModel(JpqlFilter jpqlFilter) {
    JpqlFilterCondition condition = super.convertToModel(jpqlFilter);
    condition.setCaption(jpqlFilter.getCaption());
    condition.setLocalizedCaption(getLocalizedModelCaption(jpqlFilter));
    condition.setCaptionPosition(jpqlFilter.getCaptionPosition());
    condition.setRequired(jpqlFilter.isRequired());
    condition.setParameterName(jpqlFilter.getParameterName());
    condition.setParameterClass(jpqlFilter.getParameterClass().getName());
    condition.setWhere(jpqlFilter.getWhere());
    condition.setJoin(jpqlFilter.getJoin());
    condition.setHasInExpression(jpqlFilter.hasInExpression());
    FilterValueComponent valueComponent = convertValueComponentToModel(jpqlFilter);
    String modelDefaultValue = convertDefaultValueToModel(jpqlFilter);
    valueComponent.setDefaultValue(modelDefaultValue);
    condition.setValueComponent(valueComponent);
    return condition;
}
Also used : FilterValueComponent(io.jmix.ui.entity.FilterValueComponent) JpqlFilterCondition(io.jmix.ui.entity.JpqlFilterCondition)

Aggregations

FilterValueComponent (io.jmix.ui.entity.FilterValueComponent)12 HasValue (io.jmix.ui.component.HasValue)3 MetaClass (io.jmix.core.metamodel.model.MetaClass)2 FilterCondition (io.jmix.ui.entity.FilterCondition)2 HeaderFilterCondition (io.jmix.ui.entity.HeaderFilterCondition)2 JpqlFilterCondition (io.jmix.ui.entity.JpqlFilterCondition)2 PropertyFilterCondition (io.jmix.ui.entity.PropertyFilterCondition)2 Subscribe (io.jmix.ui.screen.Subscribe)2 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 PropertyFilter (io.jmix.ui.component.PropertyFilter)1 AbstractSingleFilterCondition (io.jmix.ui.entity.AbstractSingleFilterCondition)1