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