Search in sources :

Example 1 with DatatypeRegistry

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

the class ComponentLoaderHelper method loadTableColumnType.

public static void loadTableColumnType(io.jmix.ui.component.Table.Column column, Element element, ApplicationContext applicationContext) {
    if (!(column instanceof Table.Column)) {
        return;
    }
    if (column.getMetaPropertyPath() != null) {
        ((Table.Column<?>) column).setType(column.getMetaPropertyPath().getRangeJavaClass());
    }
    String type = element.attributeValue("type");
    if (StringUtils.isNotEmpty(type)) {
        DatatypeRegistry datatypeRegistry = applicationContext.getBean(DatatypeRegistry.class);
        Datatype datatype = datatypeRegistry.get(type);
        ((Table.Column<?>) column).setType(datatype.getJavaClass());
    }
}
Also used : DatatypeRegistry(io.jmix.core.metamodel.datatype.DatatypeRegistry) Datatype(io.jmix.core.metamodel.datatype.Datatype)

Example 2 with DatatypeRegistry

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

the class AbstractFieldLoader method loadDatatype.

protected void loadDatatype(HasDatatype component, Element element) {
    String datatypeAttribute = element.attributeValue("datatype");
    if (StringUtils.isNotEmpty(datatypeAttribute)) {
        // noinspection unchecked
        DatatypeRegistry datatypeRegistry = applicationContext.getBean(DatatypeRegistry.class);
        component.setDatatype(datatypeRegistry.find(datatypeAttribute));
    }
}
Also used : DatatypeRegistry(io.jmix.core.metamodel.datatype.DatatypeRegistry)

Example 3 with DatatypeRegistry

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

the class CalendarLoader method loadDatatype.

protected void loadDatatype(HasDatatype component, Element element) {
    String datatypeAttribute = element.attributeValue("datatype");
    if (StringUtils.isNotEmpty(datatypeAttribute)) {
        DatatypeRegistry datatypeRegistry = applicationContext.getBean(DatatypeRegistry.class);
        component.setDatatype(datatypeRegistry.find(datatypeAttribute));
    }
}
Also used : DatatypeRegistry(io.jmix.core.metamodel.datatype.DatatypeRegistry)

Example 4 with DatatypeRegistry

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

the class AbstractSingleFileUploadField method getFileSizeLimitString.

protected String getFileSizeLimitString() {
    String fileSizeLimitString;
    if (fileSizeLimit > 0) {
        if (fileSizeLimit % BYTES_IN_MEGABYTE == 0) {
            fileSizeLimitString = String.valueOf(fileSizeLimit / BYTES_IN_MEGABYTE);
        } else {
            DatatypeRegistry datatypeRegistry = applicationContext.getBean(DatatypeRegistry.class);
            Datatype<Double> doubleDatatype = datatypeRegistry.get(Double.class);
            double fileSizeInMb = fileSizeLimit / ((double) BYTES_IN_MEGABYTE);
            CurrentAuthentication currentAuthentication = applicationContext.getBean(CurrentAuthentication.class);
            fileSizeLimitString = doubleDatatype.format(fileSizeInMb, currentAuthentication.getLocale());
        }
    } else {
        fileSizeLimitString = String.valueOf(componentProperties.getUploadFieldMaxUploadSizeMb());
    }
    return fileSizeLimitString;
}
Also used : CurrentAuthentication(io.jmix.core.security.CurrentAuthentication) DatatypeRegistry(io.jmix.core.metamodel.datatype.DatatypeRegistry)

Example 5 with DatatypeRegistry

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

the class FileMultiUploadFieldImpl method getFileSizeLimitString.

protected String getFileSizeLimitString() {
    String fileSizeLimitString;
    if (fileSizeLimit > 0) {
        if (fileSizeLimit % BYTES_IN_MEGABYTE == 0) {
            fileSizeLimitString = String.valueOf(fileSizeLimit / BYTES_IN_MEGABYTE);
        } else {
            DatatypeRegistry datatypeRegistry = applicationContext.getBean(DatatypeRegistry.class);
            Datatype<Double> doubleDatatype = datatypeRegistry.get(Double.class);
            double fileSizeInMb = fileSizeLimit / ((double) BYTES_IN_MEGABYTE);
            CurrentAuthentication currentAuthentication = applicationContext.getBean(CurrentAuthentication.class);
            fileSizeLimitString = doubleDatatype.format(fileSizeInMb, currentAuthentication.getLocale());
        }
    } else {
        fileSizeLimitString = String.valueOf(componentProperties.getUploadFieldMaxUploadSizeMb());
    }
    return fileSizeLimitString;
}
Also used : CurrentAuthentication(io.jmix.core.security.CurrentAuthentication) DatatypeRegistry(io.jmix.core.metamodel.datatype.DatatypeRegistry)

Aggregations

DatatypeRegistry (io.jmix.core.metamodel.datatype.DatatypeRegistry)6 CurrentAuthentication (io.jmix.core.security.CurrentAuthentication)2 Messages (io.jmix.core.Messages)1 Datatype (io.jmix.core.metamodel.datatype.Datatype)1 Nullable (javax.annotation.Nullable)1