Search in sources :

Example 11 with SafeHtmlBuilder

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;
}
Also used : SafeHtmlBuilder(com.google.gwtexpui.safehtml.client.SafeHtmlBuilder)

Example 12 with SafeHtmlBuilder

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;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CellFormatter(com.google.gwt.user.client.ui.HTMLTable.CellFormatter) SafeHtmlBuilder(com.google.gwtexpui.safehtml.client.SafeHtmlBuilder)

Example 13 with SafeHtmlBuilder

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);
}
Also used : ConfirmationCallback(com.google.gerrit.client.ConfirmationCallback) SafeHtmlBuilder(com.google.gwtexpui.safehtml.client.SafeHtmlBuilder) ConfirmationDialog(com.google.gerrit.client.ConfirmationDialog)

Example 14 with SafeHtmlBuilder

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);
}
Also used : ConfirmationCallback(com.google.gerrit.client.ConfirmationCallback) SafeHtmlBuilder(com.google.gwtexpui.safehtml.client.SafeHtmlBuilder) ConfirmationDialog(com.google.gerrit.client.ConfirmationDialog)

Example 15 with SafeHtmlBuilder

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());
}
Also used : RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo) CommitInfo(com.google.gerrit.client.info.ChangeInfo.CommitInfo) SafeHtmlBuilder(com.google.gwtexpui.safehtml.client.SafeHtmlBuilder)

Aggregations

SafeHtmlBuilder (com.google.gwtexpui.safehtml.client.SafeHtmlBuilder)16 ConfirmationCallback (com.google.gerrit.client.ConfirmationCallback)3 ConfirmationDialog (com.google.gerrit.client.ConfirmationDialog)3 RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 NotSignedInDialog (com.google.gerrit.client.NotSignedInDialog)1 ActionButton (com.google.gerrit.client.actions.ActionButton)1 AccountInfo (com.google.gerrit.client.info.AccountInfo)1 AvatarInfo (com.google.gerrit.client.info.AccountInfo.AvatarInfo)1 ActionInfo (com.google.gerrit.client.info.ActionInfo)1 ApprovalInfo (com.google.gerrit.client.info.ChangeInfo.ApprovalInfo)1 CommitInfo (com.google.gerrit.client.info.ChangeInfo.CommitInfo)1 NativeString (com.google.gerrit.client.rpc.NativeString)1 FancyFlexTableImpl (com.google.gerrit.client.ui.FancyFlexTableImpl)1 JsArrayString (com.google.gwt.core.client.JsArrayString)1 Element (com.google.gwt.dom.client.Element)1 StatusCodeException (com.google.gwt.user.client.rpc.StatusCodeException)1 CellFormatter (com.google.gwt.user.client.ui.HTMLTable.CellFormatter)1 ImageResourceRenderer (com.google.gwt.user.client.ui.ImageResourceRenderer)1