String description = messages.get(fieldAnnotation.description());
String[] values = messages.getArray(fieldAnnotation.values());
String defaultValue = messages.get(fieldAnnotation.defaultValue());
boolean enabled = fieldAnnotation.enabled();
XFormField field = null;
switch (type) {
case STRING:
field = form.addTextField(name, description, FieldType.TEXT);
break;
case INT:
field = form.addTextField(name, description, FieldType.TEXT);
((XFormTextField) field).setWidth(10);
break;
case STRINGAREA:
field = form.addTextField(name, description, FieldType.TEXTAREA);
break;
case BOOLEAN:
field = form.addCheckBox(name, description);
break;
case FILE:
field = form.addTextField(name, description, FieldType.FILE);
break;
case FOLDER:
field = form.addTextField(name, description, FieldType.FOLDER);
break;
case FILE_OR_FOLDER:
field = form.addTextField(name, description, FieldType.FILE_OR_FOLDER);
break;
case ENUMERATION:
field = form.addComboBox(name, values, description);
break;
case RADIOGROUP:
field = form.addComponent(name, new XFormRadioGroup(values));
break;
case MULTILIST:
field = form.addComponent(name, new XFormMultiSelectList(values));
break;
case STRINGLIST:
field = form.addComponent(name, new JStringListFormField(description, defaultValue));
break;
case TABLE:
field = form.addComponent(name, new JTableFormField(description));
break;
case ACTION:
field = form.addComponent(name, new ActionFormFieldComponent(name, description));
break;
case COMPONENT:
field = form.addComponent(name, new JComponentFormField(name, description));
break;
case PASSWORD:
field = form.addComponent(name, new JPasswordFieldFormField());
break;
case INFORMATION:
field = form.addComponent(name, new JMultilineLabelTextField());
break;
case LABEL:
field = form.addComponent(name, new JLabelFormField(description));
break;
case SEPARATOR:
form.addSeparator(description);
break;
case RADIOGROUP_TOP_BUTTON:
field = form.addComponent(name, new XFormRadioGroupTopButtonPosition(values));
break;
case COMBOBOX:
field = form.addComboBox(name, values, description);
break;
default:
System.out.println("Unsupported field type: " + type);
}
if (field != null) {
field.setEnabled(enabled);
}
}