use of au.com.vaadinutils.layout.TimePicker 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));
}
}
}
use of au.com.vaadinutils.layout.TimePicker 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