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

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

Introduction

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

Prototype

public SafeHtmlBuilder appendEscaped(String text) 

Source Link

Document

Appends a string after HTML-escaping it.

Usage

From source file:org.daxplore.presenter.client.ui.PerspectiveQuestionsPanel.java

License:Open Source License

private PerspectiveQuestionsPanel(QuestionMetadata questions, Perspectives perspectives, UITexts uiTexts,
        PrefixProperties prefixProperties) {
    Label header = new Label(uiTexts.pickSelectionGroupHeader());
    header.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    header.addStyleName("daxplore-PerspectiveQuestionList-header");
    this.add(header);

    perspectiveList = new Tree();
    for (String questionID : perspectives.getQuestionIDs()) {
        SafeHtmlBuilder html = new SafeHtmlBuilder();
        html.appendEscaped(questions.getShortText(questionID));
        if (questions.hasSecondary(questionID)) {
            html.appendHtmlConstant("&nbsp;<span class=\"super\">");
            html.appendEscaped(prefixProperties.getSecondaryFlagText());
            html.appendHtmlConstant("</span>");
        }/*w  w  w  .j a v  a  2s.  c o  m*/
        QuestionTreeItem item = new QuestionTreeItem(html.toSafeHtml(), questionID);
        perspectiveList.addItem(item);
    }
    this.add(perspectiveList);
    setWidth("100%");
    setPerspective(perspectives.getQuestionIDs().get(0), false);
}

From source file:org.daxplore.presenter.client.ui.QuestionPanel.java

License:Open Source License

@Inject
protected QuestionPanel(QuestionMetadata questions, Groups groups, EventBus eventBus, UITexts uiTexts,
        UIResources uiResources, PrefixProperties prefixProperties) {
    this.eventBus = eventBus;

    treeRoot = new Tree(uiResources, false);

    Label header = new Label(uiTexts.pickAQuestionHeader());
    header.addStyleName("daxplore-QuestionPanel-header");
    vp.add(header);/*from  w w  w .jav  a  2  s. c  o m*/
    vp.setCellHeight(header, "30px");

    // Set up questiontree

    treeRoot.addSelectionHandler(new QuestionSelectionHandler());
    treeRoot.addOpenHandler(new GroupOpenHandler());

    for (int i = 0; i < groups.getGroupCount(); i++) {
        String txt = groups.getGroupName(i);
        SafeHtmlBuilder html = new SafeHtmlBuilder();
        html.appendHtmlConstant("<span class=\"daxplore-QuestionPanel-branch\">&nbsp;");
        html.appendEscaped(txt);
        html.appendHtmlConstant("&nbsp;</span>");
        GroupItem gr = new GroupItem(html.toSafeHtml());
        List<String> qlist = groups.getQuestionIDs(i);
        for (String q : qlist) {
            html = new SafeHtmlBuilder();
            html.appendHtmlConstant("&nbsp;");
            html.appendEscaped(questions.getShortText(q));
            if (questions.hasSecondary(q)) {
                html.appendHtmlConstant("&nbsp;<span class=\"super\">");
                html.appendEscaped(prefixProperties.getSecondaryFlagText());
                html.appendHtmlConstant("</span>");
            }
            html.appendHtmlConstant("&nbsp;");
            QuestionTreeItem qi = new QuestionTreeItem(html.toSafeHtml(), q);
            qi.setTitle(questions.getFullText(q));
            gr.addItem(qi);
        }
        treeRoot.addItem(gr);
    }

    vp.add(treeRoot);
    vp.setCellVerticalAlignment(treeRoot, HasVerticalAlignment.ALIGN_TOP);
    vp.setWidth("100%");
    initWidget(vp);

    QueryUpdateEvent.register(eventBus, this);
}

From source file:org.drools.guvnor.client.widgets.decoratedgrid.VerticalMergableGridWidget.java

License:Apache License

@SuppressWarnings("rawtypes")
private TableCellElement makeTableCellElement(int iCol, DynamicDataRow rowData) {

    TableCellElement tce = null;//ww  w.ja v  a2 s.c  o m

    // Column to handle rendering
    DynamicColumn<?> column = columns.get(iCol);

    CellValue<? extends Comparable<?>> cellData = rowData.get(iCol);
    int rowSpan = cellData.getRowSpan();
    if (rowSpan > 0) {

        // Use Elements rather than Templates as it's easier to set attributes that need to be dynamic
        tce = Document.get().createTDElement();
        DivElement div = Document.get().createDivElement();
        DivElement divText = Document.get().createDivElement();
        tce.addClassName(style.cellTableCell());
        div.setClassName(style.cellTableCellDiv());
        divText.addClassName(style.cellTableTextDiv());

        // Set widths
        int colWidth = column.getWidth();
        div.getStyle().setWidth(colWidth, Unit.PX);
        divText.getStyle().setWidth(colWidth, Unit.PX);
        tce.getStyle().setWidth(colWidth, Unit.PX);

        // Set heights, TD includes border, DIV does not
        int divHeight = cellHeightCalculator.calculateHeight(rowSpan);
        div.getStyle().setHeight(divHeight, Unit.PX);
        tce.setRowSpan(rowSpan);

        //Styling depending upon state
        if (cellData.isOtherwise()) {
            tce.addClassName(style.cellTableCellOtherwise());
        }
        if (cellData instanceof GroupedCellValue) {
            GroupedCellValue gcv = (GroupedCellValue) cellData;
            if (gcv.hasMultipleValues()) {
                tce.addClassName(style.cellTableCellMultipleValues());
            }
        }
        if (cellData.isSelected()) {
            tce.removeClassName(style.cellTableCellMultipleValues());
            tce.removeClassName(style.cellTableCellOtherwise());
            tce.addClassName(style.cellTableCellSelected());
        }

        // Render the cell and set inner HTML
        SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder();
        if (!cellData.isOtherwise()) {
            Coordinate c = cellData.getCoordinate();
            Context context = new Context(c.getRow(), c.getCol(), c);
            column.render(context, rowData, cellBuilder);
        } else {
            cellBuilder.appendEscaped("<otherwise>");
        }
        divText.setInnerHTML(cellBuilder.toSafeHtml().asString());

        // Construct the table
        tce.appendChild(div);
        div.appendChild(divText);
        tce.setTabIndex(0);

        //Add on "Grouping" widget, if applicable
        if (rowSpan > 1 || cellData.isGrouped()) {
            Element de = DOM.createDiv();
            DivElement divGroup = DivElement.as(de);
            divGroup.setTitle(messages.groupCells());
            divGroup.addClassName(style.cellTableGroupDiv());
            if (cellData.isGrouped()) {
                divGroup.setInnerHTML(selectorUngroupedCellsHtml);
            } else {
                divGroup.setInnerHTML(selectorGroupedCellsHtml);
            }
            div.appendChild(divGroup);
        }

    }
    return tce;

}

From source file:org.drools.guvnor.client.widgets.drools.decoratedgrid.AbstractVerticalMergableGridWidget.java

License:Apache License

@SuppressWarnings("rawtypes")
private TableCellElement makeTableCellElement(int iCol, DynamicDataRow rowData) {

    TableCellElement tce = null;//from w  ww .  ja  v a2 s  .com

    // Column to handle rendering
    DynamicColumn<T> column = columns.get(iCol);

    CellValue<? extends Comparable<?>> cellData = rowData.get(iCol);
    int rowSpan = cellData.getRowSpan();
    if (rowSpan > 0) {

        // Use Elements rather than Templates as it's easier to set attributes that need to be dynamic
        tce = Document.get().createTDElement();
        DivElement div = Document.get().createDivElement();
        DivElement divText = Document.get().createDivElement();
        tce.addClassName(resources.cellTableCell());
        tce.addClassName(resources.cellTableColumn(column.getModelColumn()));
        div.setClassName(resources.cellTableCellDiv());
        divText.addClassName(resources.cellTableTextDiv());

        // Set widths
        int colWidth = column.getWidth();
        div.getStyle().setWidth(colWidth, Unit.PX);
        divText.getStyle().setWidth(colWidth, Unit.PX);
        tce.getStyle().setWidth(colWidth, Unit.PX);

        // Set heights, TD includes border, DIV does not
        int divHeight = cellHeightCalculator.calculateHeight(rowSpan);
        div.getStyle().setHeight(divHeight, Unit.PX);
        tce.setRowSpan(rowSpan);

        //Styling depending upon state
        if (cellData.isOtherwise()) {
            tce.addClassName(resources.cellTableCellOtherwise());
        } else {
            tce.removeClassName(resources.cellTableCellOtherwise());
        }
        if (cellData instanceof GroupedCellValue) {
            GroupedCellValue gcv = (GroupedCellValue) cellData;
            if (gcv.hasMultipleValues()) {
                tce.addClassName(resources.cellTableCellMultipleValues());
            }
        } else {
            tce.removeClassName(resources.cellTableCellMultipleValues());
        }
        if (cellData.isSelected()) {
            tce.addClassName(resources.cellTableCellSelected());
        } else {
            tce.removeClassName(resources.cellTableCellSelected());
        }

        // Render the cell and set inner HTML
        SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder();
        if (!cellData.isOtherwise()) {
            Coordinate c = cellData.getCoordinate();
            Context context = new Context(c.getRow(), c.getCol(), c);
            column.render(context, rowData, cellBuilder);
        } else {
            cellBuilder.appendEscaped("<otherwise>");
        }
        divText.setInnerHTML(cellBuilder.toSafeHtml().asString());

        // Construct the table
        tce.appendChild(div);
        div.appendChild(divText);
        tce.setTabIndex(0);

        //Add on "Grouping" widget, if applicable
        if (rowSpan > 1 || cellData.isGrouped()) {
            Element de = DOM.createDiv();
            DivElement divGroup = DivElement.as(de);
            divGroup.setTitle(Constants.INSTANCE.groupCells());
            divGroup.addClassName(resources.cellTableGroupDiv());
            if (cellData.isGrouped()) {
                divGroup.setInnerHTML(selectorUngroupedCellsHtml);
            } else {
                divGroup.setInnerHTML(selectorGroupedCellsHtml);
            }
            div.appendChild(divGroup);
        }

    }
    return tce;

}

From source file:org.drools.guvnor.client.widgets.drools.explorer.ArtifactDependenciesExplorerWidget.java

License:Apache License

private void addItem(final TreeItem root, final MavenArtifact artifact,
        final Collection<MavenArtifact> unchecked) {
    final SafeHtmlBuilder sb = new SafeHtmlBuilder();
    sb.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(images.modelAsset()).getHTML()));
    sb.appendEscaped(" ").appendEscaped(artifact.toLabel());

    final CheckBox checkBox = new CheckBox(sb.toSafeHtml());
    if (!unchecked.contains(artifact)) {
        checkBox.setValue(true);/*from w  w w . ja v a  2  s . com*/
    }

    final TreeItem newTreeItem = root.addItem(checkBox);
    newTreeItem.setUserObject(artifact);
    if (artifact.hasChild()) {
        for (MavenArtifact chilldren : artifact.getChild()) {
            addItem(newTreeItem, chilldren, unchecked);
        }
    }

    checkBox.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final CheckBox me = ((CheckBox) event.getSource());
            boolean checked = me.getValue();
            if (newTreeItem.getChildCount() > 0) {
                for (int i = 0; i < newTreeItem.getChildCount(); i++) {
                    defineState(newTreeItem.getChild(i), checked);
                }
            }
        }

        private void defineState(TreeItem currentItem, boolean checked) {
            ((CheckBox) currentItem.getWidget()).setValue(checked);
            if (currentItem.getChildCount() > 0) {
                for (int i = 0; i < currentItem.getChildCount(); i++) {
                    defineState(currentItem.getChild(i), checked);
                }
            }
        }
    });
}

From source file:org.drools.workbench.screens.guided.dtable.client.widget.analysis.reporting.Util.java

License:Apache License

public static void addParagraph(final SafeHtmlBuilder htmlBuilder, final String text) {
    htmlBuilder.appendHtmlConstant("<p>");
    htmlBuilder.appendEscaped(text);
    htmlBuilder.appendHtmlConstant("</p>");
}

From source file:org.ebayopensource.turmeric.policy.adminui.client.view.policy.CustomListCell.java

License:Open Source License

private void renderSimpleList(final List<String> value, final SafeHtmlBuilder sb) {
    if (value != null && !value.isEmpty()) {
        for (String option : value) {
            sb.appendEscaped(option).appendHtmlConstant("<br>");
        }/*from  www .ja  v  a2 s. com*/
    }
}

From source file:org.ebayopensource.turmeric.policy.adminui.client.view.policy.DescriptionCell.java

License:Open Source License

/**
* Render.//from w  w w  .j a  v  a 2s.  c om
* 
* @param sg
*            the sg
* @param arg1
*            the arg1
* @param safeHtml
*            the safe html
* @see com.google.gwt.cell.client.AbstractCell#render(java.lang.Object,
*      java.lang.Object, com.google.gwt.safehtml.shared.SafeHtmlBuilder)
*/
public void render(final String sg, final Object arg1, final SafeHtmlBuilder safeHtml) {
    safeHtml.appendHtmlConstant("<div><p class=\"clickable\">");
    if (sg != null) {
        int length = 10;
        if (sg.length() < length) {
            length = sg.length();
        }
        safeHtml.appendEscaped(sg.substring(0, length).trim() + "...");
    }
    safeHtml.appendHtmlConstant("</p></div>");
}

From source file:org.eclipse.che.ide.command.editor.page.text.MacroCompletionProposal.java

License:Open Source License

private void appendPlain(SafeHtmlBuilder builder, String text) {
    builder.appendEscaped(text);
}

From source file:org.eclipse.che.ide.command.editor.page.text.MacroCompletionProposal.java

License:Open Source License

private void appendHighlighted(SafeHtmlBuilder builder, String text) {
    builder.appendHtmlConstant("<span class=\"" + resources.coreCss().codeassistantHighlight() + "\">");
    builder.appendEscaped(text);
    builder.appendHtmlConstant("</span>");
}