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.activityinfo.ui.client.page.entry.form.SiteRenderer.java

License:Open Source License

protected String formatValue(IndicatorDTO indicator, Object value) {
    if (indicator.getType() == FieldTypeClass.QUANTITY) {
        if (value instanceof Double) {
            return indicatorValueFormatter.format((Double) value);
        }/*from   w  ww .  jav  a2s.com*/
    } else if (indicator.getType() == FieldTypeClass.FREE_TEXT) {
        if (value instanceof String) {
            return htmlEscape((String) value);
        }
    } else if (indicator.getType() == FieldTypeClass.NARRATIVE) {
        if (value instanceof String) {
            SafeHtmlBuilder html = new SafeHtmlBuilder();
            html.appendEscapedLines((String) value);
            return html.toSafeHtml().asString();
        }
    }
    return "-";
}

From source file:org.aksw.TripleCheckMate.client.widgets.EvaluationTable.java

License:Apache License

private void createTable() {
    // Link to data provider
    dataProvider.addDataDisplay(tblEvalTriples);

    // Table properties
    tblEvalTriples.setPageSize(arrPagerSizes[0]);

    // Set Pagers (add both bottom and top)
    pgrTop.setDisplay(tblEvalTriples);//from w w  w. ja  va  2  s. c o m
    pgrBottom.setDisplay(tblEvalTriples);

    // Table columns
    final SafeHtmlCell cellP = new SafeHtmlCell();
    Column<EvaluateItem, SafeHtml> colPred = new Column<EvaluateItem, SafeHtml>(cellP) {

        public SafeHtml getValue(EvaluateItem item) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            sb.appendHtmlConstant(item.P.toHTMLString());
            return sb.toSafeHtml();
        }
    };

    tblEvalTriples.addColumn(colPred, "Predicate");

    final SafeHtmlCell cellO = new SafeHtmlCell();
    Column<EvaluateItem, SafeHtml> colObj = new Column<EvaluateItem, SafeHtml>(cellO) {

        public SafeHtml getValue(EvaluateItem item) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            sb.appendHtmlConstant(item.O.toHTMLString());
            return sb.toSafeHtml();
        }
    };
    tblEvalTriples.addColumn(colObj, "Object");

    Column<EvaluateItem, Boolean> colIsValid = new Column<EvaluateItem, Boolean>(
            new CheckboxCell(true, false)) {

        public Boolean getValue(EvaluateItem item) {
            return item.isWrong;
        }
    };

    tblEvalTriples.addColumn(colIsValid, "Is Wrong");

    // Add a field updater to be notified when the user enters a new name.
    colIsValid.setFieldUpdater(new FieldUpdater<EvaluateItem, Boolean>() {

        public void update(int index, EvaluateItem object, Boolean value) {
            dataProvider.getList().get(index).isWrong = value;
            if (value == false) {
                dataProvider.getList().get(index).errorTittle = "";
                tblEvalTriples.redraw();
            } else {
                dlgEdit.setEvaluateItem(dataProvider.getList().get(index), true);
                dlgEdit.center();
                dlgEdit.show();
            }

        }
    });

    tblEvalTriples.addCellPreviewHandler(new CellPreviewEvent.Handler<EvaluateItem>() {

        long lastClick = -1000;

        public void onCellPreview(CellPreviewEvent<EvaluateItem> event) {

            long clictAt = System.currentTimeMillis();

            if (event.getNativeEvent().getType().contains("click")) {
                if (clictAt - lastClick < 600) { // dblclick on 2 clicks detected within 300 ms
                    int index = event.getIndex();
                    dlgEdit.setEvaluateItem(dataProvider.getList().get(index), false);
                    dlgEdit.center();
                    dlgEdit.show();
                }
                lastClick = System.currentTimeMillis();

            }
        }
    });

    final SafeHtmlCell cellError = new SafeHtmlCell();
    Column<EvaluateItem, SafeHtml> colError = new Column<EvaluateItem, SafeHtml>(cellError) {

        public SafeHtml getValue(EvaluateItem item) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            sb.appendHtmlConstant(item.errorTittle);
            return sb.toSafeHtml();
        }
    };
    tblEvalTriples.addColumn(colError, "Error");

    // Setup sorting

    colPred.setSortable(true);
    sortHandler.setComparator(colPred, new Comparator<EvaluateItem>() {
        public int compare(EvaluateItem o1, EvaluateItem o2) {
            return o1.P.toString().compareTo(o2.P.toString());
        }
    });

    colObj.setSortable(true);
    sortHandler.setComparator(colObj, new Comparator<EvaluateItem>() {
        public int compare(EvaluateItem o1, EvaluateItem o2) {
            return o1.P.toString().compareTo(o2.P.toString());
        }
    });

    colIsValid.setSortable(true);
    sortHandler.setComparator(colIsValid, new Comparator<EvaluateItem>() {
        public int compare(EvaluateItem o1, EvaluateItem o2) {
            if (o1.isWrong == o2.isWrong)
                return 0;
            else
                return (o1.isWrong ? 1 : -1);
        }
    });

    colError.setSortable(true);
    sortHandler.setComparator(colError, new Comparator<EvaluateItem>() {
        public int compare(EvaluateItem o1, EvaluateItem o2) {
            return o1.errorTittle.compareTo(o2.errorTittle);
        }
    });

    tblEvalTriples.addColumnSortHandler(sortHandler);
    tblEvalTriples.getColumnSortList().push(colObj);
    tblEvalTriples.getColumnSortList().push(colPred);

    for (int i = 0; i < arrPagerSizes.length; i++) {
        lstPager.addItem("" + arrPagerSizes[i]);
    }
    lstPager.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            tblEvalTriples.setPageSize(arrPagerSizes[lstPager.getSelectedIndex()]);
        }
    });
}

From source file:org.aksw.TripleCheckMate.client.widgets.UserStatisticsTable.java

License:Apache License

private void createTable() {
    // Link to data provider
    dataProvider.addDataDisplay(tblUserStats);

    // Table properties
    tblUserStats.setWidth("100%");
    tblUserStats.setPageSize(50);// w w w  .ja v a2 s.  c o m

    // Table columns
    Column<UserRecord, SafeHtml> colUserName = new Column<UserRecord, SafeHtml>(new SafeHtmlCell()) {

        public SafeHtml getValue(UserRecord item) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            sb.appendHtmlConstant(item.toHTMLString());
            return sb.toSafeHtml();
        }
    };

    tblUserStats.addColumn(colUserName, "User");
    colUserName.setSortable(true);
    sortHandler.setComparator(colUserName, new Comparator<UserRecord>() {
        public int compare(UserRecord o1, UserRecord o2) {
            return o1.name.compareTo(o2.name);
        }
    });

    Column<UserRecord, String> colRes = new Column<UserRecord, String>(new TextCell()) {

        public String getValue(UserRecord object) {
            // TODO Auto-generated method stub
            return "" + object.recordCount;
        }
    };
    tblUserStats.addColumn(colRes, "Resources");
    colRes.setSortable(true);
    sortHandler.setComparator(colRes, new Comparator<UserRecord>() {
        public int compare(UserRecord o1, UserRecord o2) {
            Integer a1 = new Integer(o1.recordCount);
            Integer a2 = new Integer(o2.recordCount);
            return a1.compareTo(a2);
        }
    });

    Column<UserRecord, String> colTriples = new Column<UserRecord, String>(new TextCell()) {

        public String getValue(UserRecord object) {
            // TODO Auto-generated method stub
            return "" + object.errorCount;
        }
    };
    tblUserStats.addColumn(colTriples, "Wrong Triples");
    colTriples.setSortable(true);
    sortHandler.setComparator(colTriples, new Comparator<UserRecord>() {
        public int compare(UserRecord o1, UserRecord o2) {
            Integer a1 = new Integer(o1.errorCount);
            Integer a2 = new Integer(o2.errorCount);
            return a1.compareTo(a2);
        }
    });

    Column<UserRecord, String> colErrorTypes = new Column<UserRecord, String>(new TextCell()) {

        public String getValue(UserRecord object) {
            // TODO Auto-generated method stub
            return "" + object.distinctErrorCount;
        }
    };
    tblUserStats.addColumn(colErrorTypes, "Error Types");
    colErrorTypes.setSortable(true);
    sortHandler.setComparator(colErrorTypes, new Comparator<UserRecord>() {
        public int compare(UserRecord o1, UserRecord o2) {
            Integer a1 = new Integer(o1.distinctErrorCount);
            Integer a2 = new Integer(o2.distinctErrorCount);
            return a1.compareTo(a2);
        }
    });

    tblUserStats.addColumnSortHandler(sortHandler);
    tblUserStats.getColumnSortList().push(colTriples);
    tblUserStats.getColumnSortList().push(colRes);
}

From source file:org.apache.hupa.client.ui.MessagesCellTable.java

License:Apache License

protected Column<Message, SafeHtml> getFromColumn() {
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x10x2_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x10x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x10x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x2_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee");
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x00x2_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x10x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x00x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x00x0");
    return new Column<Message, SafeHtml>(new SafeHtmlCell()) {
        @Override//from  w w  w. j  a  va 2 s.c  o  m
        public SafeHtml getValue(Message object) {
            InstrumentationLoggerProvider.get().instrument(
                    "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x3_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x2_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x20x0");
            InstrumentationLoggerProvider.get().instrument(
                    "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe");
            InstrumentationLoggerProvider.get().instrument(
                    "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x00x10x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x00x10x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x00x1");
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            InstrumentationLoggerProvider.get().instrument(
                    "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x10x00x00x00x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x10x00x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x10x00x00x00x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x10x00x00x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x10x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x10x0");
            sb.append(SafeHtmlUtils.fromString(object.getFrom() == null ? "" : object.getFrom()));
            InstrumentationLoggerProvider.get().instrument(
                    "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x2_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5556067aee0x20x00x00x2c87156fe0x30x20x0");
            return sb.toSafeHtml();
        }
    };
}

From source file:org.apache.hupa.client.ui.MessagesCellTable.java

License:Apache License

protected Column<Message, SafeHtml> getSubjectColumn() {
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x10x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x10x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x2_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x10x2_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac008");
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x10x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x00x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x00x2");
    return new Column<Message, SafeHtml>(new SafeHtmlCell()) {
        @Override/* w w  w .  j  a  v  a  2 s. c om*/
        public SafeHtml getValue(Message object) {
            InstrumentationLoggerProvider.get().instrument(
                    "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe");
            InstrumentationLoggerProvider.get().instrument(
                    "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x3_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x2_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x20x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x0");
            InstrumentationLoggerProvider.get().instrument(
                    "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x00x10x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x00x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x00x10x00x0");
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            InstrumentationLoggerProvider.get().instrument(
                    "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x10x00x00x00x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x10x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x10x00x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x10x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x10x00x00x00x0_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x10x00x00x00x1_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x1");
            sb.append(SafeHtmlUtils.fromString(object.getSubject() == null ? "" : object.getSubject()));
            InstrumentationLoggerProvider.get().instrument(
                    "org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x2_____org_apache_hupa_client_ui_MessagesCellTable_java0x0f2ab3f5530cac0080x20x00x00x2c87156fe0x30x20x0");
            return sb.toSafeHtml();
        }
    };
}

From source file:org.appverse.web.framework.frontend.gwt.theme.bluetouch.client.button.AppverseWebButtonCellDefaultAppearance.java

License:sencha.com license

@Override
public void render(final ButtonCell<C> cell, Context context, C value, SafeHtmlBuilder sb) {
    String constantHtml = cell.getHTML();
    boolean hasConstantHtml = constantHtml != null && constantHtml.length() != 0;
    boolean isBoolean = value != null && value instanceof Boolean;
    // is a boolean always a toggle button?
    String text = hasConstantHtml ? cell.getText()
            : (value != null && !isBoolean) ? SafeHtmlUtils.htmlEscape(value.toString()) : "";

    ImageResource icon = cell.getIcon();
    IconAlign iconAlign = cell.getIconAlign();

    String cls = style.button();/*  ww w  .j ava 2s. com*/
    String arrowCls = "";
    if (cell.getMenu() != null) {

        if (cell instanceof SplitButtonCell) {
            switch (cell.getArrowAlign()) {
            case RIGHT:
                arrowCls = style.split();
                break;
            case BOTTOM:
                arrowCls = style.splitBottom();
                break;
            }

        } else {
            switch (cell.getArrowAlign()) {
            case RIGHT:
                arrowCls = style.arrow();
                break;
            case BOTTOM:
                arrowCls = style.arrowBottom();
                break;
            }
        }

    }

    ButtonScale scale = cell.getScale();

    switch (scale) {
    case SMALL:
        cls += " " + style.small();
        break;

    case MEDIUM:
        cls += " " + style.medium();
        break;

    case LARGE:
        cls += " " + style.large();
        break;
    }

    SafeStylesBuilder stylesBuilder = new SafeStylesBuilder();

    int width = -1;

    if (cell.getWidth() != -1) {
        int w = cell.getWidth();
        if (w < cell.getMinWidth()) {
            w = cell.getMinWidth();
        }
        stylesBuilder.appendTrustedString("width:" + w + "px;");
        cls += " " + style.hasWidth() + " x-has-width";
        width = w;
    } else {

        if (cell.getMinWidth() != -1) {
            TextMetrics.get().bind(style.text());
            int length = TextMetrics.get().getWidth(text);
            length += 6; // frames

            if (icon != null) {
                switch (iconAlign) {
                case LEFT:
                case RIGHT:
                    length += icon.getWidth();
                    break;
                }
            }

            if (cell.getMinWidth() > length) {
                stylesBuilder.appendTrustedString("width:" + cell.getMinWidth() + "px;");
                cls += " " + style.hasWidth() + " x-has-width";
                width = cell.getMinWidth();
            }
        }
    }

    final int height = cell.getHeight();
    if (height != -1) {
        stylesBuilder.appendTrustedString("height:" + height + "px;");
    }

    if (icon != null) {
        switch (iconAlign) {
        case TOP:
            arrowCls += " " + style.iconTop();
            break;
        case BOTTOM:
            arrowCls += " " + style.iconBottom();
            break;
        case LEFT:
            arrowCls += " " + style.iconLeft();
            break;
        case RIGHT:
            arrowCls += " " + style.iconRight();
            break;
        }

    } else {
        arrowCls += " " + style.noIcon();
    }

    // toggle button
    if (value == Boolean.TRUE) {
        cls += " " + frame.pressedClass();
    }

    sb.append(templates.outer(cls, new SafeStylesBuilder().toSafeStyles()));

    SafeHtmlBuilder inside = new SafeHtmlBuilder();

    String innerWrap = arrowCls;
    if (GXT.isIE6() || GXT.isIE7()) {
        arrowCls += " " + CommonStyles.get().inlineBlock();
    }

    inside.appendHtmlConstant("<div class='" + innerWrap + "'>");
    inside.appendHtmlConstant("<table cellpadding=0 cellspacing=0 class='" + style.mainTable() + "'>");

    if (icon != null) {
        switch (iconAlign) {
        case LEFT:
            inside.appendHtmlConstant("<tr>");
            writeIcon(inside, icon, height);
            if (text != null) {
                int w = width - (icon != null ? icon.getWidth() : 0) - 4;
                writeText(inside, text, w, height);
            }
            inside.appendHtmlConstant("</tr>");
            break;
        case RIGHT:
            inside.appendHtmlConstant("<tr>");
            if (text != null) {
                int w = width - (icon != null ? icon.getWidth() : 0) - 4;
                writeText(inside, text, w, height);
            }
            writeIcon(inside, icon, height);
            inside.appendHtmlConstant("</tr>");
            break;
        case TOP:
            inside.appendHtmlConstant("<tr>");
            writeIcon(inside, icon, height);
            inside.appendHtmlConstant("</tr>");
            if (text != null) {
                inside.appendHtmlConstant("<tr>");
                writeText(inside, text, width, height);
                inside.appendHtmlConstant("</tr>");
            }
            break;
        case BOTTOM:
            if (text != null) {
                inside.appendHtmlConstant("<tr>");
                writeText(inside, text, width, height);
                inside.appendHtmlConstant("</tr>");
            }
            inside.appendHtmlConstant("<tr>");
            writeIcon(inside, icon, height);
            inside.appendHtmlConstant("</tr>");
            break;
        }

    } else {
        inside.appendHtmlConstant("<tr>");
        if (text != null) {
            writeText(inside, text, width, height);
        }
        inside.appendHtmlConstant("</tr>");
    }
    inside.appendHtmlConstant("</table>");
    inside.appendHtmlConstant("</div>");

    frame.render(sb,
            new Frame.FrameOptions(0, CommonStyles.get().noFocusOutline(), stylesBuilder.toSafeStyles()),
            inside.toSafeHtml());

    sb.appendHtmlConstant("</div>");

}

From source file:org.cloudcoder.app.client.view.OkDialogBox.java

License:Open Source License

public OkDialogBox(String title, String message) {
    setTitle(title);/*ww  w .  ja  v a 2 s .co  m*/
    setGlassEnabled(true);

    FlowPanel panel = new FlowPanel();
    panel.add(new HTML(new SafeHtmlBuilder().appendEscaped(message).toSafeHtml()));
    Button ok = new Button("OK");
    ok.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            hide();
        }
    });
    panel.add(ok);

    add(panel);
}

From source file:org.cloudcoder.app.client.view.ProblemDescriptionView.java

License:Open Source License

public void displayProblemDescription(Problem problem) {
    // Note: if the problem description contains HTML markup, it will
    // be rendered.  This is intentional, since it allows a greater degree
    // of control over formatting that just plain text would allow.
    StringBuilder buf = new StringBuilder();
    String description = problem.getDescription();

    // Add the description as specified in the problem.
    buf.append(description);// w  ww  .  java 2s  . c o m

    // Add author information.
    buf.append("<div class=\"cc-authorInfo\">Author: <span class=\"cc-authorName\">");
    String authorName = problem.getAuthorName();
    String authorWebsite = problem.getAuthorWebsite();
    if (!authorWebsite.trim().equals("")) {
        // Format author name as link to author website
        buf.append("<a href=\"");
        buf.append(new SafeHtmlBuilder().appendEscaped(authorWebsite).toSafeHtml().asString());
        buf.append("\">");
        buf.append(new SafeHtmlBuilder().appendEscaped(authorName).toSafeHtml().asString());
        buf.append("</a>");
    } else {
        // No author website
        buf.append(new SafeHtmlBuilder().appendEscaped(authorName).toSafeHtml().asString());
    }
    // Add license information.
    buf.append("</span><br>License: <span class=\"cc-problemLicense\"><a href=\"");
    buf.append(problem.getLicense().getUrl());
    buf.append("\">");
    buf.append(problem.getLicense().getName());
    buf.append("</a></span>");

    buf.append("</span>");
    buf.append("</div>");

    problemDescriptionHtml.setHTML(buf.toString());
}

From source file:org.cruxframework.crux.widgets.client.disposal.topmenudisposal.TopMenuDisposalLargeController.java

License:Apache License

@Override
public void addMenuEntry(final String label, final String targetView) {
    MenuItem menuItem = new MenuItem(new SafeHtmlBuilder().appendEscaped(label).toSafeHtml());
    menuItem.addStyleName("menuEntry");
    menuItem.setScheduledCommand(new ScheduledCommand() {
        @Override/*from   w w  w .j a v  a2 s .  co m*/
        public void execute() {
            showView(targetView, true);
        }
    });
    menuBar.addItem(menuItem);
}

From source file:org.dashbuilder.client.widgets.dataset.editor.column.ColumnTypeEditor.java

License:Apache License

private ImageListEditor<ColumnType>.Entry buildEntry(final ColumnType type) {
    final String name = type.name();
    final String descr = getColumnTypeDescription(type);
    final SafeUri uri = getImageUri(type);
    return columnType.newEntry(type, uri, new SafeHtmlBuilder().appendEscaped(name).toSafeHtml(),
            new SafeHtmlBuilder().appendEscaped(descr).toSafeHtml());
}