use of com.google.gwt.user.client.ui.HTMLTable.CellFormatter in project gerrit by GerritCodeReview.
the class MyOAuthTokenScreen method onInitUI.
@Override
protected void onInitUI() {
super.onInitUI();
tokenLabel = new CopyableLabel("");
tokenLabel.addStyleName(Gerrit.RESOURCES.css().oauthToken());
expiresLabel = new Label("");
expiresLabel.addStyleName(Gerrit.RESOURCES.css().oauthExpires());
grid = new Grid(2, 2);
grid.setStyleName(Gerrit.RESOURCES.css().infoBlock());
grid.addStyleName(Gerrit.RESOURCES.css().oauthInfoBlock());
add(grid);
expiredNote = new Label(Util.C.labelOAuthExpired());
expiredNote.setVisible(false);
add(expiredNote);
row(grid, 0, Util.C.labelOAuthToken(), tokenLabel);
row(grid, 1, Util.C.labelOAuthExpires(), expiresLabel);
CellFormatter fmt = grid.getCellFormatter();
fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(1, 0, Gerrit.RESOURCES.css().bottomheader());
flow = new FlowPanel();
flow.setStyleName(Gerrit.RESOURCES.css().oauthPanel());
add(flow);
Label netrcLabel = new Label(Util.C.labelOAuthNetRCEntry());
netrcLabel.setStyleName(Gerrit.RESOURCES.css().oauthPanelNetRCHeading());
flow.add(netrcLabel);
netrcValue = new CopyableLabel("");
netrcValue.setStyleName(Gerrit.RESOURCES.css().oauthPanelNetRCEntry());
flow.add(netrcValue);
Label cookieLabel = new Label(Util.C.labelOAuthGitCookie());
cookieLabel.setStyleName(Gerrit.RESOURCES.css().oauthPanelCookieHeading());
flow.add(cookieLabel);
cookieValue = new CopyableLabel("");
cookieValue.setStyleName(Gerrit.RESOURCES.css().oauthPanelCookieEntry());
flow.add(cookieValue);
}
use of com.google.gwt.user.client.ui.HTMLTable.CellFormatter in project gerrit by GerritCodeReview.
the class MyPasswordScreen method onInitUI.
@Override
protected void onInitUI() {
super.onInitUI();
String url = Gerrit.info().auth().httpPasswordUrl();
if (url != null) {
Anchor link = new Anchor();
link.setText(Util.C.linkObtainPassword());
link.setHref(url);
link.setTarget("_blank");
add(link);
return;
}
password = new CopyableLabel("(click 'generate' to revoke an old password)");
password.addStyleName(Gerrit.RESOURCES.css().accountPassword());
generatePassword = new Button(Util.C.buttonGeneratePassword());
generatePassword.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
doGeneratePassword();
}
});
final Grid userInfo = new Grid(2, 2);
final CellFormatter fmt = userInfo.getCellFormatter();
userInfo.setStyleName(Gerrit.RESOURCES.css().infoBlock());
userInfo.addStyleName(Gerrit.RESOURCES.css().accountInfoBlock());
add(userInfo);
row(userInfo, 0, Util.C.userName(), new UsernameField());
row(userInfo, 1, Util.C.password(), password);
fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(1, 0, Gerrit.RESOURCES.css().bottomheader());
final FlowPanel buttons = new FlowPanel();
buttons.add(generatePassword);
add(buttons);
}
use of com.google.gwt.user.client.ui.HTMLTable.CellFormatter in project gerrit by GerritCodeReview.
the class NavigationTable method movePointerTo.
protected void movePointerTo(final int newRow, final boolean scroll) {
final CellFormatter fmt = table.getCellFormatter();
final boolean clear = 0 <= currentRow && currentRow < table.getRowCount();
if (clear) {
final Element tr = fmt.getElement(currentRow, C_ARROW).getParentElement();
UIObject.setStyleName(tr, Gerrit.RESOURCES.css().activeRow(), false);
}
if (0 <= newRow && newRow < table.getRowCount() && getRowItem(newRow) != null) {
table.setWidget(newRow, C_ARROW, pointer);
final Element tr = fmt.getElement(newRow, C_ARROW).getParentElement();
UIObject.setStyleName(tr, Gerrit.RESOURCES.css().activeRow(), true);
if (scroll && isAttached()) {
scrollIntoView(tr);
}
} else if (clear) {
table.setWidget(currentRow, C_ARROW, null);
pointer.removeFromParent();
}
currentRow = newRow;
}
use of com.google.gwt.user.client.ui.HTMLTable.CellFormatter in project gerrit by GerritCodeReview.
the class FancyFlexTable method scrollIntoView.
protected void scrollIntoView(final int topRow, final int endRow) {
final CellFormatter fmt = table.getCellFormatter();
final Element top = fmt.getElement(topRow, C_ARROW).getParentElement();
final Element end = fmt.getElement(endRow, C_ARROW).getParentElement();
final int rTop = top.getAbsoluteTop();
final int rEnd = end.getAbsoluteTop() + end.getOffsetHeight();
final int rHeight = rEnd - rTop;
final int sTop = Document.get().getScrollTop();
final int sHeight = Document.get().getClientHeight();
final int sEnd = sTop + sHeight;
final int nTop;
if (sHeight <= rHeight) {
// The region is larger than the visible area, make the top
// exactly the top of the region, its the most visible area.
//
nTop = rTop;
} else if (sTop <= rTop && rTop <= sEnd) {
//
if (rEnd <= sEnd) {
//
return;
}
// Move only enough to make the end visible.
//
nTop = sTop + (rHeight - (sEnd - rTop));
} else {
// None of the region is visible. Make it visible.
//
nTop = rTop;
}
Document.get().setScrollTop(nTop);
}
use of com.google.gwt.user.client.ui.HTMLTable.CellFormatter 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);
}
Aggregations