Search in sources :

Example 1 with StringToIntegerConverter

use of com.vaadin.data.converter.StringToIntegerConverter in project SORMAS-Project by hzi-braunschweig.

the class DevModeView method createContactGeneratorLayout.

private VerticalLayout createContactGeneratorLayout() {
    VerticalLayout contactGeneratorLayout = new VerticalLayout();
    contactGeneratorLayout.setMargin(false);
    contactGeneratorLayout.setSpacing(false);
    Label heading = new Label(I18nProperties.getString(Strings.headingGenerateContacts));
    CssStyles.style(heading, CssStyles.H2);
    contactGeneratorLayout.addComponent(heading);
    HorizontalLayout contactOptionsFirstLineLayout = new HorizontalLayout();
    TextField contactCountField = new TextField();
    contactCountField.setCaption(I18nProperties.getCaption(Captions.devModeContactCount));
    contactGeneratorConfigBinder.forField(contactCountField).withConverter(new StringToIntegerConverter("Must be a number")).bind(ContactGenerationConfig::getContactCount, ContactGenerationConfig::setContactCount);
    contactOptionsFirstLineLayout.addComponent(contactCountField);
    DateField startDateField = new DateField();
    startDateField.setCaption(I18nProperties.getCaption(Captions.devModeContactStartDate));
    startDateField.setDateFormat(DateFormatHelper.getDateFormatPattern());
    startDateField.setLenient(true);
    contactGeneratorConfigBinder.bind(startDateField, ContactGenerationConfig::getStartDate, ContactGenerationConfig::setStartDate);
    contactOptionsFirstLineLayout.addComponent(startDateField);
    DateField endDateField = new DateField();
    endDateField.setCaption(I18nProperties.getCaption(Captions.devModeContactEndDate));
    endDateField.setDateFormat(DateFormatHelper.getDateFormatPattern());
    endDateField.setLenient(true);
    contactGeneratorConfigBinder.bind(endDateField, ContactGenerationConfig::getEndDate, ContactGenerationConfig::setEndDate);
    contactOptionsFirstLineLayout.addComponent(endDateField);
    ComboBox<Disease> diseaseField = new ComboBox<>(null, FacadeProvider.getDiseaseConfigurationFacade().getAllDiseases(true, true, true));
    diseaseField.setCaption(I18nProperties.getCaption(Captions.devModeContactDisease));
    contactGeneratorConfigBinder.bind(diseaseField, ContactGenerationConfig::getDisease, ContactGenerationConfig::setDisease);
    contactOptionsFirstLineLayout.addComponent(diseaseField);
    List<RegionReferenceDto> regions = FacadeProvider.getRegionFacade().getAllActiveByServerCountry();
    ComboBox<RegionReferenceDto> regionField = new ComboBox<RegionReferenceDto>(null, regions);
    regionField.setCaption(I18nProperties.getCaption(Captions.devModeContactRegion));
    contactGeneratorConfigBinder.bind(regionField, ContactGenerationConfig::getRegion, ContactGenerationConfig::setRegion);
    contactOptionsFirstLineLayout.addComponent(regionField);
    ComboBox<DistrictReferenceDto> districtField = new ComboBox<DistrictReferenceDto>();
    districtField.setCaption(I18nProperties.getCaption(Captions.devModeContactDistrict));
    contactGeneratorConfigBinder.bind(districtField, ContactGenerationConfig::getDistrict, ContactGenerationConfig::setDistrict);
    contactOptionsFirstLineLayout.addComponent(districtField);
    regionField.addValueChangeListener(event -> {
        RegionReferenceDto region = event.getValue();
        if (region != null) {
            districtField.setItems(FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
        } else {
            districtField.setItems(new ArrayList<DistrictReferenceDto>());
        }
    });
    Button generateButton = ButtonHelper.createButton(Captions.devModeGenerateContacts, e -> generateContacts(), CssStyles.FORCE_CAPTION);
    contactOptionsFirstLineLayout.addComponent(generateButton);
    contactGeneratorLayout.addComponent(contactOptionsFirstLineLayout);
    HorizontalLayout contactOptionsSecondLineLayout = new HorizontalLayout();
    CheckBox createWithoutSourceCasesField = new CheckBox(I18nProperties.getCaption(Captions.devModeContactCreateWithoutSourceCases));
    contactGeneratorConfigBinder.bind(createWithoutSourceCasesField, ContactGenerationConfig::isCreateWithoutSourceCases, ContactGenerationConfig::setCreateWithoutSourceCases);
    contactOptionsSecondLineLayout.addComponent(createWithoutSourceCasesField);
    CheckBox createMultipleContactsPerPersonField = new CheckBox(I18nProperties.getCaption(Captions.devModeContactCreateMultipleContactsPerPerson));
    contactGeneratorConfigBinder.bind(createMultipleContactsPerPersonField, ContactGenerationConfig::isCreateMultipleContactsPerPerson, ContactGenerationConfig::setCreateMultipleContactsPerPerson);
    contactOptionsSecondLineLayout.addComponent(createMultipleContactsPerPersonField);
    CheckBox createWithVisitsField = new CheckBox(I18nProperties.getCaption(Captions.devModeContactCreateWithVisits));
    contactGeneratorConfigBinder.bind(createWithVisitsField, ContactGenerationConfig::isCreateWithVisits, ContactGenerationConfig::setCreateWithVisits);
    contactOptionsSecondLineLayout.addComponent(createWithVisitsField);
    contactGeneratorLayout.addComponent(contactOptionsSecondLineLayout);
    contactGenerationConfig.setRegion(regions.get(0));
    contactGeneratorConfigBinder.setBean(contactGenerationConfig);
    return contactGeneratorLayout;
}
Also used : Disease(de.symeda.sormas.api.Disease) ComboBox(com.vaadin.ui.ComboBox) Label(com.vaadin.ui.Label) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) HorizontalLayout(com.vaadin.ui.HorizontalLayout) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) Button(com.vaadin.ui.Button) CheckBox(com.vaadin.ui.CheckBox) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField) StringToIntegerConverter(com.vaadin.data.converter.StringToIntegerConverter) DateField(com.vaadin.ui.DateField)

Example 2 with StringToIntegerConverter

use of com.vaadin.data.converter.StringToIntegerConverter in project SORMAS-Project by hzi-braunschweig.

the class DevModeView method createSamplesGeneratorLayout.

private VerticalLayout createSamplesGeneratorLayout() {
    VerticalLayout sampleGeneratorLayout = new VerticalLayout();
    sampleGeneratorLayout.setMargin(false);
    sampleGeneratorLayout.setSpacing(false);
    Label heading = new Label(I18nProperties.getCaption(Captions.devModeGenerateSamples));
    CssStyles.style(heading, CssStyles.H2);
    sampleGeneratorLayout.addComponent(heading);
    HorizontalLayout sampleOptionsFirstLineLayout = new HorizontalLayout();
    TextField sampleCountField = new TextField();
    sampleCountField.setCaption(I18nProperties.getCaption(Captions.devModeSampleCount));
    sampleGeneratorConfigBinder.forField(sampleCountField).withConverter(new StringToIntegerConverter("Must be a number")).bind(SampleGenerationConfig::getSampleCount, SampleGenerationConfig::setSampleCount);
    sampleOptionsFirstLineLayout.addComponent(sampleCountField);
    DateField startDateField = new DateField();
    startDateField.setCaption(I18nProperties.getCaption(Captions.devModeSampleStartDate));
    startDateField.setDateFormat(DateFormatHelper.getDateFormatPattern());
    startDateField.setLenient(true);
    sampleGeneratorConfigBinder.bind(startDateField, SampleGenerationConfig::getStartDate, SampleGenerationConfig::setStartDate);
    sampleOptionsFirstLineLayout.addComponent(startDateField);
    DateField endDateField = new DateField();
    endDateField.setCaption(I18nProperties.getCaption(Captions.devModeSampleEndDate));
    endDateField.setDateFormat(DateFormatHelper.getDateFormatPattern());
    endDateField.setLenient(true);
    sampleGeneratorConfigBinder.bind(endDateField, SampleGenerationConfig::getEndDate, SampleGenerationConfig::setEndDate);
    sampleOptionsFirstLineLayout.addComponent(endDateField);
    ComboBox<Disease> diseaseField = new ComboBox<>(null, FacadeProvider.getDiseaseConfigurationFacade().getAllDiseases(true, true, true));
    diseaseField.setCaption(I18nProperties.getCaption(Captions.devModeSampleDisease));
    sampleGeneratorConfigBinder.bind(diseaseField, SampleGenerationConfig::getDisease, SampleGenerationConfig::setDisease);
    diseaseField.setRequiredIndicatorVisible(true);
    sampleOptionsFirstLineLayout.addComponent(diseaseField);
    List<RegionReferenceDto> regions = FacadeProvider.getRegionFacade().getAllActiveByServerCountry();
    ComboBox<RegionReferenceDto> regionField = new ComboBox<>(null, regions);
    regionField.setCaption(I18nProperties.getCaption(Captions.devModeSampleRegion));
    sampleGeneratorConfigBinder.bind(regionField, SampleGenerationConfig::getRegion, SampleGenerationConfig::setRegion);
    sampleOptionsFirstLineLayout.addComponent(regionField);
    ComboBox<DistrictReferenceDto> districtField = new ComboBox<>();
    districtField.setCaption(I18nProperties.getCaption(Captions.devModeSampleDistrict));
    sampleGeneratorConfigBinder.bind(districtField, SampleGenerationConfig::getDistrict, SampleGenerationConfig::setDistrict);
    sampleOptionsFirstLineLayout.addComponent(districtField);
    regionField.addValueChangeListener(event -> {
        RegionReferenceDto region = event.getValue();
        if (region != null) {
            districtField.setItems(FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
        } else {
            districtField.setItems(new ArrayList<DistrictReferenceDto>());
        }
    });
    Button generateButton = ButtonHelper.createButton(I18nProperties.getCaption(Captions.devModeGenerateSamples), e -> generateSamples(), CssStyles.FORCE_CAPTION);
    sampleOptionsFirstLineLayout.addComponent(generateButton);
    sampleGeneratorLayout.addComponent(sampleOptionsFirstLineLayout);
    HorizontalLayout sampleOptionsSecondLineLayout = new HorizontalLayout();
    ComboBox<SampleMaterial> sampleMaterial = new ComboBox(null, Arrays.asList(SampleMaterial.values()));
    sampleMaterial.setCaption(I18nProperties.getCaption(Captions.devModeSampleMaterial));
    sampleGeneratorConfigBinder.bind(sampleMaterial, SampleGenerationConfig::getSampleMaterial, SampleGenerationConfig::setSampleMaterial);
    sampleMaterial.setRequiredIndicatorVisible(true);
    sampleOptionsSecondLineLayout.addComponent(sampleMaterial);
    ComboBox<FacilityReferenceDto> laboratory = new ComboBox(null, FacadeProvider.getFacilityFacade().getAllActiveLaboratories(true));
    laboratory.setCaption(I18nProperties.getCaption(Captions.devModeSampleLaboratory));
    sampleGeneratorConfigBinder.bind(laboratory, SampleGenerationConfig::getLaboratory, SampleGenerationConfig::setLaboratory);
    laboratory.setRequiredIndicatorVisible(true);
    sampleOptionsSecondLineLayout.addComponent(laboratory);
    sampleGeneratorLayout.addComponent(sampleOptionsSecondLineLayout);
    HorizontalLayout sampleOptionsThirdLineLayout = new HorizontalLayout();
    CheckBox externalLabTesting = new CheckBox(I18nProperties.getCaption(Captions.devModeSampleExternalLabTesting));
    sampleGeneratorConfigBinder.bind(externalLabTesting, SampleGenerationConfig::isExternalLabOrInternalInHouseTesting, SampleGenerationConfig::setExternalLabOrInternalInHouseTesting);
    externalLabTesting.setValue(true);
    sampleOptionsThirdLineLayout.addComponent(externalLabTesting);
    CheckBox requestPathogenTestsToBePerformed = new CheckBox(I18nProperties.getCaption(Captions.devModeSamplePathogenTestsToBePerformed));
    sampleGeneratorConfigBinder.bind(requestPathogenTestsToBePerformed, SampleGenerationConfig::isRequestPathogenTestsToBePerformed, SampleGenerationConfig::setRequestPathogenTestsToBePerformed);
    sampleOptionsThirdLineLayout.addComponent(requestPathogenTestsToBePerformed);
    CheckBox requestAdditionalTestsToBePerformed = new CheckBox(I18nProperties.getCaption(Captions.devModeSampleAdditionalTestsToBePerformed));
    sampleGeneratorConfigBinder.bind(requestAdditionalTestsToBePerformed, SampleGenerationConfig::isRequestAdditionalTestsToBePerformed, SampleGenerationConfig::setRequestAdditionalTestsToBePerformed);
    sampleOptionsThirdLineLayout.addComponent(requestAdditionalTestsToBePerformed);
    CheckBox sendDispatch = new CheckBox(I18nProperties.getCaption(Captions.devModeSampleSendDispatch));
    sampleGeneratorConfigBinder.bind(sendDispatch, SampleGenerationConfig::isSendDispatch, SampleGenerationConfig::setSendDispatch);
    sampleOptionsThirdLineLayout.addComponent(sendDispatch);
    CheckBox received = new CheckBox(I18nProperties.getCaption(Captions.devModeSampleReceived));
    sampleGeneratorConfigBinder.bind(received, SampleGenerationConfig::isReceived, SampleGenerationConfig::setReceived);
    sampleOptionsThirdLineLayout.addComponent(received);
    externalLabTesting.addValueChangeListener(event -> {
        if (externalLabTesting.getValue()) {
            requestPathogenTestsToBePerformed.setVisible(true);
            sendDispatch.setVisible(true);
            received.setVisible(true);
            laboratory.setVisible(true);
            sampleGenerationConfig.setSamplePurpose(SamplePurpose.EXTERNAL);
        } else {
            requestPathogenTestsToBePerformed.setVisible(false);
            sendDispatch.setVisible(false);
            received.setVisible(false);
            laboratory.setVisible(false);
            sampleGenerationConfig.setSamplePurpose(SamplePurpose.INTERNAL);
        }
    });
    sampleGeneratorLayout.addComponent(sampleOptionsThirdLineLayout);
    sampleGenerationConfig.setRegion(regions.get(0));
    sampleGenerationConfig.setDistrict(FacadeProvider.getDistrictFacade().getAllActiveByRegion(sampleGenerationConfig.getRegion().getUuid()).get(0));
    sampleGeneratorConfigBinder.setBean(sampleGenerationConfig);
    return sampleGeneratorLayout;
}
Also used : Disease(de.symeda.sormas.api.Disease) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) ComboBox(com.vaadin.ui.ComboBox) Label(com.vaadin.ui.Label) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) HorizontalLayout(com.vaadin.ui.HorizontalLayout) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) Button(com.vaadin.ui.Button) CheckBox(com.vaadin.ui.CheckBox) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField) SampleMaterial(de.symeda.sormas.api.sample.SampleMaterial) StringToIntegerConverter(com.vaadin.data.converter.StringToIntegerConverter) DateField(com.vaadin.ui.DateField)

Example 3 with StringToIntegerConverter

use of com.vaadin.data.converter.StringToIntegerConverter in project SORMAS-Project by hzi-braunschweig.

the class DevModeView method createCaseGeneratorLayout.

private VerticalLayout createCaseGeneratorLayout() {
    VerticalLayout caseGeneratorLayout = new VerticalLayout();
    caseGeneratorLayout.setMargin(false);
    caseGeneratorLayout.setSpacing(false);
    Label heading = new Label(I18nProperties.getString(Strings.headingGenerateCases));
    CssStyles.style(heading, CssStyles.H2);
    caseGeneratorLayout.addComponent(heading);
    HorizontalLayout caseOptionsLayout = new HorizontalLayout();
    TextField caseCountField = new TextField();
    caseCountField.setCaption(I18nProperties.getCaption(Captions.devModeCaseCount));
    caseGeneratorConfigBinder.forField(caseCountField).withConverter(new StringToIntegerConverter("Must be a number")).bind(CaseGenerationConfig::getCaseCount, CaseGenerationConfig::setCaseCount);
    caseOptionsLayout.addComponent(caseCountField);
    DateField startDateField = new DateField();
    startDateField.setCaption(I18nProperties.getCaption(Captions.devModeCaseStartDate));
    startDateField.setDateFormat(DateFormatHelper.getDateFormatPattern());
    startDateField.setLenient(true);
    caseGeneratorConfigBinder.bind(startDateField, CaseGenerationConfig::getStartDate, CaseGenerationConfig::setStartDate);
    caseOptionsLayout.addComponent(startDateField);
    DateField endDateField = new DateField();
    endDateField.setCaption(I18nProperties.getCaption(Captions.devModeCaseEndDate));
    endDateField.setDateFormat(DateFormatHelper.getDateFormatPattern());
    endDateField.setLenient(true);
    caseGeneratorConfigBinder.bind(endDateField, CaseGenerationConfig::getEndDate, CaseGenerationConfig::setEndDate);
    caseOptionsLayout.addComponent(endDateField);
    ComboBox<Disease> diseaseField = new ComboBox<>(null, FacadeProvider.getDiseaseConfigurationFacade().getAllDiseases(true, true, true));
    diseaseField.setCaption(I18nProperties.getCaption(Captions.devModeCaseDisease));
    caseGeneratorConfigBinder.bind(diseaseField, CaseGenerationConfig::getDisease, CaseGenerationConfig::setDisease);
    caseOptionsLayout.addComponent(diseaseField);
    List<RegionReferenceDto> regions = FacadeProvider.getRegionFacade().getAllActiveByServerCountry();
    ComboBox<RegionReferenceDto> regionField = new ComboBox<RegionReferenceDto>(null, regions);
    regionField.setCaption(I18nProperties.getCaption(Captions.devModeCaseRegion));
    caseGeneratorConfigBinder.bind(regionField, CaseGenerationConfig::getRegion, CaseGenerationConfig::setRegion);
    caseOptionsLayout.addComponent(regionField);
    ComboBox<DistrictReferenceDto> districtField = new ComboBox<DistrictReferenceDto>();
    districtField.setCaption(I18nProperties.getCaption(Captions.devModeCaseDistrict));
    caseGeneratorConfigBinder.bind(districtField, CaseGenerationConfig::getDistrict, CaseGenerationConfig::setDistrict);
    caseOptionsLayout.addComponent(districtField);
    regionField.addValueChangeListener(event -> {
        RegionReferenceDto region = event.getValue();
        if (region != null) {
            districtField.setItems(FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
        } else {
            districtField.setItems(new ArrayList<DistrictReferenceDto>());
        }
    });
    Button generateButton = ButtonHelper.createButton(Captions.devModeGenerateCases, e -> generateCases(), CssStyles.FORCE_CAPTION);
    caseOptionsLayout.addComponent(generateButton);
    caseGeneratorLayout.addComponent(caseOptionsLayout);
    caseGenerationConfig.setRegion(regions.get(0));
    caseGeneratorConfigBinder.setBean(caseGenerationConfig);
    return caseGeneratorLayout;
}
Also used : Disease(de.symeda.sormas.api.Disease) ComboBox(com.vaadin.ui.ComboBox) Label(com.vaadin.ui.Label) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) HorizontalLayout(com.vaadin.ui.HorizontalLayout) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField) StringToIntegerConverter(com.vaadin.data.converter.StringToIntegerConverter) DateField(com.vaadin.ui.DateField)

Example 4 with StringToIntegerConverter

use of com.vaadin.data.converter.StringToIntegerConverter in project unity by unity-idm.

the class OTPWithLDAPAuthenticatorEditor method buildServersConnectionConfigurationSection.

private CollapsibleLayout buildServersConnectionConfigurationSection() {
    FormLayoutWithFixedCaptionWidth serverConnectionLayout = new FormLayoutWithFixedCaptionWidth();
    serverConnectionLayout.setMargin(false);
    GridWithEditor<ServerSpecification> serverConfig = new GridWithEditor<>(msg, ServerSpecification.class);
    serverConnectionLayout.addComponent(serverConfig);
    serverConfig.addTextColumn(s -> s.getServer(), (t, v) -> t.setServer(v), msg.getMessage("LdapAuthenticatorEditor.server"), 40, true);
    serverConfig.addIntColumn(s -> s.getPort(), (t, v) -> t.setPort(v), msg.getMessage("LdapAuthenticatorEditor.port"), 10, Optional.of(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 1, 65535)));
    serverConfig.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
    configBinder.forField(serverConfig).withValidator((v, c) -> {
        if (v == null || v.isEmpty()) {
            return ValidationResult.error(msg.getMessage("fieldRequired"));
        } else {
            return ValidationResult.ok();
        }
    }).bind("servers");
    ComboBox<ConnectionMode> connectionMode = new ComboBox<>(msg.getMessage("LdapAuthenticatorEditor.connectionMode"));
    connectionMode.setItems(ConnectionMode.values());
    connectionMode.setEmptySelectionAllowed(false);
    configBinder.forField(connectionMode).bind("connectionMode");
    serverConnectionLayout.addComponent(connectionMode);
    TextField followReferrals = new TextField(msg.getMessage("LdapAuthenticatorEditor.followReferrals"));
    configBinder.forField(followReferrals).asRequired(msg.getMessage("notAPositiveNumber")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("followReferrals");
    serverConnectionLayout.addComponent(followReferrals);
    TextField searchTimeLimit = new TextField(msg.getMessage("LdapAuthenticatorEditor.searchTimeLimit"));
    configBinder.forField(searchTimeLimit).asRequired(msg.getMessage("notAPositiveNumber")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("searchTimeLimit");
    serverConnectionLayout.addComponent(searchTimeLimit);
    TextField socketTimeout = new TextField(msg.getMessage("LdapAuthenticatorEditor.socketTimeout"));
    configBinder.forField(socketTimeout).asRequired(msg.getMessage("notAPositiveNumber")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("socketTimeout");
    serverConnectionLayout.addComponent(socketTimeout);
    CheckBox trustAllCerts = new CheckBox(msg.getMessage("LdapAuthenticatorEditor.trustAllCerts"));
    configBinder.forField(trustAllCerts).bind("trustAllCerts");
    serverConnectionLayout.addComponent(trustAllCerts);
    ComboBox<String> clientTrustStore = new ComboBox<>(msg.getMessage("LdapAuthenticatorEditor.clientTrustStore"));
    clientTrustStore.setItems(validators);
    configBinder.forField(clientTrustStore).bind("clientTrustStore");
    serverConnectionLayout.addComponent(clientTrustStore);
    trustAllCerts.addValueChangeListener(e -> {
        clientTrustStore.setEnabled(!e.getValue());
    });
    TextField resultEntriesLimit = new TextField(msg.getMessage("LdapAuthenticatorEditor.resultEntriesLimit"));
    configBinder.forField(resultEntriesLimit).asRequired(msg.getMessage("notAPositiveNumber")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("resultEntriesLimit");
    serverConnectionLayout.addComponent(resultEntriesLimit);
    return new CollapsibleLayout(msg.getMessage("OTPWithLDAPAuthenticatorEditor.serverConnectionConfiguration"), serverConnectionLayout);
}
Also used : IntegerRangeValidator(com.vaadin.data.validator.IntegerRangeValidator) FieldSizeConstans(pl.edu.icm.unity.webui.common.FieldSizeConstans) TextField(com.vaadin.ui.TextField) PrototypeComponent(pl.edu.icm.unity.engine.api.utils.PrototypeComponent) VerticalLayout(com.vaadin.ui.VerticalLayout) ComboBox(com.vaadin.ui.ComboBox) Autowired(org.springframework.beans.factory.annotation.Autowired) ServerSpecification(pl.edu.icm.unity.ldap.client.config.ServerSpecification) ValidationResult(com.vaadin.data.ValidationResult) PKIManagement(pl.edu.icm.unity.engine.api.PKIManagement) Validator(com.vaadin.data.Validator) CheckBox(com.vaadin.ui.CheckBox) UserDNResolving(pl.edu.icm.unity.ldap.client.config.common.LDAPCommonConfiguration.UserDNResolving) AuthenticatorDefinition(pl.edu.icm.unity.types.authn.AuthenticatorDefinition) LDAPException(com.unboundid.ldap.sdk.LDAPException) SearchSpecification(pl.edu.icm.unity.ldap.client.config.SearchSpecification) MessageSource(pl.edu.icm.unity.MessageSource) IntegerRangeValidator(com.vaadin.data.validator.IntegerRangeValidator) CollapsibleLayout(pl.edu.icm.unity.webui.common.CollapsibleLayout) TooltipExtension.tooltip(io.imunity.tooltip.TooltipExtension.tooltip) GridWithEditor(pl.edu.icm.unity.webui.common.GridWithEditor) Set(java.util.Set) EnumComboBox(pl.edu.icm.unity.webui.common.EnumComboBox) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) SearchScope(pl.edu.icm.unity.ldap.client.config.common.LDAPConnectionProperties.SearchScope) Binder(com.vaadin.data.Binder) HashFunction(io.imunity.otp.HashFunction) EngineException(pl.edu.icm.unity.exceptions.EngineException) ObjectFactory(org.springframework.beans.factory.ObjectFactory) SubViewSwitcher(pl.edu.icm.unity.webui.common.webElements.SubViewSwitcher) AuthenticatorEditor(pl.edu.icm.unity.webui.authn.authenticators.AuthenticatorEditor) AuthenticatorEditorFactory(pl.edu.icm.unity.webui.authn.authenticators.AuthenticatorEditorFactory) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) ConnectionMode(pl.edu.icm.unity.ldap.client.config.common.LDAPConnectionProperties.ConnectionMode) BaseAuthenticatorEditor(pl.edu.icm.unity.webui.authn.authenticators.BaseAuthenticatorEditor) RadioButtonGroup(com.vaadin.ui.RadioButtonGroup) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException) Optional(java.util.Optional) StringToIntegerConverter(com.vaadin.data.converter.StringToIntegerConverter) Filter(com.unboundid.ldap.sdk.Filter) Unit(com.vaadin.server.Sizeable.Unit) IntStepper(org.vaadin.risto.stepper.IntStepper) Component(com.vaadin.ui.Component) CollapsibleLayout(pl.edu.icm.unity.webui.common.CollapsibleLayout) ComboBox(com.vaadin.ui.ComboBox) EnumComboBox(pl.edu.icm.unity.webui.common.EnumComboBox) ServerSpecification(pl.edu.icm.unity.ldap.client.config.ServerSpecification) GridWithEditor(pl.edu.icm.unity.webui.common.GridWithEditor) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) CheckBox(com.vaadin.ui.CheckBox) ConnectionMode(pl.edu.icm.unity.ldap.client.config.common.LDAPConnectionProperties.ConnectionMode) TextField(com.vaadin.ui.TextField) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) StringToIntegerConverter(com.vaadin.data.converter.StringToIntegerConverter)

Example 5 with StringToIntegerConverter

use of com.vaadin.data.converter.StringToIntegerConverter in project unity by unity-idm.

the class EmailConfirmationConfigurationEditor method initUI.

private void initUI() {
    binder = new Binder<>(EmailConfirmationConfiguration.class);
    msgTemplate = new CompatibleTemplatesComboBox(EmailConfirmationTemplateDef.NAME, msgTemplateMan);
    msgTemplate.setCaption(msg.getMessage("EmailConfirmationConfiguration.confirmationMsgTemplate"));
    msgTemplate.setDescription(msg.getMessage("EmailConfirmationConfiguration.confirmationMsgTemplateDesc"));
    msgTemplate.setEmptySelectionAllowed(true);
    validityTime = new TextField(msg.getMessage("EmailConfirmationConfiguration.validityTime"));
    addFieldToLayout(this);
    binder.forField(msgTemplate).bind("messageTemplate");
    binder.forField(validityTime).asRequired(msg.getMessage("fieldRequired")).withConverter(new StringToIntegerConverter(msg.getMessage("notAnIntNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("outOfBoundsNumber", 1, 60 * 24 * 365), 1, 60 * 24 * 365)).bind("validityTime");
    if (initial != null) {
        binder.setBean(initial);
    } else {
        EmailConfirmationConfiguration init = new EmailConfirmationConfiguration();
        init.setMessageTemplate(msgTemplate.getValue());
        init.setValidityTime(EmailConfirmationConfiguration.DEFAULT_VALIDITY);
        binder.setBean(init);
    }
}
Also used : IntegerRangeValidator(com.vaadin.data.validator.IntegerRangeValidator) TextField(com.vaadin.ui.TextField) StringToIntegerConverter(com.vaadin.data.converter.StringToIntegerConverter) EmailConfirmationConfiguration(pl.edu.icm.unity.types.confirmation.EmailConfirmationConfiguration) CompatibleTemplatesComboBox(pl.edu.icm.unity.webui.common.CompatibleTemplatesComboBox)

Aggregations

StringToIntegerConverter (com.vaadin.data.converter.StringToIntegerConverter)17 TextField (com.vaadin.ui.TextField)16 IntegerRangeValidator (com.vaadin.data.validator.IntegerRangeValidator)11 ComboBox (com.vaadin.ui.ComboBox)11 CheckBox (com.vaadin.ui.CheckBox)10 VerticalLayout (com.vaadin.ui.VerticalLayout)10 FormLayoutWithFixedCaptionWidth (pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth)7 HorizontalLayout (com.vaadin.ui.HorizontalLayout)6 Label (com.vaadin.ui.Label)6 CollapsibleLayout (pl.edu.icm.unity.webui.common.CollapsibleLayout)6 Button (com.vaadin.ui.Button)5 MessageSource (pl.edu.icm.unity.MessageSource)5 Binder (com.vaadin.data.Binder)4 ValidationResult (com.vaadin.data.ValidationResult)4 DateField (com.vaadin.ui.DateField)4 Disease (de.symeda.sormas.api.Disease)4 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)4 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)4 Set (java.util.Set)4 FieldSizeConstans (pl.edu.icm.unity.webui.common.FieldSizeConstans)4