use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.
the class CampaignFormDataListActivity method campaignFormMetasToItems.
private List<Item> campaignFormMetasToItems(List<CampaignFormMeta> campaignFormMetas) {
List<Item> listOut = new ArrayList<>();
listOut.add(new Item<Integer>("", null));
for (CampaignFormMeta campaignFormMeta : campaignFormMetas) {
listOut.add(new Item<>(campaignFormMeta.getFormName(), campaignFormMeta));
}
return listOut;
}
use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.
the class TaskListActivity method addFiltersToPageMenu.
@Override
public void addFiltersToPageMenu() {
View taskListFilterView = getLayoutInflater().inflate(R.layout.filter_task_list_layout, null);
FilterTaskListLayoutBinding taskListFilterBinding = DataBindingUtil.bind(taskListFilterView);
List<Item> taskAssigneeList = DataUtils.getEnumItems(TaskAssignee.class, false);
taskListFilterBinding.taskAssignee.initializeSpinner(taskAssigneeList);
pageMenu.addFilter(taskListFilterView);
taskListFilterBinding.taskAssignee.addValueChangedListener(e -> {
if (model.getTaskCriteria().getTaskAssignee() != e.getValue()) {
showPreloader();
model.getTaskCriteria().taskAssignee((TaskAssignee) e.getValue());
model.notifyCriteriaUpdated();
}
});
}
use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.
the class DataUtils method getMonthItems.
public static List<Item> getMonthItems() {
List<Item> listOut = new ArrayList<>();
listOut.add(new Item<Integer>("", null));
for (Month month : Month.values()) {
listOut.add(new Item<Integer>(I18nProperties.getEnumCaption(month), month.ordinal()));
}
return listOut;
}
use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.
the class InfrastructureDaoHelper method initializeRegionAreaFields.
public static void initializeRegionAreaFields(final ControlSpinnerField areaField, List<Item> initialAreas, Area initialArea, final ControlSpinnerField regionField, List<Item> initialRegions, Region initialRegion, final ControlSpinnerField districtField, List<Item> initialDistricts, District initialDistrict, final ControlSpinnerField communityField, List<Item> initialCommunities, Community initialCommunity) {
Item areaItem = initialArea != null ? DataUtils.toItem(initialArea) : null;
Item regionItem = initialRegion != null ? DataUtils.toItem(initialRegion) : null;
Item districtItem = initialDistrict != null ? DataUtils.toItem(initialDistrict) : null;
Item communityItem = initialCommunity != null ? DataUtils.toItem(initialCommunity) : null;
if (areaItem != null && !initialAreas.contains(areaItem)) {
initialAreas.add(areaItem);
}
if (regionItem != null && !initialRegions.contains(regionItem)) {
initialRegions.add(regionItem);
}
if (districtItem != null && !initialDistricts.contains(districtItem)) {
initialDistricts.add(districtItem);
}
if (communityItem != null && !initialCommunities.contains(communityItem)) {
initialCommunities.add(communityItem);
}
areaField.initializeSpinner(initialAreas, field -> {
Area selectedArea = (Area) field.getValue();
if (selectedArea != null) {
List<Item> newRegions = loadRegionsByArea(selectedArea);
if (initialRegion != null && selectedArea.equals(initialRegion.getArea()) && !newRegions.contains(regionItem)) {
newRegions.add(regionItem);
}
regionField.setSpinnerData(newRegions, regionField.getValue());
} else {
regionField.setSpinnerData(null);
}
});
regionField.initializeSpinner(initialRegions, field -> {
Region selectedRegion = (Region) field.getValue();
if (selectedRegion != null) {
List<Item> newDistricts = loadDistricts(selectedRegion);
if (initialDistrict != null && selectedRegion.equals(initialDistrict.getRegion()) && !newDistricts.contains(districtItem)) {
newDistricts.add(districtItem);
}
districtField.setSpinnerData(newDistricts, districtField.getValue());
areaField.setValue(selectedRegion.getArea());
} else {
districtField.setSpinnerData(null);
}
});
if (communityField != null) {
districtField.initializeSpinner(initialDistricts, field -> {
District selectedDistrict = (District) field.getValue();
if (selectedDistrict != null) {
List<Item> newCommunities = loadCommunities(selectedDistrict);
if (initialCommunity != null && selectedDistrict.equals(initialCommunity.getDistrict()) && !newCommunities.contains(communityItem)) {
newCommunities.add(communityItem);
}
communityField.setSpinnerData(newCommunities, communityField.getValue());
} else {
communityField.setSpinnerData(null);
}
});
} else {
districtField.initializeSpinner(initialDistricts);
}
if (communityField != null) {
communityField.initializeSpinner(initialCommunities);
}
}
use of de.symeda.sormas.app.component.Item in project SORMAS-Project by hzi-braunschweig.
the class InfrastructureFieldsDependencyHandler method handleCommunityChange.
public void handleCommunityChange(ControlPropertyField communityField, ControlSpinnerField districtField, ControlSpinnerField facilityField, ControlSpinnerField typeField, Facility initialFacility) {
Item facilityItem = initialFacility != null ? DataUtils.toItem(initialFacility) : null;
Community selectedCommunity = (Community) communityField.getValue();
District selectedDistrict = (District) districtField.getValue();
final List<Item> newFacilities;
if (selectedCommunity != null && typeField == null) {
newFacilities = loadFacilities(null, selectedCommunity, FacilityType.HOSPITAL);
if (initialFacility != null && selectedCommunity.equals(initialFacility.getCommunity()) && !newFacilities.contains(facilityItem)) {
newFacilities.add(facilityItem);
}
} else if (selectedCommunity != null && typeField.getValue() != null) {
newFacilities = loadFacilities(null, selectedCommunity, (FacilityType) typeField.getValue());
if (initialFacility != null && selectedCommunity.equals(initialFacility.getCommunity()) && !newFacilities.contains(facilityItem)) {
newFacilities.add(facilityItem);
}
} else {
if (!isEmptyDistrict(selectedDistrict) && typeField == null) {
newFacilities = loadFacilities(selectedDistrict, null, FacilityType.HOSPITAL);
if (initialFacility != null && selectedDistrict.equals(initialFacility.getDistrict()) && !newFacilities.contains(facilityItem)) {
newFacilities.add(facilityItem);
}
} else if (!isEmptyDistrict(selectedDistrict) && typeField.getValue() != null) {
newFacilities = loadFacilities(selectedDistrict, null, (FacilityType) typeField.getValue());
if (initialFacility != null && selectedDistrict.equals(initialFacility.getDistrict()) && !newFacilities.contains(facilityItem)) {
newFacilities.add(facilityItem);
}
} else {
newFacilities = itemsWithEmpty();
if (initialFacility != null && !newFacilities.contains(facilityItem)) {
newFacilities.add(facilityItem);
}
}
}
Facility selectedFacility = (Facility) facilityField.getValue();
if (selectedFacility == null) {
facilityField.setSpinnerData(addUnknownItem(newFacilities, unknownFacility));
} else {
if (isEmptyFacility(selectedFacility) && !isEmptyFacility(initialFacility) && !isEmptyDistrict(selectedDistrict)) {
selectedFacility = null;
}
facilityField.setSpinnerData(addUnknownItem(newFacilities, unknownFacility), selectedFacility);
}
}
Aggregations