table.setText(row, C_LAST_UPDATE, shortFormat(c.updated()));
boolean displayName = Gerrit.isSignedIn() && Gerrit.getUserAccount()
.getGeneralPreferences().isShowUsernameInReviewCategory();
CellFormatter fmt = table.getCellFormatter();
for (int idx = 0; idx < labelNames.size(); idx++) {
String name = labelNames.get(idx);
int col = BASE_COLUMNS + idx;
LabelInfo label = c.label(name);
if (label == null) {
table.clearCell(row, col);
continue;
}
String user;
if (label.rejected() != null) {
user = label.rejected().name();
if (displayName && user != null) {
FlowPanel panel = new FlowPanel();
panel.add(new Image(Gerrit.RESOURCES.redNot()));
panel.add(new InlineLabel(user));
table.setWidget(row, col, panel);
} else {
table.setWidget(row, col, new Image(Gerrit.RESOURCES.redNot()));
}
} else if (label.approved() != null) {
user = label.approved().name();
if (displayName && user != null) {
FlowPanel panel = new FlowPanel();
panel.add(new Image(Gerrit.RESOURCES.greenCheck()));
panel.add(new InlineLabel(user));
table.setWidget(row, col, panel);
} else {
table.setWidget(row, col, new Image(Gerrit.RESOURCES.greenCheck()));
}
} else if (label.disliked() != null) {
user = label.disliked().name();
String vstr = String.valueOf(label._value());
if (displayName && user != null) {
vstr = vstr + " " + user;
}
fmt.addStyleName(row, col, Gerrit.RESOURCES.css().negscore());
table.setText(row, col, vstr);
} else if (label.recommended() != null) {
user = label.recommended().name();
String vstr = "+" + label._value();
if (displayName && user != null) {
vstr = vstr + " " + user;
}
fmt.addStyleName(row, col, Gerrit.RESOURCES.css().posscore());
table.setText(row, col, vstr);
} else {
table.clearCell(row, col);
continue;
}
fmt.addStyleName(row, col, Gerrit.RESOURCES.css().singleLine());
if (!displayName && user != null) {
// Some web browsers ignore the embedded newline; some like it;
// so we include a space before the newline to accommodate both.
fmt.getElement(row, col).setTitle(name + " \nby " + user);
}
}
boolean needHighlight = false;
if (highlightUnreviewed && !c.reviewed()) {
needHighlight = true;
}
final Element tr = DOM.getParent(fmt.getElement(row, 0));
UIObject.setStyleName(tr, Gerrit.RESOURCES.css().needsReview(),
needHighlight);
setRowItem(row, c);
}