Search in sources :

Example 6 with SafeHtmlBuilder

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

Example 7 with SafeHtmlBuilder

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

Example 8 with SafeHtmlBuilder

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);
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) MenuItem(com.google.gwt.user.client.ui.MenuItem) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) CppCompletion(org.rstudio.studio.client.workbench.views.source.model.CppCompletion)

Example 9 with SafeHtmlBuilder

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;
}
Also used : Label(com.google.gwt.user.client.ui.Label) RadioButton(com.google.gwt.user.client.ui.RadioButton) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) HTMLPanel(com.google.gwt.user.client.ui.HTMLPanel)

Example 10 with SafeHtmlBuilder

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();
}
Also used : ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Aggregations

SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)142 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)26 Test (org.junit.Test)18 Column (com.google.gwt.user.cellview.client.Column)17 Cell (com.google.gwt.cell.client.Cell)14 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)12 Context (com.google.gwt.cell.client.Cell.Context)7 MenuItem (com.google.gwt.user.client.ui.MenuItem)7 NativeEvent (com.google.gwt.dom.client.NativeEvent)6 Command (com.google.gwt.user.client.Command)6 ArrayList (java.util.ArrayList)6 ValueUpdater (com.google.gwt.cell.client.ValueUpdater)5 GWT (com.google.gwt.core.client.GWT)5 Element (com.google.gwt.dom.client.Element)5 AbstractCell (com.google.gwt.cell.client.AbstractCell)4 ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)4 TextCell (com.google.gwt.cell.client.TextCell)4 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)4 ImageResource (com.google.gwt.resources.client.ImageResource)4 Map (java.util.Map)4