public SavedSearchPanel(String id) {
super(id);
tr.put(SAVED_SEARCHES, "Saved Searches");
Link saveSearch = new IndicatingAjaxFallbackLink("saveSearch") {
@Override
public void onClick(AjaxRequestTarget target) {
SavedSearchPanel.this.onSave(target, new Date().getTime());
}
};
add(saveSearch);
AjaxFallbackLink link = new IndicatingAjaxFallbackLink("saveInfo") {
@Override
public void onClick(AjaxRequestTarget target) {
SavedSearchPanel.this.onSave(target, new Date().getTime());
}
@Override
public boolean isVisible() {
return isInitialized && savedSearches.isEmpty();
}
};
add(link.setOutputMarkupId(true));
add(new WebMarkupContainer("indicatorImage") {
@Override
public boolean isVisible() {
return !isInitialized;
}
}.setOutputMarkupId(true));
// don't know how to utilize IAjaxIndicatorAware + getAjaxIndicatorMarkupId() { return indicator.getMarkupId();
//add(indicator);
savedSearchesView = new ListView("filterValues", savedSearches) {
@Override
protected void populateItem(ListItem li) {
final FacetHelper<Long> h = (FacetHelper<Long>) li.getModelObject();
long tmp = h.value;
final long ssId = tmp;
Link link = new IndicatingAjaxFallbackLink("filterValueLink") {
@Override
public void onClick(AjaxRequestTarget target) {
SavedSearchPanel.this.onClick(target, ssId);
}
};
String name = h.displayName;
if (name.length() > 20)
name = name.substring(0, 20) + "..";
else if (name.length() < 1)
name = "<empty>";
if (ssId == 0)
name = "last:" + name;
link.add(new Label("filterValue", name));
link.add(new AttributeAppender("title", true, new Model(h.displayName), " "));
Label label4count = new Label("filterCount", " (" + h.count + ")");
if (h.count < 1) {
link.add(new AttributeAppender("class", new Model("gray"), " "));
label4count.add(new AttributeAppender("class", new Model("gray"), " "));
}
li.add(label4count);
li.add(link);