use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class PointOfEntryForm method addFields.
@Override
protected void addFields() {
addField(PointOfEntryDto.NAME, TextField.class);
addField(PointOfEntryDto.POINT_OF_ENTRY_TYPE, ComboBox.class);
addField(PointOfEntryDto.ACTIVE, CheckBox.class);
AccessibleTextField tfLatitude = addField(PointOfEntryDto.LATITUDE, AccessibleTextField.class);
AccessibleTextField tfLongitude = addField(PointOfEntryDto.LONGITUDE, AccessibleTextField.class);
ComboBox cbRegion = addInfrastructureField(PointOfEntryDto.REGION);
ComboBox cbDistrict = addInfrastructureField(PointOfEntryDto.DISTRICT);
addField(RegionDto.EXTERNAL_ID, TextField.class);
tfLatitude.setConverter(new StringToAngularLocationConverter());
tfLatitude.setConversionError(I18nProperties.getValidationError(Validations.onlyGeoCoordinatesAllowed, tfLatitude.getCaption()));
tfLongitude.setConverter(new StringToAngularLocationConverter());
tfLongitude.setConversionError(I18nProperties.getValidationError(Validations.onlyGeoCoordinatesAllowed, tfLongitude.getCaption()));
cbRegion.addValueChangeListener(e -> {
RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(cbDistrict, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
});
cbRegion.addItems(FacadeProvider.getRegionFacade().getAllActiveAsReference());
setRequired(true, PointOfEntryDto.NAME, PointOfEntryDto.POINT_OF_ENTRY_TYPE);
if (!create) {
cbRegion.setEnabled(false);
cbDistrict.setEnabled(false);
} else {
setRequired(true, PointOfEntryDto.REGION, PointOfEntryDto.DISTRICT);
}
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class ContactsFilterForm method applyDependenciesOnNewValue.
@Override
protected void applyDependenciesOnNewValue(ContactCriteria newValue) {
final RegionReferenceDto region = newValue.getRegion();
final DistrictReferenceDto district = newValue.getDistrict();
applyRegionAndDistrictFilterDependency(region, ContactCriteria.DISTRICT, district, ContactCriteria.COMMUNITY);
final UserDto user = currentUserDto();
ComboBox officerField = getField(ContactCriteria.CONTACT_OFFICER);
if (user.getRegion() != null) {
officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRights(user.getRegion(), newValue.getDisease(), UserRight.CONTACT_RESPONSIBLE));
} else if (region != null) {
officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRights(region, newValue.getDisease(), UserRight.CONTACT_RESPONSIBLE));
} else {
officerField.removeAllItems();
}
ComboBox birthDateDD = getField(ContactCriteria.BIRTHDATE_DD);
if (getField(ContactCriteria.BIRTHDATE_YYYY).getValue() != null && getField(ContactCriteria.BIRTHDATE_MM).getValue() != null) {
birthDateDD.addItems(DateHelper.getDaysInMonth((Integer) getField(ContactCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(ContactCriteria.BIRTHDATE_YYYY).getValue()));
birthDateDD.setEnabled(true);
} else {
birthDateDD.clear();
birthDateDD.setEnabled(false);
}
// Date/Epi week filter
HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
@SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
ContactDateType contactDateType = newValue.getReportDateFrom() != null ? ContactDateType.REPORT_DATE : newValue.getLastContactDateFrom() != null ? ContactDateType.LAST_CONTACT_DATE : null;
weekAndDateFilter.getDateTypeSelector().setValue(contactDateType);
weekAndDateFilter.getDateFilterOptionFilter().setValue(newValue.getDateFilterOption());
Date dateFrom = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateFrom() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateFrom() : null;
Date dateTo = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateTo() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateTo() : null;
if (DateFilterOption.EPI_WEEK.equals(newValue.getDateFilterOption())) {
weekAndDateFilter.getWeekFromFilter().setValue(dateFrom == null ? null : DateHelper.getEpiWeek(dateFrom));
weekAndDateFilter.getWeekToFilter().setValue(dateTo == null ? null : DateHelper.getEpiWeek(dateTo));
} else {
weekAndDateFilter.getDateFromFilter().setValue(dateFrom);
weekAndDateFilter.getDateToFilter().setValue(dateTo);
}
if (StringUtils.isBlank(newValue.getEventLike())) {
clearAndDisableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
} else {
enableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
}
ComboBox diseaseField = getField(ContactIndexDto.DISEASE);
ComboBox diseaseVariantField = getField(ContactCriteria.DISEASE_VARIANT);
Disease disease = (Disease) diseaseField.getValue();
if (disease == null) {
FieldHelper.updateItems(diseaseVariantField, Collections.emptyList());
FieldHelper.setEnabled(false, diseaseVariantField);
} else {
List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
FieldHelper.setEnabled(CollectionUtils.isNotEmpty(diseaseVariants), diseaseVariantField);
}
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class ContactsFilterForm method populateContactResponsiblesForDistrict.
private void populateContactResponsiblesForDistrict(DistrictReferenceDto districtReferenceDto) {
if (districtReferenceDto != null) {
Disease selectedDisease = (Disease) getField(ContactIndexDto.DISEASE).getValue();
List<UserReferenceDto> items = FacadeProvider.getUserFacade().getUserRefsByDistrict(districtReferenceDto, selectedDisease, UserRight.CONTACT_RESPONSIBLE);
populateContactResponsibles(items);
} else {
final ComboBox regionField = getField(ContactCriteria.REGION);
if (regionField != null) {
populateContactResponsiblesForRegion((RegionReferenceDto) regionField.getValue());
}
}
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class SymptomsForm method addListenerForOnsetFields.
@SuppressWarnings("rawtypes")
private void addListenerForOnsetFields(ComboBox onsetSymptom, DateField onsetDateField) {
List<String> allPropertyIds = Stream.concat(unconditionalSymptomFieldIds.stream(), conditionalBleedingSymptomFieldIds.stream()).collect(Collectors.toList());
allPropertyIds.add(LESIONS_THAT_ITCH);
for (Object sourcePropertyId : allPropertyIds) {
Field sourceField = getFieldGroup().getField(sourcePropertyId);
sourceField.addValueChangeListener(event -> {
if (FieldHelper.getNullableSourceFieldValue(sourceField) == SymptomState.YES) {
onsetSymptom.addItem(sourceField.getCaption());
onsetDateField.setEnabled(true);
} else {
onsetSymptom.removeItem(sourceField.getCaption());
boolean isOnsetDateFieldEnabled = isAnySymptomSetToYes(getFieldGroup(), allPropertyIds, Arrays.asList(SymptomState.YES));
onsetDateField.setEnabled(isOnsetDateFieldEnabled);
Date onsetDate = getValue().getOnsetDate();
if (onsetDate != null) {
onsetDateField.setValue(onsetDate);
} else if (!isOnsetDateFieldEnabled) {
onsetDateField.setValue(null);
}
}
onsetSymptom.setEnabled(!onsetSymptom.getItemIds().isEmpty());
});
}
// will be updated by listener if needed
onsetSymptom.setEnabled(false);
// will be updated by listener if needed
onsetDateField.setEnabled(false);
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class BulkTaskDataForm method addFields.
@Override
protected void addFields() {
if (!initialized) {
return;
}
taskStatusCheckbox = new CheckBox(I18nProperties.getCaption(Captions.bulkTaskStatus));
getContent().addComponent(taskStatusCheckbox, STATUS_CHECKBOX);
NullableOptionGroup status = addField(TaskBulkEditData.TASK_STATUS, NullableOptionGroup.class);
status.setEnabled(false);
FieldHelper.setRequiredWhen(getFieldGroup(), taskStatusCheckbox, Arrays.asList(TaskBulkEditData.TASK_STATUS), Arrays.asList(true));
taskStatusCheckbox.addValueChangeListener(e -> {
status.setEnabled((boolean) e.getProperty().getValue());
});
priorityCheckbox = new CheckBox(I18nProperties.getCaption(Captions.bulkTaskPriority));
getContent().addComponent(priorityCheckbox, PRORITY_CHECKBOX);
NullableOptionGroup priority = addField(TaskBulkEditData.TASK_PRIORITY, NullableOptionGroup.class);
priority.setEnabled(false);
FieldHelper.setRequiredWhen(getFieldGroup(), priorityCheckbox, Arrays.asList(TaskBulkEditData.TASK_PRIORITY), Arrays.asList(true));
priorityCheckbox.addValueChangeListener(e -> {
priority.setEnabled((boolean) e.getProperty().getValue());
});
assigneeCheckbox = new CheckBox(I18nProperties.getCaption(Captions.bulkTaskAssignee));
getContent().addComponent(assigneeCheckbox, ASSIGNEE_CHECKBOX);
ComboBox assignee = addField(TaskBulkEditData.TASK_ASSIGNEE, ComboBox.class);
assignee.setEnabled(false);
FieldHelper.addSoftRequiredStyleWhen(getFieldGroup(), assigneeCheckbox, Arrays.asList(TaskBulkEditData.TASK_ASSIGNEE), Arrays.asList(true), null);
List<UserReferenceDto> users = getUsers();
Map<String, Long> userTaskCounts = FacadeProvider.getTaskFacade().getPendingTaskCountPerUser(users.stream().map(ReferenceDto::getUuid).collect(Collectors.toList()));
for (UserReferenceDto user : users) {
assignee.addItem(user);
Long userTaskCount = userTaskCounts.get(user.getUuid());
assignee.setItemCaption(user, user.getCaption() + " (" + (userTaskCount != null ? userTaskCount.toString() : "0") + ")");
}
assigneeCheckbox.addValueChangeListener(e -> {
boolean changeAssignee = (boolean) e.getProperty().getValue();
assignee.setEnabled(changeAssignee);
assignee.setRequired(changeAssignee);
});
}
Aggregations