Search in sources :

Example 1 with EntityCalendarEventProvider

use of com.haulmont.cuba.gui.components.calendar.EntityCalendarEventProvider in project cuba by cuba-platform.

the class CalendarLoader method loadDatasource.

protected void loadDatasource(Calendar component, Element element) {
    final String datasource = element.attributeValue("datasource");
    if (!StringUtils.isEmpty(datasource)) {
        CollectionDatasource ds = (CollectionDatasource) context.getDsContext().get(datasource);
        if (ds == null) {
            throw new GuiDevelopmentException(String.format("Datasource '%s' is not defined", datasource), getContext().getFullFrameId(), "Component ID", component.getId());
        }
        component.setDatasource(ds);
        if (component.getEventProvider() instanceof EntityCalendarEventProvider) {
            EntityCalendarEventProvider eventProvider = (EntityCalendarEventProvider) component.getEventProvider();
            String startDateProperty = element.attributeValue("startDateProperty");
            if (StringUtils.isNotEmpty(startDateProperty)) {
                eventProvider.setStartDateProperty(startDateProperty);
            }
            String endDateProperty = element.attributeValue("endDateProperty");
            if (StringUtils.isNotEmpty(endDateProperty)) {
                eventProvider.setEndDateProperty(endDateProperty);
            }
            String captionProperty = element.attributeValue("captionProperty");
            if (StringUtils.isNotEmpty(captionProperty)) {
                eventProvider.setCaptionProperty(captionProperty);
            }
            String descriptionProperty = element.attributeValue("descriptionProperty");
            if (StringUtils.isNotEmpty(descriptionProperty)) {
                eventProvider.setDescriptionProperty(descriptionProperty);
            }
            String styleNameProperty = element.attributeValue("stylenameProperty");
            if (StringUtils.isNotEmpty(styleNameProperty)) {
                eventProvider.setStyleNameProperty(styleNameProperty);
            }
            String allDayProperty = element.attributeValue("isAllDayProperty");
            if (StringUtils.isNotEmpty(allDayProperty)) {
                eventProvider.setAllDayProperty(allDayProperty);
            }
        }
    }
}
Also used : CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) EntityCalendarEventProvider(com.haulmont.cuba.gui.components.calendar.EntityCalendarEventProvider)

Aggregations

GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)1 EntityCalendarEventProvider (com.haulmont.cuba.gui.components.calendar.EntityCalendarEventProvider)1 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)1