use of org.activityinfo.ui.client.component.form.field.attachment.AttachmentUploadFieldWidget in project activityinfo by bedatadriven.
the class FormFieldWidgetFactory method createWidget.
public Promise<? extends FormFieldWidget> createWidget(FormClass formClass, FormField field, FieldUpdater valueUpdater) {
FieldType type = field.getType();
if (type instanceof QuantityType) {
return Promise.resolved(new QuantityFieldWidget((QuantityType) type, valueUpdater));
} else if (type instanceof SerialNumberType) {
return Promise.resolved(new SerialNumberFieldWidget((SerialNumberType) type));
} else if (type instanceof NarrativeType) {
return Promise.resolved(new NarrativeFieldWidget(valueUpdater));
} else if (type instanceof TextType) {
return Promise.resolved(new TextFieldWidget((TextType) type, valueUpdater));
} else if (type instanceof CalculatedFieldType) {
return Promise.resolved(new CalculatedFieldWidget(valueUpdater));
} else if (type instanceof LocalDateType) {
return Promise.resolved(new DateFieldWidget(valueUpdater));
} else if (type instanceof LocalDateIntervalType) {
return Promise.resolved(new DateIntervalFieldWidget(valueUpdater));
} else if (type instanceof GeoPointType) {
return Promise.resolved(new GeographicPointWidget(valueUpdater));
} else if (type instanceof EnumType) {
return Promise.resolved(new EnumFieldWidget((EnumType) field.getType(), valueUpdater, fieldWidgetMode));
} else if (type instanceof BooleanType) {
return Promise.resolved(new BooleanFieldWidget(valueUpdater));
} else if (type instanceof AttachmentType) {
AttachmentType attachmentType = (AttachmentType) type;
if (attachmentType.getKind() == AttachmentType.Kind.IMAGE) {
return Promise.resolved(new ImageUploadFieldWidget(formClass.getId(), valueUpdater, fieldWidgetMode));
} else {
return Promise.resolved(new AttachmentUploadFieldWidget(formClass.getId(), valueUpdater, fieldWidgetMode));
}
} else if (type instanceof ReferenceType) {
return createReferenceWidget(field, valueUpdater);
} else if (type instanceof BarcodeType) {
return Promise.resolved(new BarcodeFieldWidget(valueUpdater));
}
Log.error("Unexpected field type " + type.getTypeClass());
throw new UnsupportedOperationException();
}
Aggregations