use of au.com.vaadinutils.jasper.scheduler.entities.ScheduleMode in project VaadinUtils by rlsutton1.
the class JasperReportScheduleLayout method buildScheduleTab.
private void buildScheduleTab(ValidatingFieldGroup<ReportEmailScheduleEntity> validatingFieldGroup, FormLayout main, FormHelper<ReportEmailScheduleEntity> helper) {
helper.bindBooleanField(main, validatingFieldGroup, "Enabled", ReportEmailScheduleEntity_.enabled);
helper.bindDateField(main, validatingFieldGroup, "Last Run Time", ReportEmailScheduleEntity_.lastRuntime, "yyyy/MM/dd HH:mm", Resolution.MINUTE).setReadOnly(true);
helper.bindDateField(main, validatingFieldGroup, "Next Run Time", ReportEmailScheduleEntity_.nextScheduledTime, "yyyy/MM/dd HH:mm", Resolution.MINUTE).setReadOnly(true);
ComboBox modeCombo = helper.bindEnumField(main, validatingFieldGroup, "Frequency", ReportEmailScheduleEntity_.scheduleMode, ScheduleMode.class);
final DateField oneTime = helper.bindDateField(main, validatingFieldGroup, "Start time", ReportEmailScheduleEntity_.oneTimeRunDateTime, "yyyy/MM/dd HH:mm", Resolution.MINUTE);
final TimePicker timeOfDay = new TimePicker("Start time");
main.addComponent(timeOfDay);
validatingFieldGroup.bind(timeOfDay, ReportEmailScheduleEntity_.timeOfDayToRun.getName());
// day of week
final DayOfWeekCheckBoxes dayLayout = new DayOfWeekCheckBoxes();
validatingFieldGroup.bind(dayLayout, ReportEmailScheduleEntity_.scheduledDaysOfWeek.getName());
main.addComponent(dayLayout);
// day of month
List<String> options = new LinkedList<String>();
for (int i = 1; i < 32; i++) {
options.add("" + i);
}
final ComboBox dayOfMonth = helper.bindComboBox(main, validatingFieldGroup, ReportEmailScheduleEntity_.scheduledDayOfMonth.getName(), "Day of month", options);
dayOfMonth.setConverter(Integer.class);
dayOfMonth.setNullSelectionAllowed(true);
modeCombo.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 3640488458535487174L;
@Override
public void valueChange(ValueChangeEvent event) {
ScheduleMode mode = (ScheduleMode) event.getProperty().getValue();
if (mode == null) {
mode = ScheduleMode.ONE_TIME;
}
oneTime.setRequired(false);
switch(mode) {
case ONE_TIME:
oneTime.setRequired(true);
oneTime.setVisible(true);
timeOfDay.setVisible(false);
dayLayout.setVisible(false);
dayOfMonth.setVisible(false);
break;
case DAY_OF_MONTH:
oneTime.setVisible(false);
timeOfDay.setVisible(true);
dayLayout.setVisible(false);
dayOfMonth.setVisible(true);
break;
case DAY_OF_WEEK:
oneTime.setVisible(false);
timeOfDay.setVisible(true);
dayLayout.setVisible(true);
dayLayout.setRequired(true);
dayOfMonth.setVisible(false);
break;
case EVERY_DAY:
oneTime.setVisible(false);
timeOfDay.setVisible(true);
dayLayout.setVisible(false);
dayOfMonth.setVisible(false);
break;
}
}
});
}
Aggregations