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);
}
use of com.google.gwt.user.client.ui.HTMLTable.CellFormatter in project gerrit by GerritCodeReview.
the class MyProfileScreen method onInitUI.
@Override
protected void onInitUI() {
super.onInitUI();
HorizontalPanel h = new HorizontalPanel();
add(h);
if (Gerrit.info().plugin().hasAvatars()) {
VerticalPanel v = new VerticalPanel();
v.addStyleName(Gerrit.RESOURCES.css().avatarInfoPanel());
h.add(v);
avatar = new AvatarImage();
v.add(avatar);
changeAvatar = new Anchor(Util.C.changeAvatar(), "", "_blank");
changeAvatar.setVisible(false);
v.add(changeAvatar);
}
if (LocaleInfo.getCurrentLocale().isRTL()) {
labelIdx = 1;
fieldIdx = 0;
} else {
labelIdx = 0;
fieldIdx = 1;
}
info = new Grid((Gerrit.info().auth().siteHasUsernames() ? 1 : 0) + 4, 2);
info.setStyleName(Gerrit.RESOURCES.css().infoBlock());
info.addStyleName(Gerrit.RESOURCES.css().accountInfoBlock());
h.add(info);
int row = 0;
if (Gerrit.info().auth().siteHasUsernames()) {
infoRow(row++, Util.C.userName());
}
infoRow(row++, Util.C.fullName());
infoRow(row++, Util.C.preferredEmail());
infoRow(row++, Util.C.registeredOn());
infoRow(row++, Util.C.accountId());
final CellFormatter fmt = info.getCellFormatter();
fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(row - 1, 0, Gerrit.RESOURCES.css().bottomheader());
}
use of com.google.gwt.user.client.ui.HTMLTable.CellFormatter in project gerrit by GerritCodeReview.
the class MyWatchedProjectsScreen method onInitUI.
@Override
protected void onInitUI() {
super.onInitUI();
createWidgets();
/* top table */
grid = new Grid(2, 2);
grid.setStyleName(Gerrit.RESOURCES.css().infoBlock());
grid.setText(0, 0, Util.C.watchedProjectName());
final HorizontalPanel hp = new HorizontalPanel();
hp.add(nameBox);
hp.add(browse);
grid.setWidget(0, 1, hp);
grid.setText(1, 0, Util.C.watchedProjectFilter());
grid.setWidget(1, 1, filterTxt);
final CellFormatter fmt = grid.getCellFormatter();
fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().header());
fmt.addStyleName(1, 0, Gerrit.RESOURCES.css().header());
fmt.addStyleName(1, 0, Gerrit.RESOURCES.css().bottomheader());
final FlowPanel fp = new FlowPanel();
fp.setStyleName(Gerrit.RESOURCES.css().addWatchPanel());
fp.add(grid);
fp.add(addNew);
add(fp);
/* bottom table */
add(watchesTab);
add(delSel);
/* popup */
projectsPopup = new ProjectListPopup() {
@Override
protected void onMovePointerTo(String projectName) {
// prevent user input from being overwritten by simply poping up
if (!projectsPopup.isPoppingUp() || "".equals(nameBox.getText())) {
nameBox.setText(projectName);
}
}
@Override
protected void openRow(String projectName) {
nameBox.setText(projectName);
doAddNew();
}
};
projectsPopup.initPopup(Util.C.projects(), PageLinks.SETTINGS_PROJECTS);
}
use of com.google.gwt.user.client.ui.HTMLTable.CellFormatter in project gerrit by GerritCodeReview.
the class RegisterScreen method onInitUI.
@Override
protected void onInitUI() {
super.onInitUI();
setPageTitle(Util.C.welcomeToGerritCodeReview());
final FlowPanel formBody = new FlowPanel();
final FlowPanel contactGroup = new FlowPanel();
contactGroup.setStyleName(Gerrit.RESOURCES.css().registerScreenSection());
contactGroup.add(new SmallHeading(Util.C.welcomeReviewContact()));
final HTML whereFrom = new HTML(Util.C.welcomeContactFrom());
whereFrom.setStyleName(Gerrit.RESOURCES.css().registerScreenExplain());
contactGroup.add(whereFrom);
contactGroup.add(new ContactPanelShort() {
@Override
protected void display(AccountInfo account) {
super.display(account);
if ("".equals(nameTxt.getText())) {
// No name? Encourage the user to provide us something.
//
nameTxt.setFocus(true);
save.setEnabled(true);
}
}
});
formBody.add(contactGroup);
if (Gerrit.getUserAccount().username() == null && Gerrit.info().auth().canEdit(AccountFieldName.USER_NAME)) {
final FlowPanel fp = new FlowPanel();
fp.setStyleName(Gerrit.RESOURCES.css().registerScreenSection());
fp.add(new SmallHeading(Util.C.welcomeUsernameHeading()));
final Grid userInfo = new Grid(1, 2);
final CellFormatter fmt = userInfo.getCellFormatter();
userInfo.setStyleName(Gerrit.RESOURCES.css().infoBlock());
userInfo.addStyleName(Gerrit.RESOURCES.css().accountInfoBlock());
fp.add(userInfo);
fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().bottomheader());
UsernameField field = new UsernameField();
if (LocaleInfo.getCurrentLocale().isRTL()) {
userInfo.setText(0, 1, Util.C.userName());
userInfo.setWidget(0, 0, field);
fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().header());
} else {
userInfo.setText(0, 0, Util.C.userName());
userInfo.setWidget(0, 1, field);
fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().header());
}
formBody.add(fp);
}
if (Gerrit.info().hasSshd()) {
final FlowPanel sshKeyGroup = new FlowPanel();
sshKeyGroup.setStyleName(Gerrit.RESOURCES.css().registerScreenSection());
sshKeyGroup.add(new SmallHeading(Util.C.welcomeSshKeyHeading()));
final HTML whySshKey = new HTML(Util.C.welcomeSshKeyText());
whySshKey.setStyleName(Gerrit.RESOURCES.css().registerScreenExplain());
sshKeyGroup.add(whySshKey);
sshKeyGroup.add(new SshPanel() {
{
setKeyTableVisible(false);
}
});
formBody.add(sshKeyGroup);
}
final FlowPanel choices = new FlowPanel();
choices.setStyleName(Gerrit.RESOURCES.css().registerScreenNextLinks());
if (Gerrit.info().auth().useContributorAgreements()) {
final FlowPanel agreementGroup = new FlowPanel();
agreementGroup.setStyleName(Gerrit.RESOURCES.css().registerScreenSection());
agreementGroup.add(new SmallHeading(Util.C.welcomeAgreementHeading()));
final HTML whyAgreement = new HTML(Util.C.welcomeAgreementText());
whyAgreement.setStyleName(Gerrit.RESOURCES.css().registerScreenExplain());
agreementGroup.add(whyAgreement);
choices.add(new InlineHyperlink(Util.C.newAgreement(), PageLinks.SETTINGS_NEW_AGREEMENT));
choices.add(new InlineHyperlink(Util.C.welcomeAgreementLater(), nextToken));
formBody.add(agreementGroup);
} else {
choices.add(new InlineHyperlink(Util.C.welcomeContinue(), nextToken));
}
formBody.add(choices);
final FormPanel form = new FormPanel();
form.add(formBody);
add(form);
}
Aggregations