Search in sources :

Example 1 with ValueClearAction

use of io.jmix.ui.action.valuepicker.ValueClearAction in project jmix by jmix-framework.

the class JpqlFilterComponentGenerationStrategy method createCollectionField.

@SuppressWarnings({ "unchecked", "rawtypes" })
protected Component createCollectionField(ComponentGenerationContext context) {
    JpqlFilterComponentGenerationContext cfContext = (JpqlFilterComponentGenerationContext) context;
    Class parameterClass = cfContext.getParameterClass();
    ValuesPicker valuesPicker = uiComponents.create(ValuesPicker.class);
    setValueSource(valuesPicker, cfContext);
    ValuesSelectAction selectAction = actions.create(ValuesSelectAction.class);
    if (Entity.class.isAssignableFrom(parameterClass)) {
        MetaClass metaClass = metadata.getClass(cfContext.getParameterClass());
        selectAction.setEntityName(metaClass.getName());
    } else if (EnumClass.class.isAssignableFrom(parameterClass)) {
        selectAction.setEnumClass(parameterClass);
    } else if (datatypeRegistry.find(parameterClass) != null) {
        Datatype datatype = datatypeRegistry.get(parameterClass);
        selectAction.setJavaClass(datatype.getJavaClass());
    }
    valuesPicker.addAction(selectAction);
    ValueClearAction valueClearAction = actions.create(ValueClearAction.class);
    valuesPicker.addAction(valueClearAction);
    return valuesPicker;
}
Also used : ValuesSelectAction(io.jmix.ui.action.valuespicker.ValuesSelectAction) ValueClearAction(io.jmix.ui.action.valuepicker.ValueClearAction) MetaClass(io.jmix.core.metamodel.model.MetaClass) EnumClass(io.jmix.core.metamodel.datatype.impl.EnumClass) MetaClass(io.jmix.core.metamodel.model.MetaClass) EnumClass(io.jmix.core.metamodel.datatype.impl.EnumClass) Datatype(io.jmix.core.metamodel.datatype.Datatype)

Example 2 with ValueClearAction

use of io.jmix.ui.action.valuepicker.ValueClearAction in project jmix by jmix-framework.

the class DynAttrComponentGenerationStrategy method createCollectionField.

protected Component createCollectionField(ComponentGenerationContext context, AttributeDefinition attribute) {
    ValuesPicker valuesPicker = uiComponents.create(ValuesPicker.NAME);
    setValidators(valuesPicker, attribute);
    setValueSource(valuesPicker, context);
    ValuesSelectAction selectAction = actions.create(ValuesSelectAction.class);
    initValuesSelectActionByAttribute(selectAction, attribute);
    if (valuesPicker.getValueSource() instanceof ContainerValueSource && attribute.getConfiguration().isLookup()) {
        ContainerValueSource valueSource = (ContainerValueSource) valuesPicker.getValueSource();
        setValuesPickerOptionsLoader(valuesPicker, attribute, valueSource);
    }
    valuesPicker.addAction(selectAction);
    ValueClearAction valueClearAction = actions.create(ValueClearAction.class);
    valuesPicker.addAction(valueClearAction);
    return valuesPicker;
}
Also used : ContainerValueSource(io.jmix.ui.component.data.value.ContainerValueSource) ValuesSelectAction(io.jmix.ui.action.valuespicker.ValuesSelectAction) ValueClearAction(io.jmix.ui.action.valuepicker.ValueClearAction)

Example 3 with ValueClearAction

use of io.jmix.ui.action.valuepicker.ValueClearAction in project jmix by jmix-framework.

the class AbstractComponentGenerationStrategy method createCollectionField.

@SuppressWarnings({ "unchecked", "rawtypes" })
protected Component createCollectionField(ComponentGenerationContext context, MetaPropertyPath mpp) {
    ValuesPicker valuesPicker = uiComponents.create(ValuesPicker.class);
    setValueSource(valuesPicker, context);
    ValuesSelectAction selectAction = actions.create(ValuesSelectAction.class);
    Range range = mpp.getRange();
    if (range.isClass()) {
        selectAction.setEntityName(range.asClass().getName());
    } else if (range.isDatatype()) {
        selectAction.setJavaClass(range.asDatatype().getJavaClass());
    } else if (range.isEnum()) {
        selectAction.setEnumClass(range.asEnumeration().getJavaClass());
    }
    valuesPicker.addAction(selectAction);
    ValueClearAction valueClearAction = actions.create(ValueClearAction.class);
    valuesPicker.addAction(valueClearAction);
    return valuesPicker;
}
Also used : ValuesSelectAction(io.jmix.ui.action.valuespicker.ValuesSelectAction) ValueClearAction(io.jmix.ui.action.valuepicker.ValueClearAction) Range(io.jmix.core.metamodel.model.Range)

Aggregations

ValueClearAction (io.jmix.ui.action.valuepicker.ValueClearAction)3 ValuesSelectAction (io.jmix.ui.action.valuespicker.ValuesSelectAction)3 Datatype (io.jmix.core.metamodel.datatype.Datatype)1 EnumClass (io.jmix.core.metamodel.datatype.impl.EnumClass)1 MetaClass (io.jmix.core.metamodel.model.MetaClass)1 Range (io.jmix.core.metamodel.model.Range)1 ContainerValueSource (io.jmix.ui.component.data.value.ContainerValueSource)1