use of com.haulmont.cuba.gui.components.DateField.Resolution in project cuba by cuba-platform.
the class AbstractComponentGenerationStrategy method createDateField.
protected Component createDateField(ComponentGenerationContext context) {
DateField dateField = uiComponents.create(DateField.class);
setValidators(dateField, context);
setValueSource(dateField, context);
Element xmlDescriptor = context.getXmlDescriptor();
String resolution = xmlDescriptor == null ? null : xmlDescriptor.attributeValue("resolution");
String dateFormat = xmlDescriptor == null ? null : xmlDescriptor.attributeValue("dateFormat");
if (StringUtils.isNotEmpty(resolution)) {
Resolution dateResolution = Resolution.valueOf(resolution);
dateField.setResolution(dateResolution);
if (dateFormat == null) {
if (dateResolution == Resolution.DAY) {
dateFormat = "msg://dateFormat";
} else if (dateResolution == Resolution.MIN) {
dateFormat = "msg://dateTimeFormat";
}
}
}
if (StringUtils.isNotEmpty(dateFormat)) {
if (dateFormat.startsWith("msg://")) {
dateFormat = messages.getMainMessage(dateFormat.substring(6));
}
dateField.setDateFormat(dateFormat);
}
return dateField;
}
Aggregations