Search in sources :

Example 1 with NumberNumericValueValidator

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

the class CampaignFormBuilder method prepareComponent.

private <T extends AbstractComponent> void prepareComponent(T field, String fieldId, String caption, CampaignFormElementType type, List<CampaignFormElementStyle> styles) {
    Styles cssStyles = Page.getCurrent().getStyles();
    if (type == CampaignFormElementType.LABEL) {
        ((Label) field).setContentMode(ContentMode.HTML);
    } else if (type == CampaignFormElementType.YES_NO) {
        if (!styles.contains(CampaignFormElementStyle.INLINE)) {
            CssStyles.style(field, ValoTheme.OPTIONGROUP_HORIZONTAL, CssStyles.OPTIONGROUP_CAPTION_INLINE, CssStyles.FLOAT_RIGHT);
        }
        CssStyles.style(field, CssStyles.OPTIONGROUP_GRID_LAYOUT);
    } else if (type == CampaignFormElementType.TEXT || type == CampaignFormElementType.NUMBER) {
        if (styles.contains(CampaignFormElementStyle.ROW)) {
            CssStyles.style(field, CssStyles.TEXTFIELD_ROW, CssStyles.TEXTFIELD_CAPTION_INLINE);
        }
        if (type == CampaignFormElementType.NUMBER) {
            ((TextField) field).addValidator(new NumberNumericValueValidator(I18nProperties.getValidationError(Validations.onlyNumbersAllowed, caption)));
        }
    }
    cssStyles.add("#" + fieldId + " { width: " + calculateComponentWidth(type, styles) + "% !important; }");
}
Also used : NumberNumericValueValidator(de.symeda.sormas.ui.utils.NumberNumericValueValidator) Label(com.vaadin.v7.ui.Label) TextField(com.vaadin.v7.ui.TextField) CssStyles(de.symeda.sormas.ui.utils.CssStyles) Styles(com.vaadin.server.Page.Styles)

Aggregations

Styles (com.vaadin.server.Page.Styles)1 Label (com.vaadin.v7.ui.Label)1 TextField (com.vaadin.v7.ui.TextField)1 CssStyles (de.symeda.sormas.ui.utils.CssStyles)1 NumberNumericValueValidator (de.symeda.sormas.ui.utils.NumberNumericValueValidator)1