table.removeRow(row);
}
private void displayApprovals(final int row, final ApprovalSummary summary,
final AccountInfoCache aic, final boolean highlightUnreviewed) {
final CellFormatter fmt = table.getCellFormatter();
final Map<ApprovalCategory.Id, PatchSetApproval> approvals =
summary.getApprovalMap();
int col = BASE_COLUMNS;
boolean haveReview = false;
boolean showUsernameInReviewCategory = false;
if (Gerrit.isSignedIn()) {
AccountGeneralPreferences prefs = Gerrit.getUserAccount().getGeneralPreferences();
if (prefs.isShowUsernameInReviewCategory()) {
showUsernameInReviewCategory = true;
}
}
for (final ApprovalType type : approvalTypes) {
final PatchSetApproval ca = approvals.get(type.getCategory().getId());
fmt.removeStyleName(row, col, Gerrit.RESOURCES.css().negscore());
fmt.removeStyleName(row, col, Gerrit.RESOURCES.css().posscore());
fmt.addStyleName(row, col, Gerrit.RESOURCES.css().singleLine());
if (ca == null || ca.getValue() == 0) {
table.clearCell(row, col);
} else {
haveReview = true;
final ApprovalCategoryValue acv = type.getValue(ca);
final AccountInfo ai = aic.get(ca.getAccountId());
if (type.isMaxNegative(ca)) {
if (showUsernameInReviewCategory) {
FlowPanel fp = new FlowPanel();
fp.add(new Image(Gerrit.RESOURCES.redNot()));
fp.add(new InlineLabel(FormatUtil.name(ai)));
table.setWidget(row, col, fp);
} else {
table.setWidget(row, col, new Image(Gerrit.RESOURCES.redNot()));
}
} else if (type.isMaxPositive(ca)) {
if (showUsernameInReviewCategory) {
FlowPanel fp = new FlowPanel();
fp.add(new Image(Gerrit.RESOURCES.greenCheck()));
fp.add(new InlineLabel(FormatUtil.name(ai)));
table.setWidget(row, col, fp);
} else {
table.setWidget(row, col, new Image(Gerrit.RESOURCES.greenCheck()));
}
} else {
String vstr = String.valueOf(ca.getValue());
if (showUsernameInReviewCategory) {
vstr = vstr + " " + FormatUtil.name(ai);
}
if (ca.getValue() > 0) {
vstr = "+" + vstr;
fmt.addStyleName(row, col, Gerrit.RESOURCES.css().posscore());
} else {
fmt.addStyleName(row, col, Gerrit.RESOURCES.css().negscore());
}
table.setText(row, col, vstr);
}
// 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(
acv.getName() + " \nby " + FormatUtil.nameEmail(ai));
}
col++;
}
final Element tr = DOM.getParent(fmt.getElement(row, 0));
UIObject.setStyleName(tr, Gerrit.RESOURCES.css().needsReview(), !haveReview
&& highlightUnreviewed);
}