use of org.apache.wicket.datetime.markup.html.form.DateTextField in project midpoint by Evolveum.
the class PageTaskAdd method initScheduling.
private void initScheduling(final Form mainForm) {
final WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
container.setOutputMarkupId(true);
mainForm.add(container);
final IModel<Boolean> recurringCheck = new PropertyModel<>(model, TaskAddDto.F_RECURRING);
final IModel<Boolean> boundCheck = new PropertyModel<>(model, TaskAddDto.F_BOUND);
final WebMarkupContainer boundContainer = new WebMarkupContainer(ID_BOUND_CONTAINER);
boundContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return recurringCheck.getObject();
}
});
boundContainer.setOutputMarkupId(true);
container.add(boundContainer);
final WebMarkupContainer intervalContainer = new WebMarkupContainer(ID_INTERVAL_CONTAINER);
intervalContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return recurringCheck.getObject();
}
});
intervalContainer.setOutputMarkupId(true);
container.add(intervalContainer);
final WebMarkupContainer cronContainer = new WebMarkupContainer(ID_CRON_CONTAINER);
cronContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return recurringCheck.getObject() && !boundCheck.getObject();
}
});
cronContainer.setOutputMarkupId(true);
container.add(cronContainer);
AjaxCheckBox recurring = new AjaxCheckBox(ID_RECURRING, recurringCheck) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(container);
}
};
mainForm.add(recurring);
AjaxCheckBox bound = new AjaxCheckBox(ID_BOUND, boundCheck) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(container);
}
};
boundContainer.add(bound);
Label boundHelp = new Label(ID_BOUND_HELP);
boundHelp.add(new InfoTooltipBehavior());
boundContainer.add(boundHelp);
TextField<Integer> interval = new TextField<>(ID_INTERVAL, new PropertyModel<Integer>(model, TaskAddDto.F_INTERVAL));
interval.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
intervalContainer.add(interval);
TextField<String> cron = new TextField<>(ID_CRON, new PropertyModel<String>(model, TaskAddDto.F_CRON));
cron.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
// if (recurringCheck.getObject() && !boundCheck.getObject()) {
// cron.setRequired(true);
// }
cronContainer.add(cron);
Label cronHelp = new Label(ID_CRON_HELP);
cronHelp.add(new InfoTooltipBehavior());
cronContainer.add(cronHelp);
final DateTimeField notStartBefore = new DateTimeField(ID_NO_START_BEFORE_FIELD, new PropertyModel<Date>(model, TaskAddDto.F_NOT_START_BEFORE)) {
@Override
protected DateTextField newDateTextField(String id, PropertyModel dateFieldModel) {
// todo i18n
return DateTextField.forDatePattern(id, dateFieldModel, "dd/MMM/yyyy");
}
};
notStartBefore.setOutputMarkupId(true);
mainForm.add(notStartBefore);
final DateTimeField notStartAfter = new DateTimeField(ID_NO_START_AFTER_FIELD, new PropertyModel<Date>(model, TaskAddDto.F_NOT_START_AFTER)) {
@Override
protected DateTextField newDateTextField(String id, PropertyModel dateFieldModel) {
// todo i18n
return DateTextField.forDatePattern(id, dateFieldModel, "dd/MMM/yyyy");
}
};
notStartAfter.setOutputMarkupId(true);
mainForm.add(notStartAfter);
mainForm.add(new StartEndDateValidator(notStartBefore, notStartAfter));
mainForm.add(new ScheduleValidator(getTaskManager(), recurring, bound, interval, cron));
}
Aggregations