Search in sources :

Example 1 with AdaptiveNumberDatatype

use of io.jmix.core.metamodel.datatype.impl.AdaptiveNumberDatatype in project jmix by jmix-framework.

the class CategoryAttrsEdit method setupNumberFormat.

protected void setupNumberFormat() {
    String formatPattern = getEditedEntity().getConfiguration().getNumberFormatPattern();
    Datatype datatype;
    if (!Strings.isNullOrEmpty(formatPattern)) {
        datatype = new AdaptiveNumberDatatype(BigDecimal.class, formatPattern, "", "", formatStringsRegistry);
    } else {
        datatype = datatypeRegistry.find(BigDecimal.class);
    }
    defaultDecimalField.setDatatype(datatype);
    minDecimalField.setDatatype(datatype);
    maxDecimalField.setDatatype(datatype);
    defaultDecimalField.setValue(defaultDecimalField.getValue());
    minDecimalField.setValue(minDecimalField.getValue());
    maxDecimalField.setValue(maxDecimalField.getValue());
}
Also used : AdaptiveNumberDatatype(io.jmix.core.metamodel.datatype.impl.AdaptiveNumberDatatype) BigDecimal(java.math.BigDecimal) AdaptiveNumberDatatype(io.jmix.core.metamodel.datatype.impl.AdaptiveNumberDatatype) Datatype(io.jmix.core.metamodel.datatype.Datatype)

Example 2 with AdaptiveNumberDatatype

use of io.jmix.core.metamodel.datatype.impl.AdaptiveNumberDatatype in project jmix by jmix-framework.

the class DynAttrComponentGenerationStrategy method setCustomDatatype.

protected void setCustomDatatype(TextField field, AttributeDefinition attribute) {
    String formatPattern = attribute.getConfiguration().getNumberFormatPattern();
    if (!Strings.isNullOrEmpty(formatPattern)) {
        Class<?> type = attribute.getDataType() == DECIMAL ? BigDecimal.class : Number.class;
        // noinspection unchecked
        field.setDatatype(new AdaptiveNumberDatatype(type, formatPattern, "", "", formatStringsRegistry));
    }
}
Also used : AdaptiveNumberDatatype(io.jmix.core.metamodel.datatype.impl.AdaptiveNumberDatatype)

Aggregations

AdaptiveNumberDatatype (io.jmix.core.metamodel.datatype.impl.AdaptiveNumberDatatype)2 Datatype (io.jmix.core.metamodel.datatype.Datatype)1 BigDecimal (java.math.BigDecimal)1