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());
}
}
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));
}
}
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));
}
}
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;
}
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;
}
Aggregations