use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class SampleEditForm method fillPathogenTestResult.
public void fillPathogenTestResult() {
ComboBox pathogenTestResultField = (ComboBox) getFieldGroup().getField(SampleDto.PATHOGEN_TEST_RESULT);
boolean hasOnlyPendingPathogenTests = FacadeProvider.getPathogenTestFacade().getBySampleUuids(Collections.singletonList(getValue().getUuid())).stream().allMatch(pathogenTest -> pathogenTest.getTestResult() == PathogenTestResultType.PENDING);
Collection<PathogenTestResultType> pathogenTestResultTypes;
if (hasOnlyPendingPathogenTests) {
pathogenTestResultTypes = Arrays.asList(PathogenTestResultType.values());
} else {
pathogenTestResultTypes = Arrays.stream(PathogenTestResultType.values()).filter(type -> type != PathogenTestResultType.NOT_DONE).collect(Collectors.toList());
}
FieldHelper.updateEnumData(pathogenTestResultField, pathogenTestResultTypes);
if (pathogenTestResultField.getValue() == null) {
pathogenTestResultField.setValue(PathogenTestResultType.PENDING);
}
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class AbstractEditForm method addDiseaseField.
/**
* Adds the field to the form by using addField(fieldId, fieldType), but additionally sets up a ValueChangeListener
* that makes sure the value that is about to be selected is added to the list of allowed values. This is intended
* to be used for Disease fields that might contain a disease that is no longer active in the system and thus will
* not be returned by DiseaseHelper.isActivePrimaryDisease(disease).
*
* @param showNonPrimaryDiseases
* Whether or not diseases that have been configured as non-primary should be included
* @param setServerDiseaseAsDefault
* If only a single diseases is active on the server, set it as the default value
*/
@SuppressWarnings("unchecked")
protected ComboBox addDiseaseField(String fieldId, boolean showNonPrimaryDiseases, boolean setServerDiseaseAsDefault) {
diseaseField = addField(fieldId, ComboBox.class);
this.setServerDiseaseAsDefault = setServerDiseaseAsDefault;
if (showNonPrimaryDiseases) {
addNonPrimaryDiseasesTo(diseaseField);
}
if (setServerDiseaseAsDefault) {
setDefaultDiseaseValue();
}
// Make sure that the ComboBox still contains a pre-selected inactive disease
diseaseField.addValueChangeListener(e -> {
Object value = e.getProperty().getValue();
if (value != null && !diseaseField.containsId(value)) {
Item newItem = diseaseField.addItem(value);
newItem.getItemProperty(SormasFieldGroupFieldFactory.CAPTION_PROPERTY_ID).setValue(value.toString());
}
});
return diseaseField;
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class AbstractFilterForm method applyDistrictDependency.
protected void applyDistrictDependency(DistrictReferenceDto district, String communityFieldId) {
final UserDto user = UserProvider.getCurrent().getUser();
final ComboBox communityField = getField(communityFieldId);
if (user.getDistrict() != null && user.getCommunity() == null) {
FieldHelper.updateItems(communityField, FacadeProvider.getCommunityFacade().getAllActiveByDistrict(user.getDistrict().getUuid()));
communityField.setEnabled(true);
} else {
if (district != null) {
FieldHelper.updateItems(communityField, FacadeProvider.getCommunityFacade().getAllActiveByDistrict(district.getUuid()));
communityField.setEnabled(true);
} else {
communityField.setEnabled(false);
}
}
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class AbstractFilterForm method applyRegionFilterDependency.
protected void applyRegionFilterDependency(RegionReferenceDto region, String districtFieldId) {
final UserDto user = UserProvider.getCurrent().getUser();
final ComboBox districtField = getField(districtFieldId);
if (user.getRegion() != null && user.getDistrict() == null) {
FieldHelper.updateItems(districtField, FacadeProvider.getDistrictFacade().getAllActiveByRegion(user.getRegion().getUuid()));
districtField.setEnabled(true);
} else {
if (region != null) {
FieldHelper.updateItems(districtField, FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
districtField.setEnabled(true);
} else {
districtField.setEnabled(false);
}
}
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class ComboBoxHelper method createComboBoxV7.
/**
* Create a default V7 combobox which uses FilteringMode.CONTAINS
*/
public static ComboBox createComboBoxV7() {
ComboBox cb = new ComboBox();
cb.setFilteringMode(FilteringMode.CONTAINS);
return cb;
}
Aggregations