DataView<QueryResult> ticketsView = new DataView<QueryResult>("ticket", resultsDataProvider) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<QueryResult> item) {
final QueryResult ticket = item.getModelObject();
item.add(getStateIcon("state", ticket.type, ticket.status));
item.add(new Label("id", "" + ticket.number));
UserModel creator = app().users().getUserModel(ticket.createdBy);
if (creator != null) {
item.add(new LinkPanel("createdBy", null, creator.getDisplayName(),
UserPage.class, WicketUtils.newUsernameParameter(ticket.createdBy)));
} else {
item.add(new Label("createdBy", ticket.createdBy));
}
item.add(WicketUtils.createDateLabel("createDate", ticket.createdAt, GitBlitWebSession
.get().getTimezone(), getTimeUtils(), false));
if (ticket.updatedAt == null) {
item.add(new Label("updated").setVisible(false));
} else {
Fragment updated = new Fragment("updated", "updatedFragment", this);
UserModel updater = app().users().getUserModel(ticket.updatedBy);
if (updater != null) {
updated.add(new LinkPanel("updatedBy", null, updater.getDisplayName(),
UserPage.class, WicketUtils.newUsernameParameter(ticket.updatedBy)));
} else {
updated.add(new Label("updatedBy", ticket.updatedBy));
}
updated.add(WicketUtils.createDateLabel("updateDate", ticket.updatedAt, GitBlitWebSession
.get().getTimezone(), getTimeUtils(), false));
item.add(updated);
}
item.add(new LinkPanel("title", "list subject", StringUtils.trimString(
ticket.title, Constants.LEN_SHORTLOG), TicketsPage.class, newTicketParameter(ticket)));
ListDataProvider<String> labelsProvider = new ListDataProvider<String>(ticket.getLabels());
DataView<String> labelsView = new DataView<String>("labels", labelsProvider) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<String> labelItem) {
String content = bugtraqProcessor().processPlainCommitMessage(getRepository(), repositoryName, labelItem.getModelObject());
Label label = new Label("label", content);
label.setEscapeModelStrings(false);
TicketLabel tLabel = app().tickets().getLabel(getRepositoryModel(), labelItem.getModelObject());
String background = MessageFormat.format("background-color:{0};", tLabel.color);
label.add(new SimpleAttributeModifier("style", background));
labelItem.add(label);
}
};
item.add(labelsView);
if (StringUtils.isEmpty(ticket.responsible)) {
item.add(new Label("responsible").setVisible(false));
} else {
UserModel responsible = app().users().getUserModel(ticket.responsible);
if (responsible == null) {
responsible = new UserModel(ticket.responsible);
}
GravatarImage avatar = new GravatarImage("responsible", responsible.getDisplayName(),
responsible.emailAddress, null, 16, true);
avatar.setTooltip(getString("gb.responsible") + ": " + responsible.getDisplayName());
item.add(avatar);
}
// votes indicator
Label v = new Label("votes", "" + ticket.votesCount);
WicketUtils.setHtmlTooltip(v, getString("gb.votes"));
item.add(v.setVisible(ticket.votesCount > 0));
// watching indicator
item.add(new Label("watching").setVisible(ticket.isWatching(GitBlitWebSession.get().getUsername())));
// status indicator
String css = getLozengeClass(ticket.status, true);
Label l = new Label("status", ticket.status.toString());
WicketUtils.setCssClass(l, css);