}
Set<TicketQuery> dynamicQueries = new TreeSet<TicketQuery>();
for (TicketLabel label : app().tickets().getLabels(getRepositoryModel())) {
String q = QueryBuilder.q(Lucene.labels.matches(label.name)).build();
dynamicQueries.add(new TicketQuery(label.name, q).color(label.color));
}
for (QueryResult ticket : results) {
if (!StringUtils.isEmpty(ticket.topic)) {
String q = QueryBuilder.q(Lucene.topic.matches(ticket.topic)).build();
dynamicQueries.add(new TicketQuery(ticket.topic, q));
}
if (!ArrayUtils.isEmpty(ticket.labels)) {
for (String label : ticket.labels) {
String q = QueryBuilder.q(Lucene.labels.matches(label)).build();
dynamicQueries.add(new TicketQuery(label, q));
}
}
}
if (dynamicQueries.size() == 0) {
add(new Label("dynamicQueries").setVisible(false));
} else {
Fragment fragment = new Fragment("dynamicQueries", "dynamicQueriesFragment", this);
ListDataProvider<TicketQuery> dynamicQueriesDp = new ListDataProvider<TicketQuery>(new ArrayList<TicketQuery>(dynamicQueries));
DataView<TicketQuery> dynamicQueriesList = new DataView<TicketQuery>("dynamicQuery", dynamicQueriesDp) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<TicketQuery> item) {
final TicketQuery tq = item.getModelObject();
Component swatch = new Label("swatch", " ").setEscapeModelStrings(false);
if (StringUtils.isEmpty(tq.color)) {
// calculate a color
tq.color = StringUtils.getColor(tq.name);
}