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();
}
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)));
}
}
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;
}
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;
}
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);
}
Aggregations