Search in sources :

Example 1 with SafeHtmlBuilder

use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.

the class Util method highlight.

public static String highlight(final String text, final String toHighlight) {
    final SafeHtmlBuilder b = new SafeHtmlBuilder();
    if (toHighlight == null || "".equals(toHighlight)) {
        b.append(text);
        return b.toSafeHtml().asString();
    }
    int pos = 0;
    int endPos = 0;
    while ((pos = text.toLowerCase().indexOf(toHighlight.toLowerCase(), pos)) > -1) {
        if (pos > endPos) {
            b.append(text.substring(endPos, pos));
        }
        endPos = pos + toHighlight.length();
        b.openElement("b");
        b.append(text.substring(pos, endPos));
        b.closeElement("b");
        pos = endPos;
    }
    if (endPos < text.length()) {
        b.append(text.substring(endPos));
    }
    return b.toSafeHtml().asString();
}
Also used : SafeHtmlBuilder(com.google.gwtexpui.safehtml.client.SafeHtmlBuilder)

Example 2 with SafeHtmlBuilder

use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.

the class Actions method reloadRevisionActions.

void reloadRevisionActions(NativeMap<ActionInfo> actions) {
    if (!Gerrit.isSignedIn()) {
        return;
    }
    boolean canSubmit = actions.containsKey("submit");
    if (canSubmit) {
        ActionInfo action = actions.get("submit");
        submit.setTitle(action.title());
        submit.setEnabled(action.enabled());
        submit.setHTML(new SafeHtmlBuilder().openDiv().append(action.label()).closeDiv());
        submit.setEnabled(action.enabled());
    }
    submit.setVisible(canSubmit);
    a2b(actions, "cherrypick", cherrypick);
    a2b(actions, "rebase", rebase);
    // The rebase button on change screen is always enabled.
    // It is the "Rebase" button in the RebaseDialog that might be disabled.
    rebaseParentNotCurrent = rebase.isEnabled();
    if (rebase.isVisible()) {
        rebase.setEnabled(true);
    }
    RevisionInfo revInfo = changeInfo.revision(revision);
    for (String id : filterNonCore(actions)) {
        add(new ActionButton(changeInfo, revInfo, actions.get(id)));
    }
}
Also used : ActionButton(com.google.gerrit.client.actions.ActionButton) RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo) ActionInfo(com.google.gerrit.client.info.ActionInfo) SafeHtmlBuilder(com.google.gwtexpui.safehtml.client.SafeHtmlBuilder)

Example 3 with SafeHtmlBuilder

use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.

the class FancyFlexTableImplIE8 method parseBody.

private static Element parseBody(final SafeHtml body) {
    final SafeHtmlBuilder b = new SafeHtmlBuilder();
    b.openElement("table");
    b.append(body);
    b.closeElement("table");
    final Element newTable = SafeHtml.parse(b);
    for (Element e = DOM.getFirstChild(newTable); e != null; e = DOM.getNextSibling(e)) {
        if ("tbody".equals(e.getTagName().toLowerCase())) {
            return e;
        }
    }
    return null;
}
Also used : Element(com.google.gwt.dom.client.Element) SafeHtmlBuilder(com.google.gwtexpui.safehtml.client.SafeHtmlBuilder)

Example 4 with SafeHtmlBuilder

use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.

the class Header method formatPath.

public static SafeHtml formatPath(String path) {
    SafeHtmlBuilder b = new SafeHtmlBuilder();
    if (Patch.COMMIT_MSG.equals(path)) {
        return b.append(Util.C.commitMessage());
    } else if (Patch.MERGE_LIST.equals(path)) {
        return b.append(Util.C.mergeList());
    }
    int s = path.lastIndexOf('/') + 1;
    b.append(path.substring(0, s));
    b.openElement("b");
    b.append(path.substring(s));
    b.closeElement("b");
    return b;
}
Also used : SafeHtmlBuilder(com.google.gwtexpui.safehtml.client.SafeHtmlBuilder)

Example 5 with SafeHtmlBuilder

use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.

the class PatchSetsBox method render.

private void render(NativeMap<RevisionInfo> map) {
    map.copyKeysIntoChildren("name");
    revisions = map.values();
    RevisionInfo.sortRevisionInfoByNumber(revisions);
    Collections.reverse(Natives.asList(revisions));
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    header(sb);
    for (int i = 0; i < revisions.length(); i++) {
        revision(sb, i, revisions.get(i));
    }
    GWT.<FancyFlexTableImpl>create(FancyFlexTableImpl.class).resetHtml(table, sb);
}
Also used : SafeHtmlBuilder(com.google.gwtexpui.safehtml.client.SafeHtmlBuilder) FancyFlexTableImpl(com.google.gerrit.client.ui.FancyFlexTableImpl)

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