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

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

Introduction

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

Prototype

public SafeHtmlBuilder append(SafeHtml html) 

Source Link

Document

Appends the contents of another SafeHtml object, without applying HTML-escaping to it.

Usage

From source file:org.opendatakit.common.web.client.UIEnabledActionCell.java

License:Apache License

@Override
public void render(Context context, T object, SafeHtmlBuilder sb) {
    if (isVisiblePredicate == null || isVisiblePredicate.isVisible(object)) {
        if (isEnabledPredicate == null || isEnabledPredicate.isEnabled(object)) {
            sb.append(htmlEnabled);
        } else {//www. j  av a  2 s . c om
            sb.append(htmlDisabled);
        }
    }
}

From source file:org.opendatakit.common.web.client.UIEnabledValidatingCheckboxCell.java

License:Apache License

@SuppressWarnings("unchecked")
@Override//from  ww  w . j  av  a 2 s. co m
public void render(Context context, Boolean value, SafeHtmlBuilder sb) {
    // Get the view data.
    Object key = context.getKey();
    Boolean viewData = getViewData(key);
    if (viewData != null && viewData.equals(value)) {
        clearViewData(key);
        viewData = null;
    }

    if (isVisiblePredicate == null || isVisiblePredicate.isVisible((T) key)) {
        if (value != null && ((viewData != null) ? viewData : value)) {
            if (isEnabledPredicate == null || isEnabledPredicate.isEnabled((T) key)) {
                sb.append(INPUT_CHECKED);
            } else {
                sb.append(INPUT_DISABLED_CHECKED);
            }
        } else {
            if (isEnabledPredicate == null || isEnabledPredicate.isEnabled((T) key)) {
                sb.append(INPUT_UNCHECKED);
            } else {
                sb.append(INPUT_DISABLED_UNCHECKED);
            }
        }
    }
}

From source file:org.opendatakit.common.web.client.UIEnabledValidatingSelectionCell.java

License:Apache License

@SuppressWarnings("unchecked")
@Override/*from ww w  .j a v a 2  s .  co m*/
public void render(Context context, String value, SafeHtmlBuilder sb) {
    // Get the view data.
    Object key = context.getKey();
    String viewData = getViewData(key);
    if (viewData != null && viewData.equals(value)) {
        clearViewData(key);
        viewData = null;
    }

    if (isVisiblePredicate == null || isVisiblePredicate.isVisible((T) key)) {
        int selectedIndex = getSelectedIndex(viewData == null ? value : viewData);
        if (isEnabledPredicate == null || isEnabledPredicate.isEnabled((T) key)) {
            sb.appendHtmlConstant("<select tabindex=\"-1\">");
        } else {
            sb.appendHtmlConstant("<select tabindex=\"-1\" disabled>");
        }
        int index = 0;
        for (String option : options) {
            if (index++ == selectedIndex) {
                sb.append(template.selected(option));
            } else {
                sb.append(template.deselected(option));
            }
        }
        sb.appendHtmlConstant("</select>");
    }
}

From source file:org.opendatakit.common.web.client.UIEnabledValidatingTextInputCell.java

License:Apache License

@SuppressWarnings("unchecked")
@Override/*w w  w.j a  v  a 2 s.  c  o m*/
public void render(Context context, String value, SafeHtmlBuilder sb) {
    Object key = context.getKey();
    ViewData viewData = getViewData(key);
    if (viewData != null && viewData.getCurrentValue().equals(value)) {
        clearViewData(key);
        viewData = null;
    }
    // Get the view data.
    String s = (viewData != null) ? viewData.getCurrentValue() : value;

    if (isVisiblePredicate == null || isVisiblePredicate.isVisible((T) key)) {
        if (isEnabledPredicate == null || isEnabledPredicate.isEnabled((T) key)) {
            if (s != null) {
                sb.append(template.input(s));
            } else {
                sb.appendHtmlConstant("<input type=\"text\" tabindex=\"-1\"></input>");
            }
        } else {
            if (s != null) {
                sb.append(disabledTemplate.input(s));
            } else {
                sb.appendHtmlConstant("<input type=\"text\" tabindex=\"-1\" disabled></input>");
            }
        }
    }
}

From source file:org.openelis.ui.widget.table.StaticView.java

License:Open Source License

protected void bulkRender() {
    CellRenderer renderer;/*from w w  w .  j av  a  2  s . c  o  m*/
    String style;

    SafeHtmlBuilder tb = new SafeHtmlBuilder();

    for (int i = 0; i < table.getRowCount(); i++) {
        style = table.getRowAt(i).getStyle(i);
        tb.appendHtmlConstant("<tr height='" + (table.getRowHeight() + 3) + "px' index='" + i + "'"
                + (style != null ? " class='" + style + "'>" : ">"));
        for (int j = 0; j < table.getColumnCount(); j++) {
            renderer = table.getColumnAt(j).getCellRenderer();
            if (table.getColumnAt(j).display)
                tb.appendHtmlConstant("<td>");
            else
                tb.appendHtmlConstant("<td style=\"display : none;\">)");
            tb.append(renderer.bulkRender(table.getValueAt(i, j)));
            tb.appendHtmlConstant("</td>");
        }
        tb.appendHtmlConstant("</tr>");
    }

    // this is in a try catch only to get by for unit testing
    try {
        flexTable.getElement().getElementsByTagName("tbody").getItem(0).setInnerSafeHtml(tb.toSafeHtml());
    } catch (Exception e) {
    }

    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            adjustForScroll(0);
        }
    });

}

From source file:org.openelis.ui.widget.tree.StaticView.java

License:Open Source License

protected void bulkRender() {
    CellRenderer renderer;/*from   w  ww  .ja v a 2  s.c  o m*/
    String style;
    Node node;

    SafeHtmlBuilder tb = new SafeHtmlBuilder();

    for (int r = 0; r < tree.getRowCount(); r++) {
        node = tree.getNodeAt(r);
        style = node.getStyle(r);
        tb.appendHtmlConstant("<tr height='" + tree.getRowHeight() + "px' index='" + r + "'"
                + (style != null ? " class='" + style + "'>" : ">"));
        for (int c = 0; c < tree.getColumnCount(); c++) {

            if (c < tree.getNodeDefinition(node.getType()).size()) {
                renderer = tree.getCellRenderer(r, c);
                if (c == 0) {
                    Grid treeGrid = getTreeCell(node, r, c);
                    renderer.render(treeGrid, 0, treeGrid.getCellCount(0) - 1, tree.getValueAt(r, c));
                    tb.appendHtmlConstant("<td>");
                    tb.appendHtmlConstant(treeGrid.getElement().getString());
                    tb.appendHtmlConstant("</td>");
                } else {
                    tb.appendHtmlConstant("<td>");
                    tb.append(renderer.bulkRender(tree.getValueAt(r, c)));
                    tb.appendHtmlConstant("</td>");
                }
            } else {
                tb.appendHtmlConstant("<td/>");
            }
        }
        tb.appendHtmlConstant("</tr>");
    }

    flexTable.getElement().getElementsByTagName("tbody").getItem(0).setInnerSafeHtml(tb.toSafeHtml());

    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            adjustForScroll(0);
        }
    });
}

From source file:org.opennms.features.node.list.gwt.client.DblClickTextCell.java

License:Open Source License

@Override
protected void render(Context context, SafeHtml value, SafeHtmlBuilder sb) {
    if (value != null) {
        sb.append(value);
    }/*from   w ww  .  j  a v a 2  s. com*/
}

From source file:org.opennms.features.vaadin.nodemaps.internal.gwt.client.ui.controls.search.SearchControl.java

License:Open Source License

private void initializeCellAutocompleteWidget() {
    final AbstractSafeHtmlRenderer<NodeMarker> renderer = new AbstractSafeHtmlRenderer<NodeMarker>() {
        @Override/*from www. ja va  2 s  . com*/
        public SafeHtml render(final NodeMarker marker) {
            final SafeHtmlBuilder builder = new SafeHtmlBuilder();
            final String search = m_inputBox.getValue();

            builder.appendHtmlConstant("<div class=\"autocomplete-label\">");
            builder.appendHtmlConstant(marker.getNodeLabel());
            builder.appendHtmlConstant("</div>");
            String additionalSearchInfo = null;

            if (search != null && (search.contains(":") || search.contains("="))) {
                final String searchKey = search.replaceAll("[\\:\\=].*$", "").toLowerCase();
                LOG.info("searchKey = " + searchKey);

                final Map<String, String> props = marker.getProperties();

                if ("category".equals(searchKey) || "categories".equals(searchKey)) {
                    final String catString = props.get("categories");
                    if (catString != null) {
                        additionalSearchInfo = catString;
                    }
                }

                for (final Map.Entry<String, String> entry : props.entrySet()) {
                    final String key = entry.getKey().toLowerCase();
                    final Object value = entry.getValue();
                    if (key.equals(searchKey) && m_labels.containsKey(key)) {
                        additionalSearchInfo = m_labels.get(key) + ": " + value;
                        break;
                    }
                }
            }

            if (additionalSearchInfo != null) {
                builder.appendHtmlConstant("<div class=\"autocomplete-additional-info\">")
                        .appendHtmlConstant(additionalSearchInfo).appendHtmlConstant("</div>");
            }

            return builder.toSafeHtml();
        }
    };

    final AbstractSafeHtmlCell<NodeMarker> cell = new AbstractSafeHtmlCell<NodeMarker>(renderer, "keydown",
            "click", "dblclick", "touchstart") {

        @Override
        public void onBrowserEvent(final Context context, final com.google.gwt.dom.client.Element parent,
                final NodeMarker value, final NativeEvent event, final ValueUpdater<NodeMarker> valueUpdater) {
            LOG.info("SearchControl.AutocompleteCell.onBrowserEvent(): context = " + context + ", parent = "
                    + parent + ", value = " + value + ", event = " + event);
            if (m_stateManager.handleAutocompleteEvent(event)) {
                super.onBrowserEvent(context, parent, value, event, valueUpdater);
            }
        }

        @Override
        protected void render(final Context context, final SafeHtml data, final SafeHtmlBuilder builder) {
            builder.appendHtmlConstant("<div class=\"autocomplete-entry\">");
            if (data != null) {
                builder.append(data);
            }
            builder.appendHtmlConstant("</div>");
        }
    };

    m_autoComplete = new CellList<NodeMarker>(cell);
    m_autoComplete.setSelectionModel(m_selectionModel);
    m_autoComplete.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
    m_autoComplete.setVisible(false);
    m_autoComplete.addStyleName("search-autocomplete");
    setIdIfMissing(m_autoComplete, "searchControl.autoComplete");
}

From source file:org.openremote.app.client.widget.IconCell.java

License:Open Source License

@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
    if (value == null) {
        return;//from  w  w w  .  j  a  v  a  2s .c o  m
    }
    SafeHtml rendered = templates.cell(value);
    sb.append(rendered);
}

From source file:org.otalo.ao.client.widget.chlist.client.ChosenImpl.java

License:Apache License

private void resultsBuild() {

    selectItems = new SelectParser().parse(selectElement);

    if (isMultiple && choices > 0) {
        searchChoices.find("li." + css.searchChoice()).remove();
        choices = 0;/*from  w  ww  .  j  a  v a2 s.co  m*/
    } else if (!isMultiple) {
        selectedItem.addClass(css.chznDefault()).find("span").text(defaultText);

        if (selectElement.getOptions().getLength() <= options.getDisableSearchThreshold()) {
            container.addClass(css.chznContainerSingleNoSearch());
        } else {
            container.removeClass(css.chznContainerSingleNoSearch());
        }
    }

    SafeHtmlBuilder content = new SafeHtmlBuilder();

    for (int i = 0; i < selectItems.length(); i++) {
        SelectItem item = selectItems.get(i);

        if (item.isGroup()) {
            SafeHtml result = resultAddGroup((GroupItem) item);
            if (result != null) {
                content.append(result);
            }
        } else {
            OptionItem optionItem = (OptionItem) item;

            if (optionItem.isEmpty()) {
                continue;
            }

            SafeHtml optionHtml = resultAddOption(optionItem);
            if (optionHtml != null) {
                content.append(optionHtml);
            }

            if (optionItem.isSelected() && isMultiple) {
                choiceBuild(optionItem);
            } else if (optionItem.isSelected() && !isMultiple) {
                selectedItem.removeClass(css.chznDefault()).find("span").text(optionItem.getText());
                if (allowSingleDeselect) {
                    singleDeselectControlBuild();
                }
            }
        }
    }
    searchFieldDisabled();
    showSearchFieldDefault();
    searchFieldScale();
    searchResults.html(content.toSafeHtml().asString());
}