Example usage for com.google.gwt.safehtml.shared SafeHtmlBuilder SafeHtmlBuilder

List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder SafeHtmlBuilder

Introduction

In this page you can find the example usage for com.google.gwt.safehtml.shared SafeHtmlBuilder SafeHtmlBuilder.

Prototype

public SafeHtmlBuilder() 

Source Link

Document

Constructs an empty SafeHtmlBuilder.

Usage

From source file:org.roda.wui.client.main.BreadcrumbUtils.java

private static BreadcrumbItem getBreadcrumbItem(final DIPFile dipFile) {
    SafeHtmlBuilder b = new SafeHtmlBuilder();
    // TODO get icon from config
    b.append(SafeHtmlUtils.fromSafeConstant("<i class='fa fa-play-circle'></i>"));
    b.append(SafeHtmlUtils.fromString(dipFile.getId()));
    SafeHtml label = b.toSafeHtml();/* w w w.j a v a 2  s  .c o  m*/

    return new BreadcrumbItem(label, dipFile.getId(), new Command() {

        @Override
        public void execute() {
            HistoryUtils.openBrowse(dipFile);
        }
    });
}

From source file:org.roda.wui.client.main.BreadcrumbUtils.java

private static SafeHtml getBreadcrumbLabel(String label, String level) {
    SafeHtml elementLevelIconSafeHtml = DescriptionLevelUtils.getElementLevelIconSafeHtml(level, false);
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.append(elementLevelIconSafeHtml).append(SafeHtmlUtils.fromString(label));
    return builder.toSafeHtml();
}

From source file:org.roda.wui.client.main.BreadcrumbUtils.java

private static SafeHtml getBreadcrumbLabel(IndexedAIP aip) {
    SafeHtml breadcrumbLabel;//from ww  w. j a  v a2  s.co  m
    SafeHtml elementLevelIconSafeHtml;
    if (aip.getGhost()) {
        elementLevelIconSafeHtml = DescriptionLevelUtils.getElementLevelIconSafeHtml(RodaConstants.AIP_GHOST,
                true);
        SafeHtmlBuilder builder = new SafeHtmlBuilder();
        builder.append(elementLevelIconSafeHtml);
        breadcrumbLabel = builder.toSafeHtml();
    } else {
        elementLevelIconSafeHtml = DescriptionLevelUtils.getElementLevelIconSafeHtml(aip.getLevel(), false);
        SafeHtmlBuilder builder = new SafeHtmlBuilder();
        String label = aip.getTitle() != null ? aip.getTitle() : aip.getId();
        builder.append(elementLevelIconSafeHtml).append(SafeHtmlUtils.fromString(label));
        breadcrumbLabel = builder.toSafeHtml();
    }

    return breadcrumbLabel;
}

From source file:org.roda.wui.client.main.Menu.java

private MenuItem customMenuItem(String icon, String label, String styleNames, MenuBar subMenu,
        ScheduledCommand command) {/*from w  ww . j a  va 2 s. c o  m*/
    SafeHtmlBuilder b = new SafeHtmlBuilder();
    String iconHTML = "<i class='" + icon + "'></i>";

    b.append(SafeHtmlUtils.fromSafeConstant(iconHTML));
    if (label != null)
        b.append(SafeHtmlUtils.fromSafeConstant(label));

    MenuItem menuItem;
    if (subMenu != null) {
        menuItem = new MenuItem(b.toSafeHtml(), subMenu);
    } else if (command != null) {
        menuItem = new MenuItem(b.toSafeHtml(), command);
    } else {
        menuItem = new MenuItem(b.toSafeHtml());
    }
    menuItem.addStyleName("menu-item");
    menuItem.addStyleName(styleNames);

    return menuItem;
}

From source file:org.roda.wui.client.main.Menu.java

private void setLanguageMenu() {
    String locale = LocaleInfo.getCurrentLocale().getLocaleName();

    // Getting supported languages and their display name
    Map<String, String> supportedLanguages = new HashMap<>();

    for (String localeName : LocaleInfo.getAvailableLocaleNames()) {
        if (!"default".equals(localeName)) {
            supportedLanguages.put(localeName, LocaleInfo.getLocaleNativeDisplayName(localeName));
        }/* w w w .  j  av  a  2 s .  com*/
    }

    languagesMenu.clearItems();

    for (final Entry<String, String> entry : supportedLanguages.entrySet()) {
        final String key = entry.getKey();
        final String value = entry.getValue();

        if (key.equals(locale)) {
            SafeHtmlBuilder b = new SafeHtmlBuilder();
            String iconHTML = "<i class='fa fa-check'></i>";

            b.append(SafeHtmlUtils.fromSafeConstant(value));
            b.append(SafeHtmlUtils.fromSafeConstant(iconHTML));

            MenuItem languageMenuItem = new MenuItem(b.toSafeHtml());
            languageMenuItem.addStyleName("menu-item-language-selected");
            languageMenuItem.addStyleName("menu-item-language");
            languagesMenu.addItem(languageMenuItem);
            selectedLanguage = value;
        } else {
            MenuItem languageMenuItem = new MenuItem(SafeHtmlUtils.fromSafeConstant(value),
                    new ScheduledCommand() {

                        @Override
                        public void execute() {
                            JavascriptUtils.changeLocale(key);
                        }
                    });
            languagesMenu.addItem(languageMenuItem);
            languageMenuItem.addStyleName("menu-item-language");
        }
    }
}

From source file:org.roda.wui.common.client.widgets.wcag.AccessibleHeaderOrFooterBuilder.java

private SafeHtml getSortingIcon(boolean isAscending) {
    AbstractCellTable<T> table = getTable();
    SafeHtmlBuilder shb = new SafeHtmlBuilder();

    if (isAscending) {
        table.getResources().sortAscending();
        shb.appendEscaped("A");
    } else {/*  ww w  . j  a  va  2 s . c  o  m*/
        table.getResources().sortDescending();
        shb.appendEscaped("D");
    }

    return shb.toSafeHtml();
}

From source file:org.rstudio.core.client.cellview.TriStateCheckboxCell.java

License:Open Source License

@Override
public void setValue(Context context, Element parent, Boolean value) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    render(context, value, builder);//from  www  .  jav a  2s .c o m
    parent.setInnerHTML(builder.toSafeHtml().asString());
}

From source file:org.rstudio.core.client.resources.ImageResource2x.java

License:Open Source License

public SafeHtml getSafeHtml() {
    if (html_ == null) {
        SafeHtmlBuilder sb = new SafeHtmlBuilder();

        sb.appendHtmlConstant("<img src=\"");
        sb.appendHtmlConstant(getSafeUri().asString());
        sb.appendHtmlConstant("\" width=\"");
        sb.appendHtmlConstant(new Integer(getWidth()).toString());
        sb.appendHtmlConstant("\" height=\"");
        sb.appendHtmlConstant(new Integer(getHeight()).toString());
        sb.appendHtmlConstant("\">");

        html_ = sb.toSafeHtml();/*from ww w  .j  av  a  2 s . co  m*/
    }

    return html_;
}

From source file:org.rstudio.core.client.resources.ImageResourceUrl.java

License:Open Source License

public SafeHtml getSafeHtml() {
    SafeHtmlBuilder sb = new SafeHtmlBuilder();

    sb.appendHtmlConstant("<img src=\"");
    sb.appendHtmlConstant(getSafeUri().asString());
    sb.appendHtmlConstant("\" width=\"");
    sb.appendHtmlConstant(new Integer(getWidth()).toString());
    sb.appendHtmlConstant("\" height=\"");
    sb.appendHtmlConstant(new Integer(getHeight()).toString());
    sb.appendHtmlConstant("\">");

    return sb.toSafeHtml();
}

From source file:org.rstudio.core.client.VirtualConsole.java

License:Open Source License

public SafeHtml toSafeHtml() {
    // convert to a plain-text string
    String plainText = toString();
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    String lastClass = null;/*from ww w.  j ava  2s  .co  m*/
    int len = plainText.length();
    padCharClass(len);

    // iterate in lockstep over the plain-text string and character class
    // assignment list; emit the appropriate tags when switching classes
    for (int i = 0; i < len; i++) {
        if (!charClass.get(i).equals(lastClass)) {
            if (lastClass != null)
                sb.appendHtmlConstant("</span>");
            lastClass = charClass.get(i);
            if (lastClass != null)
                sb.appendHtmlConstant("<span class=\"" + lastClass + "\">");
        }
        sb.appendEscaped(plainText.substring(i, i + 1));
    }
    if (lastClass != null)
        sb.appendHtmlConstant("</span>");

    return sb.toSafeHtml();
}