use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.
the class IncludedInBox method formatList.
private SafeHtml formatList(JsArrayString l) {
SafeHtmlBuilder html = new SafeHtmlBuilder();
int size = l.length();
for (int i = 0; i < size; i++) {
html.openSpan().addStyleName(style.includedInElement()).append(l.get(i)).closeSpan();
if (i < size - 1) {
html.append(", ");
}
}
return html;
}
use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.
the class Labels method renderUsers.
private Widget renderUsers(LabelInfo label, Set<Integer> removable) {
Map<Integer, List<ApprovalInfo>> m = new HashMap<>(4);
int approved = 0;
int rejected = 0;
for (ApprovalInfo ai : Natives.asList(label.all())) {
if (ai.value() != 0) {
List<ApprovalInfo> l = m.get(Integer.valueOf(ai.value()));
if (l == null) {
l = new ArrayList<>(label.all().length());
m.put(Integer.valueOf(ai.value()), l);
}
l.add(ai);
if (isRejected(label, ai)) {
rejected = ai.value();
} else if (isApproved(label, ai)) {
approved = ai.value();
}
}
}
SafeHtmlBuilder html = new SafeHtmlBuilder();
for (Integer v : sort(m.keySet(), approved, rejected)) {
if (!html.isEmpty()) {
html.br();
}
String val = LabelValue.formatValue(v.shortValue());
html.openSpan();
html.setAttribute("title", label.valueText(val));
if (v.intValue() == approved) {
html.setStyleName(style.label_ok());
} else if (v.intValue() == rejected) {
html.setStyleName(style.label_reject());
}
html.append(val).append(" ");
html.append(formatUserList(style, m.get(v), removable, label.name(), null));
html.closeSpan();
}
return html.toBlockWidget();
}
use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.
the class Reviewers method addReviewer.
private void addReviewer(final String reviewer, boolean confirmed) {
if (reviewer.isEmpty()) {
return;
}
ChangeApi.reviewers(changeId.get()).post(PostInput.create(reviewer, confirmed), new GerritCallback<PostResult>() {
@Override
public void onSuccess(PostResult result) {
if (result.confirm()) {
askForConfirmation(result.error());
} else if (result.error() != null) {
UIObject.setVisible(error, true);
error.setInnerText(result.error());
} else {
UIObject.setVisible(error, false);
error.setInnerText("");
suggestBox.setText("");
if (result.reviewers() != null && result.reviewers().length() > 0) {
updateReviewerList();
}
}
}
private void askForConfirmation(String text) {
new ConfirmationDialog(Util.C.approvalTableAddManyReviewersConfirmationDialogTitle(), new SafeHtmlBuilder().append(text), new ConfirmationCallback() {
@Override
public void onOk() {
addReviewer(reviewer, true);
}
}).center();
}
@Override
public void onFailure(Throwable err) {
if (isSigninFailure(err)) {
new NotSignedInDialog().center();
} else {
UIObject.setVisible(error, true);
error.setInnerText(err instanceof StatusCodeException ? ((StatusCodeException) err).getEncodedResponse() : err.getMessage());
}
}
});
}
use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.
the class Hashtags method formatHashtags.
private SafeHtmlBuilder formatHashtags(JsArrayString hashtags) {
SafeHtmlBuilder html = new SafeHtmlBuilder();
Iterator<String> itr = Natives.asList(hashtags).iterator();
while (itr.hasNext()) {
String hashtagName = itr.next();
html.openSpan().setAttribute(DATA_ID, hashtagName).setStyleName(style.hashtagName()).openAnchor().setAttribute("href", "#" + PageLinks.toChangeQuery("hashtag:\"" + hashtagName + "\"")).setAttribute("role", "listitem").openSpan().setStyleName(style.hashtagIcon()).append(new ImageResourceRenderer().render(Gerrit.RESOURCES.hashtag())).closeSpan().append(" ").append(hashtagName).closeAnchor();
if (canEdit) {
html.openElement("button").setAttribute("title", "Remove hashtag").setAttribute("onclick", REMOVE + "(event)").append("×").closeElement("button");
}
html.closeSpan();
if (itr.hasNext()) {
html.append(' ');
}
}
return html;
}
use of com.google.gwtexpui.safehtml.client.SafeHtmlBuilder in project gerrit by GerritCodeReview.
the class CopyableLabel method embedMovie.
private void embedMovie() {
if (copier == null && flashEnabled && !text.isEmpty() && UserAgent.Flash.isInstalled()) {
final String flashVars = "text=" + URL.encodeQueryString(getText());
final SafeHtmlBuilder h = new SafeHtmlBuilder();
h.openElement("div");
h.setStyleName(ClippyResources.I.css().swf());
h.openElement("object");
h.setWidth(SWF_WIDTH);
h.setHeight(SWF_HEIGHT);
h.setAttribute("classid", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000");
h.paramElement("movie", swfUrl());
h.paramElement("FlashVars", flashVars);
h.openElement("embed");
h.setWidth(SWF_WIDTH);
h.setHeight(SWF_HEIGHT);
h.setAttribute("wmode", "transparent");
h.setAttribute("type", "application/x-shockwave-flash");
h.setAttribute("src", swfUrl());
h.setAttribute("FlashVars", flashVars);
h.closeSelf();
h.closeElement("object");
h.closeElement("div");
if (swf != null) {
getElement().removeChild(swf);
}
DOM.appendChild(getElement(), swf = SafeHtml.parse(h));
}
}
Aggregations