@Override
public void onClick(AjaxRequestTarget target) {
onRemoveAllFilter(target, entry.getKey());
}
}.add(new AttributeAppender("title", new Model("Remove all filters from '" + dtVal + "'"), " ")));
} else
item.add(new Label("filterName", dtVal));
item.add(new ListView("filterValues", entry.getValue()) {
@Override
protected void populateItem(ListItem li) {
final FacetHelper h = (FacetHelper) li.getModelObject();
final boolean selected = isAlreadyFiltered(h.getFilter());
final boolean excluded = isAlreadyExcluded(h.getFilter());
Link link = new IndicatingAjaxFallbackLink("filterValueLink") {
@Override
public void onClick(AjaxRequestTarget target) {
if (selected)
onFilterChange(target, h.key, h.value, null);
else
onFilterChange(target, h.key, h.value, false);
}
};
Link excludeLink = new IndicatingAjaxFallbackLink("filterExcludeLink") {
@Override
public void onClick(AjaxRequestTarget target) {
if (excluded)
onFilterChange(target, h.key, h.value, null);
else
onFilterChange(target, h.key, h.value, true);
}
};
li.add(new Label("filterCount", " (" + h.count + ")"));
li.add(link);
li.add(excludeLink);
/* exlude does not work for filter queries like RT_COUNT.contains(h.key)*/
if (USER.contains(h.key) || LANG.contains(h.key))
excludeLink.setVisible(true);
else
excludeLink.setVisible(false);
if (excluded)
link.add(new AttributeAppender("class", new Model("filter-ex"), " "));
// change style if filter is selected
if (selected)
link.add(new AttributeAppender("class", new Model("filter-rm"), " "));
else
link.add(new AttributeAppender("class", new Model("filter-add"), " "));
// TODO strike through if filter is excluded
link.add(new Label("filterValue", h.displayName));
// not clickable if filter would result in 0 docs
if (h.count == 0) {
link.setEnabled(false);
link.add(new AttributeAppender("class", new Model("gray"), " "));
}
}
});
}
};