Search in sources :

Example 1 with SormasFieldGroupFieldFactory

use of de.symeda.sormas.ui.utils.SormasFieldGroupFieldFactory in project SORMAS-Project by hzi-braunschweig.

the class CampaignFormBuilder method createField.

@SuppressWarnings("unchecked")
private <T extends Field<?>> T createField(String fieldId, String caption, CampaignFormElementType type, List<CampaignFormElementStyle> styles) {
    SormasFieldGroupFieldFactory fieldFactory = new SormasFieldGroupFieldFactory(new FieldVisibilityCheckers(), UiFieldAccessCheckers.getNoop());
    T field;
    if (type == CampaignFormElementType.YES_NO) {
        field = fieldFactory.createField(Boolean.class, (Class<T>) NullableOptionGroup.class);
    } else if (type == CampaignFormElementType.TEXT || type == CampaignFormElementType.NUMBER) {
        field = fieldFactory.createField(String.class, (Class<T>) TextField.class);
    } else {
        field = null;
    }
    prepareComponent((AbstractComponent) field, fieldId, caption, type, styles);
    return field;
}
Also used : SormasFieldGroupFieldFactory(de.symeda.sormas.ui.utils.SormasFieldGroupFieldFactory) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) TextField(com.vaadin.v7.ui.TextField)

Example 2 with SormasFieldGroupFieldFactory

use of de.symeda.sormas.ui.utils.SormasFieldGroupFieldFactory in project SORMAS-Project by hzi-braunschweig.

the class DEAFormBuilder method buildForm.

public void buildForm() {
    SormasFieldGroupFieldFactory fieldFactory = new SormasFieldGroupFieldFactory(new FieldVisibilityCheckers(), UiFieldAccessCheckers.getNoop());
    for (DeaContentEntry deaContentEntry : deaContentEntries) {
        final TextField textField = fieldFactory.createField(String.class, TextField.class);
        textField.setWidthFull();
        final String caption = deaContentEntry.getCaption();
        textField.setId(caption);
        CssStyles.style(textField, CssStyles.TEXTFIELD_ROW);
        textField.setCaption(caption);
        if (!isCreate) {
            textField.setValue(deaContentEntry.getValue());
        }
        gridLayout.addComponent(textField);
        fields.add(textField);
    }
}
Also used : SormasFieldGroupFieldFactory(de.symeda.sormas.ui.utils.SormasFieldGroupFieldFactory) DeaContentEntry(de.symeda.sormas.api.travelentry.DeaContentEntry) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) TextField(com.vaadin.v7.ui.TextField)

Aggregations

TextField (com.vaadin.v7.ui.TextField)2 FieldVisibilityCheckers (de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers)2 SormasFieldGroupFieldFactory (de.symeda.sormas.ui.utils.SormasFieldGroupFieldFactory)2 DeaContentEntry (de.symeda.sormas.api.travelentry.DeaContentEntry)1