Search in sources :

Example 1 with DateParameterOffsetType

use of au.com.vaadinutils.jasper.scheduler.entities.DateParameterOffsetType in project VaadinUtils by rlsutton1.

the class JasperReportScheduleLayout method dateParamsHandleRowChange.

private void dateParamsHandleRowChange(EntityItem<ReportEmailScheduleEntity> item) {
    paramForm.removeAllComponents();
    paramForm.setSpacing(true);
    paramForm.setSizeFull();
    paramForm.setMargin(true);
    updaters.clear();
    if (item != null) {
        ReportEmailScheduleEntity entity = item.getEntity();
        List<DateParameterOffsetType> offsetTypes = new LinkedList<DateParameterOffsetType>();
        for (DateParameterOffsetType offsetType : DateParameterOffsetType.values()) {
            offsetTypes.add(offsetType);
        }
        for (final ScheduledDateParameter dateParam : entity.getDateParameters()) {
            HorizontalLayout dateLayout = new HorizontalLayout();
            dateLayout.setSizeFull();
            dateLayout.setSpacing(true);
            dateLayout.setHeight("55");
            final ComboBox offsetType = new ComboBox(dateParam.getLabel(), offsetTypes);
            offsetType.setImmediate(true);
            offsetType.setNullSelectionAllowed(false);
            offsetType.setWidth("140");
            final DateField startDateField = new DateField("From", dateParam.getStartDate());
            startDateField.setResolution(Resolution.DAY);
            startDateField.setDateFormat("yyyy/MM/dd");
            // pickers visability doesn't change, it's determined by the
            // parameter type which can't be changed here
            final TimePicker startTimePicker = new TimePicker("");
            startTimePicker.setValues(dateParam.getStartDate());
            startTimePicker.setVisible(dateParam.getType() == DateParameterType.DATE_TIME);
            final DateField endDateField = new DateField("To", dateParam.getEndDate());
            endDateField.setResolution(Resolution.DAY);
            endDateField.setDateFormat("yyyy/MM/dd");
            // pickers visability doesn't change, it's determined by the
            // parameter type which can't be changed here
            final TimePicker endTimePicker = new TimePicker("");
            endTimePicker.setValues(dateParam.getStartDate());
            endTimePicker.setVisible(dateParam.getType() == DateParameterType.DATE_TIME);
            offsetType.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 7081417825842355432L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    DateParameterOffsetType offsetTypeValue = (DateParameterOffsetType) event.getProperty().getValue();
                    startDateField.setVisible(offsetTypeValue == DateParameterOffsetType.CONSTANT);
                    endDateField.setVisible(offsetTypeValue == DateParameterOffsetType.CONSTANT);
                }
            });
            offsetType.setValue(dateParam.getOffsetType());
            dateLayout.addComponent(offsetType);
            dateLayout.addComponent(startDateField);
            dateLayout.addComponent(startTimePicker);
            dateLayout.addComponent(endDateField);
            dateLayout.addComponent(endTimePicker);
            paramForm.addComponent(dateLayout);
            updaters.add(new EntityParamUpdater(dateParam.getLabel(), offsetType, startDateField, startTimePicker, endDateField, endTimePicker));
        }
    }
}
Also used : TimePicker(au.com.vaadinutils.layout.TimePicker) ComboBox(com.vaadin.ui.ComboBox) ReportEmailScheduleEntity(au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduleEntity) DateParameterOffsetType(au.com.vaadinutils.jasper.scheduler.entities.DateParameterOffsetType) LinkedList(java.util.LinkedList) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) DateField(com.vaadin.ui.DateField)

Aggregations

DateParameterOffsetType (au.com.vaadinutils.jasper.scheduler.entities.DateParameterOffsetType)1 ReportEmailScheduleEntity (au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduleEntity)1 TimePicker (au.com.vaadinutils.layout.TimePicker)1 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)1 ValueChangeListener (com.vaadin.data.Property.ValueChangeListener)1 ComboBox (com.vaadin.ui.ComboBox)1 DateField (com.vaadin.ui.DateField)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 LinkedList (java.util.LinkedList)1