AForm formAnnotation = formClass.getAnnotation(AForm.class);
if (formAnnotation == null) {
throw new RuntimeException("formClass is not annotated correctly..");
}
MessageSupport messages = MessageSupport.getMessages(formClass);
XFormDialogBuilder builder = XFormFactory.createDialogBuilder(messages.get(formAnnotation.name()));
XForm form = createForm(builder, null);
for (Field field : formClass.getFields()) {
AField fieldAnnotation = field.getAnnotation(AField.class);
if (fieldAnnotation != null) {
try {
addFormField(form, field, fieldAnnotation, messages);
} catch (Exception e) {
e.printStackTrace();
}
}
}
ActionList defaultActions = StringUtils.isBlank(formAnnotation.helpUrl()) ? null : builder.buildHelpActions(formAnnotation
.helpUrl());
if (actions == null) {
actions = defaultActions;
} else {
// since there is only one action do it like this
actions.insertAction(defaultActions.getActionAt(0), 0);
}
XFormDialog dialog = builder.buildDialog(actions, messages.get(formAnnotation.description()),
UISupport.createImageIcon(formAnnotation.icon()));
return dialog;
}