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;
}
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;
}
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;
}
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);
}
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);
}
}
Aggregations