use of com.google.gerrit.client.ui.ProjectLink in project gerrit by GerritCodeReview.
the class ChangeTable method populateChangeRow.
private void populateChangeRow(final int row, final ChangeInfo c, boolean highlightUnreviewed) {
CellFormatter fmt = table.getCellFormatter();
if (Gerrit.isSignedIn()) {
table.setWidget(row, C_STAR, StarredChanges.createIcon(c.legacyId(), c.starred()));
}
table.setWidget(row, C_ID, new TableChangeLink(String.valueOf(c.legacyId()), c));
String subject = Util.cropSubject(c.subject());
table.setWidget(row, C_SUBJECT, new TableChangeLink(subject, c));
Change.Status status = c.status();
if (status != Change.Status.NEW) {
table.setText(row, C_STATUS, Util.toLongString(status) + (c.isPrivate() ? (" " + Util.C.isPrivate()) : ""));
} else if (!c.mergeable()) {
table.setText(row, C_STATUS, Util.C.changeTableNotMergeable() + (c.isPrivate() ? (" " + Util.C.isPrivate()) : ""));
} else if (c.isPrivate()) {
table.setText(row, C_STATUS, Util.C.isPrivate());
}
if (c.owner() != null) {
table.setWidget(row, C_OWNER, AccountLinkPanel.withStatus(c.owner(), status));
} else {
table.setText(row, C_OWNER, "");
}
if (showAssignee) {
if (c.assignee() != null) {
table.setWidget(row, C_ASSIGNEE, AccountLinkPanel.forAssignee(c.assignee()));
if (Gerrit.getUserPreferences().highlightAssigneeInChangeTable() && Objects.equals(c.assignee().getId(), Gerrit.getUserAccount().getId())) {
table.getRowFormatter().addStyleName(row, Gerrit.RESOURCES.css().cASSIGNEDTOME());
}
} else {
table.setText(row, C_ASSIGNEE, "");
}
}
table.setWidget(row, C_PROJECT, new ProjectLink(c.projectNameKey()));
table.setWidget(row, C_BRANCH, new BranchLink(c.projectNameKey(), c.status(), c.branch(), c.topic()));
if (Gerrit.getUserPreferences().relativeDateInChangeTable()) {
table.setText(row, C_LAST_UPDATE, relativeFormat(c.updated()));
} else {
table.setText(row, C_LAST_UPDATE, shortFormat(c.updated()));
}
int col = C_SIZE;
if (!Gerrit.getUserPreferences().sizeBarInChangeTable()) {
table.setText(row, col, Util.M.insertionsAndDeletions(c.insertions(), c.deletions()));
} else {
table.setWidget(row, col, getSizeWidget(c));
fmt.getElement(row, col).setTitle(Util.M.insertionsAndDeletions(c.insertions(), c.deletions()));
}
col++;
for (int idx = 0; idx < labelNames.size(); idx++, col++) {
String name = labelNames.get(idx);
LabelInfo label = c.label(name);
if (label == null) {
fmt.getElement(row, col).setTitle(Gerrit.C.labelNotApplicable());
fmt.addStyleName(row, col, Gerrit.RESOURCES.css().labelNotApplicable());
continue;
}
String user;
String info;
ReviewCategoryStrategy reviewCategoryStrategy = Gerrit.getUserPreferences().reviewCategoryStrategy();
if (label.rejected() != null) {
user = label.rejected().name();
info = getReviewCategoryDisplayInfo(reviewCategoryStrategy, label.rejected());
if (info != null) {
FlowPanel panel = new FlowPanel();
panel.add(new Image(Gerrit.RESOURCES.redNot()));
panel.add(new InlineLabel(info));
table.setWidget(row, col, panel);
} else {
table.setWidget(row, col, new Image(Gerrit.RESOURCES.redNot()));
}
} else if (label.approved() != null) {
user = label.approved().name();
info = getReviewCategoryDisplayInfo(reviewCategoryStrategy, label.approved());
if (info != null) {
FlowPanel panel = new FlowPanel();
panel.add(new Image(Gerrit.RESOURCES.greenCheck()));
panel.add(new InlineLabel(info));
table.setWidget(row, col, panel);
} else {
table.setWidget(row, col, new Image(Gerrit.RESOURCES.greenCheck()));
}
} else if (label.disliked() != null) {
user = label.disliked().name();
info = getReviewCategoryDisplayInfo(reviewCategoryStrategy, label.disliked());
String vstr = String.valueOf(label._value());
if (info != null) {
vstr = vstr + " " + info;
}
fmt.addStyleName(row, col, Gerrit.RESOURCES.css().negscore());
table.setText(row, col, vstr);
} else if (label.recommended() != null) {
user = label.recommended().name();
info = getReviewCategoryDisplayInfo(reviewCategoryStrategy, label.recommended());
String vstr = "+" + label._value();
if (info != null) {
vstr = vstr + " " + info;
}
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 (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 = fmt.getElement(row, 0).getParentElement();
UIObject.setStyleName(tr, Gerrit.RESOURCES.css().needsReview(), needHighlight);
setRowItem(row, c);
}
use of com.google.gerrit.client.ui.ProjectLink in project gerrit by GerritCodeReview.
the class MyWatchesTable method populate.
protected void populate(final int row, final ProjectWatchInfo info) {
final FlowPanel fp = new FlowPanel();
fp.add(new ProjectLink(info.project(), new Project.NameKey(info.project())));
if (info.filter() != null) {
Label filter = new Label(info.filter());
filter.setStyleName(Gerrit.RESOURCES.css().watchedProjectFilter());
fp.add(filter);
}
table.setWidget(row, 1, new CheckBox());
table.setWidget(row, 2, fp);
addNotifyButton(ProjectWatchInfo.Type.NEW_CHANGES, info, row, 3);
addNotifyButton(ProjectWatchInfo.Type.NEW_PATCHSETS, info, row, 4);
addNotifyButton(ProjectWatchInfo.Type.ALL_COMMENTS, info, row, 5);
addNotifyButton(ProjectWatchInfo.Type.SUBMITTED_CHANGES, info, row, 6);
addNotifyButton(ProjectWatchInfo.Type.ABANDONED_CHANGES, info, row, 7);
final FlexCellFormatter fmt = table.getFlexCellFormatter();
fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().iconCell());
fmt.addStyleName(row, 2, Gerrit.RESOURCES.css().dataCell());
fmt.addStyleName(row, 3, Gerrit.RESOURCES.css().dataCell());
fmt.addStyleName(row, 4, Gerrit.RESOURCES.css().dataCell());
fmt.addStyleName(row, 5, Gerrit.RESOURCES.css().dataCell());
fmt.addStyleName(row, 6, Gerrit.RESOURCES.css().dataCell());
fmt.addStyleName(row, 7, Gerrit.RESOURCES.css().dataCell());
setRowItem(row, info);
}
Aggregations