return panel;
}
private Form createForm(final boolean required, final boolean failValidator) {
// hand-crafted form, not using form field factory
final Form form = new Form() {
@Override
public void addField(Object propertyId, Field<?> field) {
super.addField(propertyId, field);
field.setRequired(required);
field.setRequiredError("Missing required value!");
if (failValidator && !(field instanceof Button)) {
field.addValidator(new AlwaysFailValidator());
}
}
};
form.addField("Field", new TextField("Text"));
form.addField("Date", new DateField("Date"));
// not good for automated testing with screenshots when null
// form.addField("Inline Date", new InlineDateField("Date"));
// same as basic DateField
// form.addField("Popup Date", new PopupDateField("Date"));
Button setDateButton = new Button("Set date");
form.getLayout().addComponent(setDateButton);
// form.addField("Set Date", setDateButton);
setDateButton.addListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
form.getField("Date").setValue(new Date(0));
}
});
NativeSelect nativeSelect = new NativeSelect("NativeSelect");
form.addField("Native Select", nativeSelect);
nativeSelect.addItem("Value 1");
// in #4103, the Select component was behaving differently from others
form.addField("Select", new Select("Select"));
Select select2 = new Select("Select 2");
select2.addItem("Value 1");
form.addField("Select 2", select2);
OptionGroup optionGroup = new OptionGroup("OptionGroup");
optionGroup.setMultiSelect(false);
optionGroup.addItem("Option 1");
optionGroup.addItem("Option 2");
form.addField("Option Group 1", optionGroup);
OptionGroup optionGroup2 = new OptionGroup("OptionGroup");
optionGroup2.setMultiSelect(true);
optionGroup2.addItem("Option 1");
optionGroup2.addItem("Option 2");
form.addField("Option Group 2", optionGroup2);
// TODO could add more different fields
return form;
}