Object dropDownFieldItems = field.getChildren().get(0);
if (!(dropDownFieldItems instanceof DropDownItems)) {
throw new IllegalStateException("Search component of DropDownFieldFilter should have exactly one child component - " +
"instance of DropDownItems component. But was - " + dropDownFieldItems.toString());
}
DropDownItems dropDownItems = (DropDownItems) dropDownFieldItems;
Collection<Object> possibleValuesCollection = filter.calculateAllCriterionNames(context);
for (Iterator<Object> criterionIterator = possibleValuesCollection.iterator(); criterionIterator.hasNext();) {
Object criterionObj = criterionIterator.next();
if (isEmptyItem(criterionObj)) {
criterionIterator.remove();
}
}
List<Object> availableItems = new ArrayList<Object>(possibleValuesCollection);
List<DropDownItem> itemList = new ArrayList<DropDownItem>(availableItems.size());
for (Object itemObj : availableItems) {
DropDownItem item = createDropDownItem(context, itemObj);
itemList.add(item);
}
DropDownItem allRecordsItem = createDropDownItem(context, null);
String allRecordsCriterionName = filter.getAllRecordsText();
HtmlOutputText outputText = Components.createOutputText(context, allRecordsCriterionName);
String predefinedCriterionClass = getPredefinedCriterionClass(context, filter);
outputText.setStyleClass(predefinedCriterionClass);
allRecordsItem.getChildren().add(outputText);
itemList.add(0, allRecordsItem);
dropDownItems.setValue(itemList);
List<UIComponent> children = field.getChildren();
children.clear();
children.add(dropDownItems);
}