Search in sources :

Example 1 with DateInIntervalComponent

use of com.haulmont.cuba.gui.components.filter.dateinterval.DateInIntervalComponent in project cuba by cuba-platform.

the class Param method createEditComponent.

/**
 * Creates an GUI component for condition parameter.
 *
 * @param valueProperty What value the editor will be connected with: current filter value or default one.
 * @return GUI component for condition parameter.
 */
public Component createEditComponent(ValueProperty valueProperty) {
    Component component;
    switch(type) {
        case DATATYPE:
            if (isDateInterval) {
                DateInIntervalComponent dateInIntervalComponent = AppBeans.get(DateInIntervalComponent.class);
                dateInIntervalComponent.addValueChangeListener(newValue -> {
                    _setValue(newValue == null ? null : newValue.getDescription(), valueProperty);
                });
                component = dateInIntervalComponent.createComponent((String) _getValue(valueProperty));
            } else {
                component = createDatatypeField(Datatypes.getNN(javaClass), valueProperty);
            }
            break;
        case ENTITY:
            component = createEntityLookup(valueProperty);
            break;
        case UNARY:
            component = createUnaryField(valueProperty);
            break;
        case ENUM:
            component = createEnumLookup(valueProperty);
            break;
        case RUNTIME_ENUM:
            component = createRuntimeEnumLookup(valueProperty);
            break;
        default:
            throw new UnsupportedOperationException("Unsupported param type: " + type);
    }
    this.editComponent = component;
    return component;
}
Also used : DateInIntervalComponent(com.haulmont.cuba.gui.components.filter.dateinterval.DateInIntervalComponent) DateInIntervalComponent(com.haulmont.cuba.gui.components.filter.dateinterval.DateInIntervalComponent)

Example 2 with DateInIntervalComponent

use of com.haulmont.cuba.gui.components.filter.dateinterval.DateInIntervalComponent in project cuba by cuba-platform.

the class Param method createEditComponent.

/**
 * Creates an GUI component for condition parameter.
 *
 * @param valueProperty What value the editor will be connected with: current filter value or default one.
 * @return GUI component for condition parameter.
 */
protected Component createEditComponent(@Nullable FilterDataContext context, ValueProperty valueProperty) {
    Component component;
    switch(type) {
        case DATATYPE:
            if (isDateInterval) {
                DateInIntervalComponent dateInIntervalComponent = beanLocator.get(DateInIntervalComponent.class);
                dateInIntervalComponent.addValueChangeListener(newValue -> {
                    _setValue(newValue == null ? null : newValue.getDescription(), valueProperty);
                });
                component = dateInIntervalComponent.createComponent((String) _getValue(valueProperty));
            } else {
                component = createDatatypeField(Datatypes.getNN(javaClass), valueProperty);
            }
            break;
        case ENTITY:
            component = createEntityLookup(context, valueProperty);
            break;
        case UNARY:
            component = createUnaryField(valueProperty);
            break;
        case ENUM:
            component = createEnumLookup(valueProperty);
            break;
        case RUNTIME_ENUM:
            component = createRuntimeEnumLookup(valueProperty);
            break;
        default:
            throw new UnsupportedOperationException("Unsupported param type: " + type);
    }
    this.editComponent = component;
    return component;
}
Also used : DateInIntervalComponent(com.haulmont.cuba.gui.components.filter.dateinterval.DateInIntervalComponent) DateInIntervalComponent(com.haulmont.cuba.gui.components.filter.dateinterval.DateInIntervalComponent)

Aggregations

DateInIntervalComponent (com.haulmont.cuba.gui.components.filter.dateinterval.DateInIntervalComponent)2