use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project rstudio by rstudio.
the class AppCommand method createMenuImageHtml.
private static SafeHtml createMenuImageHtml(ImageResource image) {
SafeHtmlBuilder sb = new SafeHtmlBuilder();
sb.append(SafeHtmlUtil.createOpenTag("img", "width", Integer.toString(image.getWidth()), "height", Integer.toString(image.getHeight()), "src", image.getSafeUri().asString()));
sb.appendHtmlConstant("</img>");
return sb.toSafeHtml();
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project rstudio by rstudio.
the class TriStateCheckboxCell method setValue.
@Override
public void setValue(Context context, Element parent, Boolean value) {
SafeHtmlBuilder builder = new SafeHtmlBuilder();
render(context, value, builder);
parent.setInnerHTML(builder.toSafeHtml().asString());
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project rstudio by rstudio.
the class CppCompletionPopupMenu method setCompletions.
public void setCompletions(JsArray<CppCompletion> completions, CommandWithArg<CppCompletion> onSelected) {
// save completions and selectable state
completions_ = completions;
onSelected_ = onSelected;
// clear existing items
updatingMenu_ = true;
menuBar_.clearItems();
// add items (remember first item for programmatic selection)
MenuItem firstItem = null;
for (int i = 0; i < completions.length(); i++) {
final CppCompletion completion = completions.get(i);
SafeHtmlBuilder sb = new SafeHtmlBuilder();
SafeHtmlUtil.appendImage(sb, RES.styles().itemImage(), completion.getIcon());
SafeHtmlUtil.appendSpan(sb, RES.styles().itemName(), completion.getTypedText());
MenuItem menuItem = new MenuItem(sb.toSafeHtml(), new ScheduledCommand() {
@Override
public void execute() {
docDisplay_.setFocus(true);
if (isSelectable())
onSelected_.execute(completion);
}
});
menuItem.addStyleName(RES.styles().itemMenu());
FontSizer.applyNormalFontSize(menuItem);
addItem(menuItem);
if (i == 0)
firstItem = menuItem;
}
updatingMenu_ = false;
// select first item
if (isSelectable() && (firstItem != null))
selectItem(firstItem);
if (completions.length() > 0) {
showMenu();
} else {
setVisible(false);
if (toolTip_ != null)
toolTip_.setVisible(false);
}
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project rstudio by rstudio.
the class NewRMarkdownDialog method createFormatOption.
private Widget createFormatOption(String name, String description) {
HTMLPanel formatWrapper = new HTMLPanel("");
formatWrapper.setStyleName(style.outputFormat());
SafeHtmlBuilder sb = new SafeHtmlBuilder();
sb.appendHtmlConstant("<span class=\"" + style.outputFormatName() + "\">");
sb.appendEscaped(name);
sb.appendHtmlConstant("</span>");
RadioButton button = new RadioButton("DefaultOutputFormat", sb.toSafeHtml().asString(), true);
button.addStyleName(style.outputFormatChoice());
formatOptions_.add(button);
formatWrapper.add(button);
Label label = new Label(description);
label.setStyleName(style.outputFormatDetails());
formatWrapper.add(label);
return formatWrapper;
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project rstudio by rstudio.
the class GitStatusRenderer method render.
@Override
public SafeHtml render(String str) {
if (str.length() != 2)
return null;
ImageResource2x indexImg = imgForStatus(str.charAt(0));
ImageResource2x treeImg = imgForStatus(str.charAt(1));
SafeHtmlBuilder builder = new SafeHtmlBuilder();
builder.append(SafeHtmlUtils.fromTrustedString("<span " + "class=\"" + ctRes_.cellTableStyle().status() + "\" " + "title=\"" + SafeHtmlUtils.htmlEscape(descForStatus(str)) + "\">"));
builder.append(indexImg.getSafeHtml());
builder.append(treeImg.getSafeHtml());
builder.appendHtmlConstant("</span>");
return builder.toSafeHtml();
}
Aggregations