use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class AbstractSampleForm method addCommonFields.
protected void addCommonFields() {
final NullableOptionGroup samplePurpose = addField(SampleDto.SAMPLE_PURPOSE, NullableOptionGroup.class);
addField(SampleDto.UUID).setReadOnly(true);
addField(SampleDto.REPORTING_USER).setReadOnly(true);
samplePurpose.addValueChangeListener(e -> updateRequestedTestFields());
addField(SampleDto.LAB_SAMPLE_ID, TextField.class);
final DateTimeField sampleDateField = addField(SampleDto.SAMPLE_DATE_TIME, DateTimeField.class);
sampleDateField.setInvalidCommitted(false);
addField(SampleDto.SAMPLE_MATERIAL, ComboBox.class);
addField(SampleDto.SAMPLE_MATERIAL_TEXT, TextField.class);
addField(SampleDto.SAMPLE_SOURCE, ComboBox.class);
addField(SampleDto.FIELD_SAMPLE_ID, TextField.class);
addDateField(SampleDto.SHIPMENT_DATE, DateField.class, 7);
addField(SampleDto.SHIPMENT_DETAILS, TextField.class);
addField(SampleDto.RECEIVED_DATE, DateField.class);
final ComboBox lab = addInfrastructureField(SampleDto.LAB);
lab.addItems(FacadeProvider.getFacilityFacade().getAllActiveLaboratories(true));
final TextField labDetails = addField(SampleDto.LAB_DETAILS, TextField.class);
labDetails.setVisible(false);
lab.addValueChangeListener(event -> updateLabDetailsVisibility(labDetails, event));
addField(SampleDto.SPECIMEN_CONDITION, ComboBox.class);
addField(SampleDto.NO_TEST_POSSIBLE_REASON, TextField.class);
TextArea comment = addField(SampleDto.COMMENT, TextArea.class);
comment.setRows(4);
comment.setDescription(I18nProperties.getPrefixDescription(SampleDto.I18N_PREFIX, SampleDto.COMMENT, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
addField(SampleDto.SHIPPED, CheckBox.class);
addField(SampleDto.RECEIVED, CheckBox.class);
ComboBox testResultField = addField(SampleDto.PATHOGEN_TEST_RESULT, ComboBox.class);
testResultField.removeItem(PathogenTestResultType.NOT_DONE);
addFields(SampleDto.SAMPLING_REASON, SampleDto.SAMPLING_REASON_DETAILS);
FieldHelper.setVisibleWhen(getFieldGroup(), SampleDto.SAMPLING_REASON_DETAILS, SampleDto.SAMPLING_REASON, Collections.singletonList(SamplingReason.OTHER_REASON), true);
addField(SampleDto.DELETION_REASON);
addField(SampleDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
setVisible(false, SampleDto.DELETION_REASON, SampleDto.OTHER_DELETION_REASON);
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class LocationEditForm method addFields.
@SuppressWarnings("deprecation")
@Override
protected void addFields() {
addressType = addField(LocationDto.ADDRESS_TYPE, ComboBox.class);
addressType.setVisible(false);
final PersonAddressType[] personAddressTypeValues = PersonAddressType.getValues(FacadeProvider.getConfigFacade().getCountryCode());
if (!isConfiguredServer("ch")) {
addressType.removeAllItems();
addressType.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ID);
addressType.addItems(personAddressTypeValues);
}
TextField addressTypeDetails = addField(LocationDto.ADDRESS_TYPE_DETAILS, TextField.class);
addressTypeDetails.setVisible(false);
FieldHelper.setVisibleWhen(getFieldGroup(), LocationDto.ADDRESS_TYPE_DETAILS, addressType, Arrays.stream(personAddressTypeValues).filter(pat -> !pat.equals(PersonAddressType.HOME)).collect(Collectors.toList()), true);
FieldHelper.setRequiredWhen(getFieldGroup(), addressType, Arrays.asList(LocationDto.ADDRESS_TYPE_DETAILS), Arrays.asList(PersonAddressType.OTHER_ADDRESS));
facilityTypeGroup = ComboBoxHelper.createComboBoxV7();
;
facilityTypeGroup.setId("typeGroup");
facilityTypeGroup.setCaption(I18nProperties.getCaption(Captions.Facility_typeGroup));
facilityTypeGroup.setWidth(100, Unit.PERCENTAGE);
facilityTypeGroup.addItems(FacilityTypeGroup.values());
getContent().addComponent(facilityTypeGroup, FACILITY_TYPE_GROUP_LOC);
facilityType = addField(LocationDto.FACILITY_TYPE);
facility = addInfrastructureField(LocationDto.FACILITY);
facility.setImmediate(true);
facilityDetails = addField(LocationDto.FACILITY_DETAILS, TextField.class);
facilityDetails.setVisible(false);
addressType.addValueChangeListener(e -> {
FacilityTypeGroup oldGroup = (FacilityTypeGroup) facilityTypeGroup.getValue();
FacilityType oldType = (FacilityType) facilityType.getValue();
FacilityReferenceDto oldFacility = (FacilityReferenceDto) facility.getValue();
String oldDetails = facilityDetails.getValue();
if (PersonAddressType.HOME.equals(addressType.getValue())) {
facilityTypeGroup.removeAllItems();
facilityTypeGroup.addItems(FacilityTypeGroup.getAccomodationGroups());
setOldFacilityValuesIfPossible(oldGroup, oldType, oldFacility, oldDetails);
} else {
facilityTypeGroup.removeAllItems();
facilityTypeGroup.addItems(FacilityTypeGroup.values());
setOldFacilityValuesIfPossible(oldGroup, oldType, oldFacility, oldDetails);
}
});
TextField streetField = addField(LocationDto.STREET, TextField.class);
TextField houseNumberField = addField(LocationDto.HOUSE_NUMBER, TextField.class);
TextField additionalInformationField = addField(LocationDto.ADDITIONAL_INFORMATION, TextField.class);
addField(LocationDto.DETAILS, TextField.class);
TextField cityField = addField(LocationDto.CITY, TextField.class);
TextField postalCodeField = addField(LocationDto.POSTAL_CODE, TextField.class);
ComboBox areaType = addField(LocationDto.AREA_TYPE, ComboBox.class);
areaType.setDescription(I18nProperties.getDescription(getPropertyI18nPrefix() + "." + LocationDto.AREA_TYPE));
contactPersonFirstName = addField(LocationDto.CONTACT_PERSON_FIRST_NAME, TextField.class);
contactPersonLastName = addField(LocationDto.CONTACT_PERSON_LAST_NAME, TextField.class);
contactPersonPhone = addField(LocationDto.CONTACT_PERSON_PHONE, TextField.class);
contactPersonPhone.addValidator(new PhoneNumberValidator(I18nProperties.getValidationError(Validations.validPhoneNumber, contactPersonPhone.getCaption())));
contactPersonEmail = addField(LocationDto.CONTACT_PERSON_EMAIL, TextField.class);
contactPersonEmail.addValidator(new EmailValidator(I18nProperties.getValidationError(Validations.validEmailAddress, contactPersonEmail.getCaption())));
final AccessibleTextField tfLatitude = addField(LocationDto.LATITUDE, AccessibleTextField.class);
final AccessibleTextField tfLongitude = addField(LocationDto.LONGITUDE, AccessibleTextField.class);
final AccessibleTextField tfAccuracy = addField(LocationDto.LAT_LON_ACCURACY, AccessibleTextField.class);
final StringToAngularLocationConverter stringToAngularLocationConverter = new StringToAngularLocationConverter();
tfLatitude.setConverter(stringToAngularLocationConverter);
tfLongitude.setConverter(stringToAngularLocationConverter);
tfAccuracy.setConverter(stringToAngularLocationConverter);
continent = addInfrastructureField(LocationDto.CONTINENT);
subcontinent = addInfrastructureField(LocationDto.SUB_CONTINENT);
country = addInfrastructureField(LocationDto.COUNTRY);
ComboBox region = addInfrastructureField(LocationDto.REGION);
ComboBox district = addInfrastructureField(LocationDto.DISTRICT);
ComboBox community = addInfrastructureField(LocationDto.COMMUNITY);
continent.setVisible(false);
subcontinent.setVisible(false);
initializeVisibilitiesAndAllowedVisibilities();
initializeAccessAndAllowedAccesses();
if (!isEditableAllowed(LocationDto.COMMUNITY)) {
setEnabled(false, LocationDto.COUNTRY, LocationDto.REGION, LocationDto.DISTRICT);
}
ValueChangeListener continentValueListener = e -> {
if (continent.isVisible()) {
ContinentReferenceDto continentReferenceDto = (ContinentReferenceDto) e.getProperty().getValue();
if (subcontinent.getValue() == null) {
FieldHelper.updateItems(country, continentReferenceDto != null ? FacadeProvider.getCountryFacade().getAllActiveByContinent(continentReferenceDto.getUuid()) : FacadeProvider.getCountryFacade().getAllActiveAsReference());
country.setValue(null);
}
subcontinent.setValue(null);
FieldHelper.updateItems(subcontinent, continentReferenceDto != null ? FacadeProvider.getSubcontinentFacade().getAllActiveByContinent(continentReferenceDto.getUuid()) : FacadeProvider.getSubcontinentFacade().getAllActiveAsReference());
}
};
ValueChangeListener subContinentValueListener = e -> {
if (subcontinent.isVisible()) {
SubcontinentReferenceDto subcontinentReferenceDto = (SubcontinentReferenceDto) e.getProperty().getValue();
if (subcontinentReferenceDto != null) {
continent.removeValueChangeListener(continentValueListener);
continent.setValue(FacadeProvider.getContinentFacade().getBySubcontinent(subcontinentReferenceDto));
continent.addValueChangeListener(continentValueListener);
}
country.setValue(null);
ContinentReferenceDto continentValue = (ContinentReferenceDto) continent.getValue();
FieldHelper.updateItems(country, subcontinentReferenceDto != null ? FacadeProvider.getCountryFacade().getAllActiveBySubcontinent(subcontinentReferenceDto.getUuid()) : continentValue == null ? FacadeProvider.getCountryFacade().getAllActiveAsReference() : FacadeProvider.getCountryFacade().getAllActiveByContinent(continentValue.getUuid()));
}
};
continent.addValueChangeListener(continentValueListener);
subcontinent.addValueChangeListener(subContinentValueListener);
skipCountryValueChange = false;
country.addValueChangeListener(e -> {
if (!skipCountryValueChange) {
CountryReferenceDto countryDto = (CountryReferenceDto) e.getProperty().getValue();
if (countryDto != null) {
final ContinentReferenceDto countryContinent = FacadeProvider.getContinentFacade().getByCountry(countryDto);
final SubcontinentReferenceDto countrySubcontinent = FacadeProvider.getSubcontinentFacade().getByCountry(countryDto);
if (countryContinent != null) {
continent.removeValueChangeListener(continentValueListener);
if (continent.isVisible()) {
skipCountryValueChange = true;
FieldHelper.updateItems(country, FacadeProvider.getCountryFacade().getAllActiveByContinent(countryContinent.getUuid()));
skipCountryValueChange = false;
}
continent.setValue(countryContinent);
continent.addValueChangeListener(continentValueListener);
}
if (countrySubcontinent != null) {
subcontinent.removeValueChangeListener(subContinentValueListener);
if (subcontinent.isVisible()) {
skipCountryValueChange = true;
if (countryContinent != null) {
FieldHelper.updateItems(subcontinent, FacadeProvider.getSubcontinentFacade().getAllActiveByContinent(countryContinent.getUuid()));
}
FieldHelper.updateItems(country, FacadeProvider.getCountryFacade().getAllActiveBySubcontinent(countrySubcontinent.getUuid()));
skipCountryValueChange = false;
}
subcontinent.setValue(countrySubcontinent);
subcontinent.addValueChangeListener(subContinentValueListener);
}
}
}
});
region.addValueChangeListener(e -> {
RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(district, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
});
district.addValueChangeListener(e -> {
DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(community, districtDto != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(districtDto.getUuid()) : null);
if (districtDto == null) {
FieldHelper.removeItems(facility);
// Add a visual indictator reminding the user to select a district
facility.setComponentError(new ErrorMessage() {
@Override
public ErrorLevel getErrorLevel() {
return ErrorLevel.INFO;
}
@Override
public String getFormattedHtmlMessage() {
return I18nProperties.getString(Strings.infoFacilityNeedsDistrict);
}
});
} else if (facilityType.getValue() != null) {
facility.setComponentError(null);
facility.markAsDirty();
FieldHelper.updateItems(facility, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(districtDto, (FacilityType) facilityType.getValue(), true, false));
}
});
community.addValueChangeListener(e -> {
CommunityReferenceDto communityDto = (CommunityReferenceDto) e.getProperty().getValue();
if (facilityType.getValue() != null) {
FieldHelper.updateItems(facility, communityDto != null ? FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType(communityDto, (FacilityType) facilityType.getValue(), true, true) : district.getValue() != null ? FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType((DistrictReferenceDto) district.getValue(), (FacilityType) facilityType.getValue(), true, false) : null);
}
});
skipFacilityTypeUpdate = false;
facilityTypeGroup.addValueChangeListener(e -> {
if (!skipFacilityTypeUpdate) {
FieldHelper.removeItems(facility);
FieldHelper.updateEnumData(facilityType, FacilityType.getTypes((FacilityTypeGroup) facilityTypeGroup.getValue()));
facilityType.setRequired(facilityTypeGroup.getValue() != null);
}
});
facilityType.addValueChangeListener(e -> {
FieldHelper.removeItems(facility);
facility.setComponentError(null);
facility.markAsDirty();
if (facilityType.getValue() != null && facilityTypeGroup.getValue() == null) {
facilityTypeGroup.setValue(((FacilityType) facilityType.getValue()).getFacilityTypeGroup());
}
if (facilityType.getValue() != null && district.getValue() != null) {
if (community.getValue() != null) {
FieldHelper.updateItems(facility, FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType((CommunityReferenceDto) community.getValue(), (FacilityType) facilityType.getValue(), true, false));
} else {
FieldHelper.updateItems(facility, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType((DistrictReferenceDto) district.getValue(), (FacilityType) facilityType.getValue(), true, false));
}
} else if (facilityType.getValue() != null && district.getValue() == null) {
// Add a visual indictator reminding the user to select a district
facility.setComponentError(new ErrorMessage() {
@Override
public ErrorLevel getErrorLevel() {
return ErrorLevel.INFO;
}
@Override
public String getFormattedHtmlMessage() {
return I18nProperties.getString(Strings.infoFacilityNeedsDistrict);
}
});
}
// Only show contactperson-details if at least a faciltytype has been set
if (facilityType.getValue() != null) {
setFacilityContactPersonFieldsVisible(true, true);
} else {
setFacilityContactPersonFieldsVisible(false, true);
}
});
facility.addValueChangeListener(e -> {
if (facility.getValue() != null) {
boolean visibleAndRequired = areFacilityDetailsRequired();
facilityDetails.setVisible(visibleAndRequired);
facilityDetails.setRequired(visibleAndRequired);
if (!visibleAndRequired) {
facilityDetails.clear();
} else {
String facilityDetailsValue = getValue() != null ? getValue().getFacilityDetails() : null;
facilityDetails.setValue(facilityDetailsValue);
}
} else {
facilityDetails.setVisible(false);
facilityDetails.setRequired(false);
facilityDetails.clear();
}
// value because of this field dependencies to other fields and the way updateEnumValues works
if (facility.isAttached() && !disableFacilityAddressCheck) {
if (facility.getValue() != null) {
FacilityDto facilityDto = FacadeProvider.getFacilityFacade().getByUuid(((FacilityReferenceDto) getField(LocationDto.FACILITY).getValue()).getUuid());
// Only if the facility's address is set
if (StringUtils.isNotEmpty(facilityDto.getCity()) || StringUtils.isNotEmpty(facilityDto.getPostalCode()) || StringUtils.isNotEmpty(facilityDto.getStreet()) || StringUtils.isNotEmpty(facilityDto.getHouseNumber()) || StringUtils.isNotEmpty(facilityDto.getAdditionalInformation()) || facilityDto.getAreaType() != null || facilityDto.getLatitude() != null || facilityDto.getLongitude() != null || (StringUtils.isNotEmpty(facilityDto.getContactPersonFirstName()) && StringUtils.isNotEmpty(facilityDto.getContactPersonLastName()))) {
// Show a confirmation popup if the location's address is already set and different from the facility one
if ((StringUtils.isNotEmpty(cityField.getValue()) && !cityField.getValue().equals(facilityDto.getCity())) || (StringUtils.isNotEmpty(postalCodeField.getValue()) && !postalCodeField.getValue().equals(facilityDto.getPostalCode())) || (StringUtils.isNotEmpty(streetField.getValue()) && !streetField.getValue().equals(facilityDto.getStreet())) || (StringUtils.isNotEmpty(houseNumberField.getValue()) && !houseNumberField.getValue().equals(facilityDto.getHouseNumber())) || (StringUtils.isNotEmpty(additionalInformationField.getValue()) && !additionalInformationField.getValue().equals(facilityDto.getAdditionalInformation())) || (areaType.getValue() != null && areaType.getValue() != facilityDto.getAreaType()) || (StringUtils.isNotEmpty(contactPersonFirstName.getValue()) && StringUtils.isNotEmpty(contactPersonLastName.getValue())) || (tfLatitude.getConvertedValue() != null && Double.compare((Double) tfLatitude.getConvertedValue(), facilityDto.getLatitude()) != 0) || (tfLongitude.getConvertedValue() != null && Double.compare((Double) tfLongitude.getConvertedValue(), facilityDto.getLongitude()) != 0)) {
VaadinUiUtil.showConfirmationPopup(I18nProperties.getString(Strings.headingLocation), new Label(I18nProperties.getString(Strings.confirmationLocationFacilityAddressOverride)), I18nProperties.getString(Strings.yes), I18nProperties.getString(Strings.no), 640, confirmationEvent -> {
if (confirmationEvent) {
overrideLocationDetailsWithFacilityOnes(facilityDto);
}
});
} else {
overrideLocationDetailsWithFacilityOnes(facilityDto);
}
}
}
}
});
final List<ContinentReferenceDto> continents = FacadeProvider.getContinentFacade().getAllActiveAsReference();
if (continents.isEmpty()) {
continent.setVisible(false);
continent.clear();
} else {
continent.addItems(continents);
}
final List<SubcontinentReferenceDto> subcontinents = FacadeProvider.getSubcontinentFacade().getAllActiveAsReference();
if (subcontinents.isEmpty()) {
subcontinent.setVisible(false);
subcontinent.clear();
} else {
subcontinent.addItems(subcontinents);
}
country.addItems(FacadeProvider.getCountryFacade().getAllActiveAsReference());
updateRegionCombo(region, country);
country.addValueChangeListener(e -> {
updateRegionCombo(region, country);
region.setValue(null);
});
Stream.of(LocationDto.LATITUDE, LocationDto.LONGITUDE).<Field<?>>map(this::getField).forEach(f -> f.addValueChangeListener(e -> this.updateLeafletMapContent()));
// Set initial visiblity of facility-contactperson-details (should only be visible if at least a facilityType has been selected)
setFacilityContactPersonFieldsVisible(facilityType.getValue() != null, true);
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class SampleController method addPathogenTestComponent.
/**
* @param sampleComponent
* to add the pathogen test create component to.
* @param pathogenTest
* the preset values to insert. May be null.
* @param caseSampleCount
* describes how many samples already exist for a case related to the pathogen test's sample (if a case exists, otherwise 0
* is valid).
* @param callback
* use it to define additional actions that need to be taken after the pathogen test is saved (e.g. refresh the UI)
* @return the pathogen test create component added.
*/
public PathogenTestForm addPathogenTestComponent(CommitDiscardWrapperComponent<? extends AbstractSampleForm> sampleComponent, PathogenTestDto pathogenTest, int caseSampleCount, Runnable callback) {
// add horizontal rule to clearly distinguish the component
Label horizontalRule = new Label("<br><hr /><br>", ContentMode.HTML);
horizontalRule.setWidth(100f, Unit.PERCENTAGE);
sampleComponent.addComponent(horizontalRule, sampleComponent.getComponentCount() - 1);
PathogenTestForm pathogenTestForm = new PathogenTestForm(sampleComponent.getWrappedComponent().getValue(), true, caseSampleCount, false);
// prefill fields
if (pathogenTest != null) {
pathogenTestForm.setValue(pathogenTest);
// show typingId field when it has a preset value
if (pathogenTest.getTypingId() != null && !"".equals(pathogenTest.getTypingId())) {
pathogenTestForm.getField(PathogenTestDto.TYPING_ID).setVisible(true);
}
} else {
pathogenTestForm.setValue(PathogenTestDto.build(sampleComponent.getWrappedComponent().getValue(), UserProvider.getCurrent().getUser()));
// remove value invalid for newly created pathogen tests
ComboBox pathogenTestResultField = pathogenTestForm.getField(PathogenTestDto.TEST_RESULT);
pathogenTestResultField.removeItem(PathogenTestResultType.NOT_DONE);
pathogenTestResultField.setValue(PathogenTestResultType.PENDING);
ComboBox testDiseaseField = pathogenTestForm.getField(PathogenTestDto.TESTED_DISEASE);
testDiseaseField.setValue(FacadeProvider.getDiseaseConfigurationFacade().getDefaultDisease());
}
// setup field updates
Field testLabField = pathogenTestForm.getField(PathogenTestDto.LAB);
NullableOptionGroup samplePurposeField = sampleComponent.getWrappedComponent().getField(SampleDto.SAMPLE_PURPOSE);
Runnable updateTestLabFieldRequired = () -> testLabField.setRequired(!SamplePurpose.INTERNAL.equals(samplePurposeField.getValue()));
updateTestLabFieldRequired.run();
samplePurposeField.addValueChangeListener(e -> updateTestLabFieldRequired.run());
// validate pathogen test create component before saving the sample
sampleComponent.addFieldGroups(pathogenTestForm.getFieldGroup());
CommitDiscardWrapperComponent.CommitListener savePathogenTest = () -> {
ControllerProvider.getPathogenTestController().savePathogenTest(pathogenTestForm.getValue(), null, true, true);
if (callback != null) {
callback.run();
}
};
sampleComponent.addCommitListener(savePathogenTest);
// Discard button configuration
Button discardButton = ButtonHelper.createButton(I18nProperties.getCaption(Captions.pathogenTestRemove));
VerticalLayout buttonLayout = new VerticalLayout(discardButton);
buttonLayout.setComponentAlignment(discardButton, Alignment.TOP_LEFT);
// add the discard button above the overall discard and commit buttons
sampleComponent.addComponent(buttonLayout, sampleComponent.getComponentCount() - 1);
discardButton.addClickListener(o -> {
sampleComponent.removeComponent(horizontalRule);
sampleComponent.removeComponent(buttonLayout);
sampleComponent.removeComponent(pathogenTestForm);
sampleComponent.removeFieldGroups(pathogenTestForm.getFieldGroup());
sampleComponent.removeCommitListener(savePathogenTest);
pathogenTestForm.discard();
});
// Country specific configuration
boolean germanInstance = FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_GERMANY);
pathogenTestForm.getField(PathogenTestDto.REPORT_DATE).setVisible(germanInstance);
pathogenTestForm.getField(PathogenTestDto.EXTERNAL_ID).setVisible(germanInstance);
pathogenTestForm.getField(PathogenTestDto.EXTERNAL_ORDER_ID).setVisible(germanInstance);
pathogenTestForm.getField(PathogenTestDto.VIA_LIMS).setVisible(germanInstance);
// Sample creation specific configuration
final DateTimeField sampleDateField = sampleComponent.getWrappedComponent().getField(SampleDto.SAMPLE_DATE_TIME);
final DateTimeField testDateField = pathogenTestForm.getField(PathogenTestDto.TEST_DATE_TIME);
testDateField.addValidator(new DateComparisonValidator(testDateField, sampleDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, testDateField.getCaption(), sampleDateField.getCaption())));
// add the pathogenTestForm above the overall discard and commit buttons
sampleComponent.addComponent(pathogenTestForm, sampleComponent.getComponentCount() - 1);
return pathogenTestForm;
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class SampleGridFilterForm method addFields.
@Override
protected void addFields() {
addField(FieldConfiguration.withCaptionAndPixelSized(SampleCriteria.PATHOGEN_TEST_RESULT, I18nProperties.getPrefixCaption(PathogenTestDto.I18N_PREFIX, PathogenTestDto.TEST_RESULT), 140));
addField(FieldConfiguration.withCaptionAndPixelSized(SampleCriteria.SPECIMEN_CONDITION, I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, SampleDto.SPECIMEN_CONDITION), 140));
addField(FieldConfiguration.withCaptionAndPixelSized(SampleCriteria.CASE_CLASSIFICATION, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CASE_CLASSIFICATION), 140));
addField(FieldConfiguration.withCaptionAndPixelSized(SampleCriteria.DISEASE, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISEASE), 140));
UserDto user = currentUserDto();
if (user.getRegion() == null) {
ComboBox regionField = addField(FieldConfiguration.withCaptionAndPixelSized(SampleCriteria.REGION, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REGION), 140));
regionField.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
}
addField(FieldConfiguration.withCaptionAndPixelSized(SampleCriteria.DISTRICT, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISTRICT), 140));
ComboBox labField = addField(FieldConfiguration.withCaptionAndPixelSized(SampleCriteria.LAB, I18nProperties.getPrefixCaption(SampleIndexDto.I18N_PREFIX, SampleIndexDto.LAB), 140));
labField.addItems(FacadeProvider.getFacilityFacade().getAllActiveLaboratories(true));
TextField searchField = addField(FieldConfiguration.withCaptionAndPixelSized(SampleCriteria.CASE_CODE_ID_LIKE, I18nProperties.getString(Strings.promptSamplesSearchField), 200));
searchField.setNullRepresentation("");
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class SampleGridFilterForm method applyDependenciesOnNewValue.
@Override
protected void applyDependenciesOnNewValue(SampleCriteria criteria) {
UserDto user = currentUserDto();
ComboBox districtField = (ComboBox) getField(SampleCriteria.DISTRICT);
if (user.getRegion() != null) {
districtField.addItems(FacadeProvider.getDistrictFacade().getAllActiveByRegion(user.getRegion().getUuid()));
districtField.setEnabled(true);
} else {
RegionReferenceDto region = criteria.getRegion();
if (region != null) {
districtField.addItems(FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
districtField.setEnabled(true);
} else {
districtField.setEnabled(false);
}
}
HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
EpiWeekAndDateFilterComponent<DateFilterOption> weekAndDateFilter;
weekAndDateFilter = (EpiWeekAndDateFilterComponent<DateFilterOption>) dateFilterLayout.getComponent(0);
weekAndDateFilter.getDateFilterOptionFilter().setValue(criteria.getDateFilterOption());
Date sampleDateFrom = criteria.getSampleReportDateFrom();
Date sampleDateTo = criteria.getSampleReportDateTo();
if (DateFilterOption.EPI_WEEK.equals(criteria.getDateFilterOption())) {
weekAndDateFilter.getWeekFromFilter().setValue(sampleDateFrom == null ? null : DateHelper.getEpiWeek(sampleDateFrom));
weekAndDateFilter.getWeekToFilter().setValue(sampleDateTo == null ? null : DateHelper.getEpiWeek(sampleDateTo));
} else {
weekAndDateFilter.getDateFromFilter().setValue(sampleDateFrom);
weekAndDateFilter.getDateToFilter().setValue(sampleDateTo);
}
}
Aggregations