Search in sources :

Example 1 with Resolution

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;
}
Also used : Element(org.dom4j.Element) Resolution(com.haulmont.cuba.gui.components.DateField.Resolution)

Aggregations

Resolution (com.haulmont.cuba.gui.components.DateField.Resolution)1 Element (org.dom4j.Element)1