use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.
the class KeyCommand method describeKeyStroke.
SafeHtml describeKeyStroke() {
final SafeHtmlBuilder b = new SafeHtmlBuilder();
if ((keyMask & M_CTRL) == M_CTRL) {
modifier(b, KeyConstants.I.keyCtrl());
}
if ((keyMask & M_ALT) == M_ALT) {
modifier(b, KeyConstants.I.keyAlt());
}
if ((keyMask & M_META) == M_META) {
modifier(b, KeyConstants.I.keyMeta());
}
if ((keyMask & M_SHIFT) == M_SHIFT) {
modifier(b, KeyConstants.I.keyShift());
}
final char c = (char) (keyMask & 0xffff);
switch(c) {
case KeyCodes.KEY_ENTER:
namedKey(b, KeyConstants.I.keyEnter());
break;
case KeyCodes.KEY_ESCAPE:
namedKey(b, KeyConstants.I.keyEsc());
break;
case KeyCodes.KEY_LEFT:
namedKey(b, KeyConstants.I.keyLeft());
break;
case KeyCodes.KEY_RIGHT:
namedKey(b, KeyConstants.I.keyRight());
break;
default:
b.openSpan();
b.setStyleName(KeyResources.I.css().helpKey());
b.append(String.valueOf(c));
b.closeSpan();
break;
}
return b;
}
use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.
the class KeyHelpPopup method formatKeys.
private int formatKeys(final Grid lists, int row, final int col, final KeyCommandSet set, final SafeHtml prefix) {
final CellFormatter fmt = lists.getCellFormatter();
final List<KeyCommand> keys = sort(set);
if (lists.getRowCount() < row + keys.size()) {
lists.resizeRows(row + keys.size());
}
Map<KeyCommand, Integer> rows = new HashMap<>();
FORMAT_KEYS: for (int i = 0; i < keys.size(); i++) {
final KeyCommand k = keys.get(i);
if (rows.containsKey(k)) {
continue;
}
if (k instanceof CompoundKeyCommand) {
final SafeHtmlBuilder b = new SafeHtmlBuilder();
b.append(k.describeKeyStroke());
row = formatKeys(lists, row, col, ((CompoundKeyCommand) k).getSet(), b);
continue;
}
for (int prior = 0; prior < i; prior++) {
if (KeyCommand.same(keys.get(prior), k)) {
final int r = rows.get(keys.get(prior));
final SafeHtmlBuilder b = new SafeHtmlBuilder();
b.append(SafeHtml.get(lists, r, col + 0));
b.append(" ");
b.append(KeyConstants.I.orOtherKey());
b.append(" ");
if (prefix != null) {
b.append(prefix);
b.append(" ");
b.append(KeyConstants.I.thenOtherKey());
b.append(" ");
}
b.append(k.describeKeyStroke());
SafeHtml.set(lists, r, col + 0, b);
rows.put(k, r);
continue FORMAT_KEYS;
}
}
SafeHtmlBuilder b = new SafeHtmlBuilder();
String t = k.getHelpText();
if (prefix != null) {
b.append(prefix);
b.append(" ");
b.append(KeyConstants.I.thenOtherKey());
b.append(" ");
}
b.append(k.describeKeyStroke());
if (k.sibling != null) {
b.append(" / ").append(k.sibling.describeKeyStroke());
t += " / " + k.sibling.getHelpText();
rows.put(k.sibling, row);
}
SafeHtml.set(lists, row, col + 0, b);
lists.setText(row, col + 1, ":");
lists.setText(row, col + 2, t);
rows.put(k, row);
fmt.addStyleName(row, col + 0, KeyResources.I.css().helpKeyStroke());
fmt.addStyleName(row, col + 1, KeyResources.I.css().helpSeparator());
row++;
}
return row;
}
use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.
the class ProjectBranchesScreen method showAddedBranch.
void showAddedBranch(BranchInfo branch) {
SafeHtmlBuilder b = new SafeHtmlBuilder();
b.openElement("b");
b.append(Gerrit.C.branchCreationConfirmationMessage());
b.closeElement("b");
b.openElement("p");
b.append(branch.ref());
b.closeElement("p");
ConfirmationDialog confirmationDialog = new ConfirmationDialog(Gerrit.C.branchCreationDialogTitle(), b.toSafeHtml(), new ConfirmationCallback() {
@Override
public void onOk() {
//do nothing
}
});
confirmationDialog.center();
confirmationDialog.setCancelVisible(false);
}
use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.
the class ProjectTagsScreen method showAddedTag.
void showAddedTag(TagInfo tag) {
SafeHtmlBuilder b = new SafeHtmlBuilder();
b.openElement("b");
b.append(Gerrit.C.tagCreationConfirmationMessage());
b.closeElement("b");
b.openElement("p");
b.append(tag.ref());
b.closeElement("p");
ConfirmationDialog confirmationDialog = new ConfirmationDialog(Gerrit.C.tagCreationDialogTitle(), b.toSafeHtml(), new ConfirmationCallback() {
@Override
public void onOk() {
//do nothing
}
});
confirmationDialog.center();
confirmationDialog.setCancelVisible(false);
}
use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.
the class CommitBox method set.
void set(CommentLinkProcessor commentLinkProcessor, ChangeInfo change, String revision) {
RevisionInfo revInfo = change.revision(revision);
CommitInfo commit = revInfo.commit();
commitName.setText(revision);
idText.setText("Change-Id: " + change.changeId());
idText.setPreviewText(change.changeId());
formatLink(commit.author(), authorPanel, authorNameEmail, authorDate, change);
formatLink(commit.committer(), committerPanel, committerNameEmail, committerDate, change);
text.setHTML(commentLinkProcessor.apply(new SafeHtmlBuilder().append(commit.message()).linkify()));
setWebLinks(webLinkPanel, revInfo.commit());
if (revInfo.commit().parents().length() > 1) {
mergeCommit.setVisible(true);
}
setParents(revInfo.commit().parents());
}
Aggregations