use of edu.stanford.bmir.protege.web.shared.form.field.FormElementDescriptor in project webprotege by protegeproject.
the class FormPresenter method createFormAndSetFormData.
/**
* Creates the form from scratch and fills in the specified form data.
*
* @param formDescriptor The descriptor that describes the form.
* @param formData The form data to be filled into the form.
*/
private void createFormAndSetFormData(@Nonnull FormDescriptor formDescriptor, @Nonnull FormData formData) {
formView.clear();
for (FormElementDescriptor elementDescriptor : formDescriptor.getElements()) {
Optional<FormDataValue> dataValue = formData.getFormElementData(elementDescriptor.getId());
createFormEditor(elementDescriptor, dataValue);
}
}
use of edu.stanford.bmir.protege.web.shared.form.field.FormElementDescriptor in project webprotege by protegeproject.
the class FormDescriptorDeserializer method deserialize.
@Override
public FormDescriptor deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
if (!jsonElement.isJsonObject()) {
throw createParseException(jsonElement, "Object");
}
JsonObject object = jsonElement.getAsJsonObject();
String id = object.getAsJsonPrimitive("id").getAsString();
JsonArray fieldsArray = object.getAsJsonArray("fields");
List<FormElementDescriptor> formElementDescriptors = new ArrayList<>();
for (JsonElement fieldElement : fieldsArray) {
FormElementDescriptor elementDescriptor = jsonDeserializationContext.deserialize(fieldElement, FormElementDescriptor.class);
formElementDescriptors.add(elementDescriptor);
}
return new FormDescriptor(new FormId(id), formElementDescriptors);
}
Aggregations