final SimpleForm form = new SimpleForm();
form.setEnabled(true);
final TextAreaItem name = new TextAreaItem("name", "Name", true);
final TextAreaItem address = new TextAreaItem("address", "Address", true);
final ComboBoxItem type = new ComboBoxItem("execType", "ExecType")
{
@Override
public boolean isRequired() {
return true;
}
};
type.setValueMap(new String[] {
FXModel.ExecutionType.CREATE.name(),
FXModel.ExecutionType.UPDATE.name(),
FXModel.ExecutionType.DELETE.name()
});
type.setDefaultToFirstOption(true);
type.selectItem(1);
final ListItem fieldNames = new ListItem("fieldNames", "FieldNames")
{
@Override
public boolean isRequired() {
return false;
}
};
form.setFields(name, address, type, fieldNames);
layout.add(form.asWidget());
DialogueOptions options = new DialogueOptions(
new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final FormValidation validation = form.validate();
ModelNode addressNode = new ModelNode();
try {
List<String[]> tuple = AddressBinding.parseAddressString(address.getValue());
addressNode = new AddressBinding(tuple).asResource().get("address");
} catch (Throwable e) {
validation.addError("Invalid address value");
address.setErroneous(true);
}
if(!validation.hasErrors())
{
FXTemplate template = new FXTemplate(
name.getValue(),
UUID.uuid()
);
FXModel model = new FXModel(
FXModel.ExecutionType.valueOf(type.getValue()),
addressNode
);
model.getFieldNames().addAll(fieldNames.getValue());