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

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

Introduction

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

Prototype

public SafeHtmlBuilder appendHtmlConstant(String html) 

Source Link

Document

Appends a compile-time-constant string, which will not be escaped.

Usage

From source file:de.uni_koeln.spinfo.maalr.webapp.ui.user.client.search.celltable.ResultCellTable.java

License:Apache License

private void addColumnB(String langB, final boolean b) {
    columnB = new Column<LemmaVersion, SafeHtml>(new SafeHtmlCell()) {

        @Override//from   w  w w  . ja v a 2  s .c  o  m
        public SafeHtml getValue(LemmaVersion object) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            String toDisplay = description.toString(object, UseCase.RESULT_LIST, b);
            String redirect = b ? object.getEntryValue("redirect_a") : object.getEntryValue("redirect_b");
            if (maalrQuery.isHighlight() && redirect == null) {
                toDisplay = Highlighter.highlight(toDisplay, maalrQuery.getValue("searchPhrase"));
            }
            if (redirect != null) {
                MaalrQuery mq = new MaalrQuery();
                String[] redir = redirect.split("=");
                mq.setQueryValue(redir[0], redir[1]);
                String text = redir[1];
                if (maalrQuery.isHighlight()) {
                    text = Highlighter.highlight(text, maalrQuery.getValue("searchPhrase"));
                }
                String url = "<a href=\"" + Window.Location.getPath() + "#" + mq.toURL() + "\">" + text
                        + "</a>";
                toDisplay = toDisplay.replace(redir[1], url);
                // toDisplay = "<a href=\"" + mq.toURL() + "\">" + redir[1]
                // + "</a>";
            }
            if (!object.isApproved()) {
                toDisplay = "<span class=\"unverified\">" + toDisplay + "</span>";
            }
            // if (!b)
            // sb.appendHtmlConstant(refereTo(toDisplay));
            // else
            sb.appendHtmlConstant(toDisplay);
            return sb.toSafeHtml();
        }

    };
    cellTable.addColumn(columnB, new SafeHtmlBuilder()
            .appendHtmlConstant("<span class=\"maalr_result_title\">" + langB + "</span>").toSafeHtml());
}

From source file:de.yarkon.gwt.eventcalendar.client.EventTable.java

License:Open Source License

public EventTable(Date month) {
    super();/*from   w  w w . j  a  v  a 2  s.c  om*/

    TableResources.INSTANCE.cellTableStyle().ensureInjected();

    this.setMonth(month);

    setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);

    // Anchor column for the name of the event
    Column<EventInfo, EventInfo> nameColumn = new Column<EventInfo, EventInfo>(new AbstractCell<EventInfo>() {

        @Override
        public void render(com.google.gwt.cell.client.Cell.Context context, EventInfo value,
                SafeHtmlBuilder sb) {
            if (value == null) {
                return;
            }

            // Append some HTML that sets the text color.
            sb.appendHtmlConstant("<a target=\"_blank\" href=\"" + value.getLinkURL() + "\">");
            sb.appendEscaped(value.getEvent());
            sb.appendHtmlConstant("</a>");
        }
    }) {

        @Override
        public EventInfo getValue(EventInfo object) {
            return object;
        }
    };

    addColumn(nameColumn, "Veranstaltung");
    addColumnStyleName(0, "cellTableColumn-event");

    // Add a date column
    TextColumn<EventInfo> dateColumn = new TextColumn<EventInfo>() {
        @Override
        public String getValue(EventInfo object) {
            return dateShortFormat.format(object.getDate());
        }
    };
    addColumn(dateColumn, "Datum");
    addColumnStyleName(1, "cellTableColumn-date");

    // Add a text column to show location of the event.

    TextColumn<EventInfo> locationColumn = new TextColumn<EventInfo>() {
        @Override
        public String getValue(EventInfo object) {
            return object.getLocation();
        }
    };

    addColumn(locationColumn, "Ort");
    addColumnStyleName(2, "cellTableColumn-loc");

    addStyleName("cellTable");
    setRowStyles(new RowStyles<EventInfo>() {
        @Override
        public String getStyleNames(EventInfo row, int rowIndex) {
            return "cellTableRow";
        }
    });
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.button.Css3ButtonCellAppearance.java

License:sencha.com license

@Override
public void render(ButtonCell<M> cell, Context context, M 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 arrowClass = "";
    String scaleClass = "";
    String iconClass = "";

    int width = cell.getWidth();
    int height = cell.getHeight();
    boolean hasIcon = cell.getIcon() != null;
    boolean isSplitButton = cell instanceof SplitButtonCell;
    boolean hasMenu = cell.getMenu() != null;

    boolean hasWidth = width != -1;

    if (cell.getMenu() != null) {

        if (cell instanceof SplitButtonCell) {
            switch (cell.getArrowAlign()) {
            case RIGHT:
                arrowClass = style.split();
                break;
            case BOTTOM:
                arrowClass = style.splitBottom();
                break;
            }/*from ww w  .j  av a 2s  .  c  o m*/

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

    }

    ButtonScale scale = cell.getScale();

    switch (scale) {
    case SMALL:
        scaleClass = style.small();
        break;

    case MEDIUM:
        scaleClass = style.medium();
        break;

    case LARGE:
        scaleClass = style.large();
        break;
    }

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

    String buttonClass = style.button();
    boolean hasText = text != null && !text.equals("");
    if (!hasText) {
        buttonClass += " " + style.noText();
    }

    // toggle button
    if (value == Boolean.TRUE) {
        buttonClass += " " + style.pressed();
    }

    String innerClass = style.buttonInner() + " " + iconClass;

    innerClass += " " + arrowClass;
    innerClass += " " + scaleClass;

    SafeHtmlBuilder builder = new SafeHtmlBuilder();

    SafeStylesBuilder ss = new SafeStylesBuilder();

    if (height != -1) {
        ButtonDetails bd = resources.theme().button();
        EdgeDetails padding = bd.padding();
        EdgeDetails paddingInner = bd.radiusMinusBorderWidth();
        int ah = height;
        ah -= padding.top();
        ah -= padding.bottom();
        ah -= paddingInner.top();
        ah -= paddingInner.bottom();

        ss.appendTrustedString("line-height: " + ah + "px;");
    }

    builder.appendHtmlConstant("<div class='" + buttonClass + "'>");

    // get iconbuilder ready
    SafeHtmlBuilder iconBuilder = new SafeHtmlBuilder();
    if (icon != null) {
        int iconWidth = icon != null ? icon.getWidth() : 0;
        int iconHeight = icon != null ? icon.getHeight() : 0;
        String styles = "width: " + iconWidth + "px; height: " + iconHeight + "px;";

        iconBuilder.appendHtmlConstant("<div class='" + iconClass + "' style='" + styles + "'>");
        iconBuilder.append(AbstractImagePrototype.create(icon).getSafeHtml());
        iconBuilder.appendHtmlConstant("</div>");
    }

    // for left / right aligned icons with a fixed button width we render the icon outside of the inner div
    if (hasWidth && hasIcon && iconAlign == IconAlign.LEFT) {
        builder.append(iconBuilder.toSafeHtml());
    }

    if (hasWidth && hasIcon && (iconAlign == IconAlign.LEFT)) {
        int tw = width - (resources.theme().button().borderRadius() * 2);
        if (isSplitButton && cell.getArrowAlign() == ButtonArrowAlign.RIGHT) {
            tw -= resources.split().getWidth() + 10;
        }

        if (!isSplitButton && iconAlign == IconAlign.LEFT && hasMenu
                && cell.getArrowAlign() == ButtonArrowAlign.RIGHT) {
            tw -= resources.arrow().getWidth() + 10;
        }

        if (hasIcon && iconAlign == IconAlign.LEFT) {
            tw -= icon.getWidth();
        }

        ss.appendTrustedString("width: " + tw + "px;");
    }

    builder.appendHtmlConstant("<div class='" + innerClass + "' style='" + ss.toSafeStyles().asString() + "'>");

    if (icon != null) {
        if ((!hasWidth && iconAlign == IconAlign.LEFT) || iconAlign == IconAlign.TOP) {
            builder.append(iconBuilder.toSafeHtml());
        }
        builder.appendHtmlConstant(text);
        if (iconAlign == IconAlign.RIGHT || iconAlign == IconAlign.BOTTOM) {
            builder.append(iconBuilder.toSafeHtml());
        }
    } else {
        builder.appendHtmlConstant(text);
    }

    builder.appendHtmlConstant("</div></div>");
    sb.append(builder.toSafeHtml());
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.field.Css3TextAreaAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb, String value, FieldAppearanceOptions options) {
    String inputStyles = "";
    String wrapStyles = "";

    int width = options.getWidth();
    int height = options.getHeight();

    String name = options.getName() != null ? "name='" + options.getName() + "'" : "";
    String disabled = options.isDisabled() ? "disabled=true" : "";
    String placeholder = options.getEmptyText() != null
            ? " placeholder='" + SafeHtmlUtils.htmlEscape(options.getEmptyText()) + "' "
            : "";

    boolean empty = false;

    if ((value == null || value.equals("")) && options.getEmptyText() != null) {
        if (GXT.isIE8() || GXT.isIE9()) {
            value = options.getEmptyText();
        }//from  w  w  w. j  a v  a2s. com
        empty = true;
    }

    Size adjusted = adjustTextAreaSize(width, height);

    if (width != -1) {
        wrapStyles += "width:" + width + "px;";
        width = adjusted.getWidth();
        inputStyles += "width:" + width + "px;";
    }

    if (height != -1) {
        height = adjusted.getHeight();
        inputStyles += "height: " + height + "px;";
    }

    String cls = style.area() + " " + style.field();
    if (empty) {
        cls += " " + style.empty();
    }

    String ro = options.isReadonly() ? " readonly" : "";

    if (options instanceof TextAreaCellOptions) {
        TextAreaCellOptions opts = (TextAreaCellOptions) options;
        inputStyles += "resize:" + opts.getResizable().name().toLowerCase() + ";";
    }

    sb.appendHtmlConstant("<div style='" + wrapStyles + "' class='" + style.wrap() + "'>");
    sb.appendHtmlConstant("<textarea " + name + disabled + " style='" + inputStyles + "' type='text' class='"
            + cls + "'" + ro + placeholder + ">");
    sb.append(SafeHtmlUtils.fromString(value));
    sb.appendHtmlConstant("</textarea></div>");
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.field.Css3TextFieldAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb, String type, String value, FieldAppearanceOptions options) {
    String inputStyles = "";
    String wrapStyles = "";

    int width = options.getWidth();

    String name = options.getName() != null ? " name='" + options.getName() + "' " : "";
    String disabled = options.isDisabled() ? "disabled=true" : "";
    String placeholder = options.getEmptyText() != null
            ? " placeholder='" + SafeHtmlUtils.htmlEscape(options.getEmptyText()) + "' "
            : "";

    boolean empty = false;

    if ((value == null || value.equals("")) && options.getEmptyText() != null) {
        if (GXT.isIE8() || GXT.isIE9()) {
            value = options.getEmptyText();
        }//from  w  ww .j av  a 2 s  .co  m
        empty = true;
    }

    if (width != -1) {
        wrapStyles += "width:" + width + "px;";
        width = adjustTextAreaWidth(width);
        inputStyles += "width:" + width + "px;";
    }

    String cls = style.text() + " " + style.field();
    if (empty) {
        cls += " " + style.empty();
    }

    String ro = options.isReadonly() ? " readonly" : "";

    value = SafeHtmlUtils.htmlEscape(value);

    sb.appendHtmlConstant("<div style='" + wrapStyles + "' class='" + style.wrap() + "'>");
    sb.appendHtmlConstant("<input " + name + disabled + " value='" + value + "' style='" + inputStyles
            + "' type='" + type + "' class='" + cls + "'" + ro + placeholder + ">");

}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.field.Css3TriggerFieldAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb, String value, FieldAppearanceOptions options) {
    int width = options.getWidth();
    boolean hideTrigger = options.isHideTrigger();

    if (width == -1) {
        width = 150;/*w w w. j a v a  2 s . com*/
    }

    SafeStylesBuilder inputStylesBuilder = new SafeStylesBuilder();
    inputStylesBuilder.appendTrustedString("width:100%;");

    // outer div needed for widgets like comboBox that need the full width to set for listview width
    sb.appendHtmlConstant("<div style='width:" + width + "px;'>");

    if (hideTrigger) {
        sb.appendHtmlConstant("<div class='" + style.wrap() + "'>");
        renderInput(sb, value, inputStylesBuilder.toSafeStyles(), options);
    } else {
        FieldDetails fieldDetails = getResources().theme().field();

        int rightPadding = fieldDetails.padding().right();
        sb.appendHtmlConstant("<div class='" + style.wrap() + "' style='padding-right:"
                + (getResources().triggerArrow().getWidth() + rightPadding) + "px;'>");
        renderInput(sb, value, inputStylesBuilder.toSafeStyles(), options);

        int right = fieldDetails.borderWidth() + 1;
        int halfHeight = getResources().triggerArrow().getHeight() / 2;
        SafeStyles triggerStyle = SafeStylesUtils
                .fromTrustedString("margin-top:-" + halfHeight + "px;right:" + right + "px;");
        sb.appendHtmlConstant(
                "<div class='" + getStyle().trigger() + "' style='" + triggerStyle.asString() + "'></div>");
    }

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

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.field.Css3TwinTriggerFieldAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb, String value, FieldAppearanceOptions options) {
    int width = options.getWidth();
    boolean hideTrigger = options.isHideTrigger();

    if (width == -1) {
        width = 150;/*from   w w  w .  j  a  va  2  s. c  om*/
    }

    SafeStylesBuilder inputStylesBuilder = new SafeStylesBuilder();
    inputStylesBuilder.appendTrustedString("width:100%;");

    sb.appendHtmlConstant("<div style='width:" + width + "px;'>");

    if (hideTrigger) {
        sb.appendHtmlConstant("<div class='" + style.wrap() + "'>");
        renderInput(sb, value, inputStylesBuilder.toSafeStyles(), options);
    } else {
        FieldDetails fieldDetails = getResources().theme().field();

        int rightPadding = fieldDetails.padding().right();
        sb.appendHtmlConstant("<div class='" + style.wrap() + "' style='padding-right:"
                + (getResources().triggerArrow().getWidth() + rightPadding) + "px;'>");
        renderInput(sb, value, inputStylesBuilder.toSafeStyles(), options);

        int triggerWrapTopMargin = -(getTriggerWrapHeight() / 2);

        sb.appendHtmlConstant("<div class='" + getStyle().triggerWrap() + "' style='margin-top:"
                + triggerWrapTopMargin + "px;'>");
        sb.appendHtmlConstant("<div class='" + getStyle().trigger() + "'></div>");
        sb.appendHtmlConstant("<div class='" + getStyle().twinTrigger() + "'></div>");
        sb.appendHtmlConstant("</div>");
    }

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

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.tree.Css3TreeAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb) {
    // EXTGWT-3113 the inner table is needed so that the tree nodes are as wide as needed with horizontal scrolling
    if (GXT.isIE6() || GXT.isIE7()) {
        sb.appendHtmlConstant("<div class=" + style.tree() + " style=\"position: relative;\"></div>");
    } else {/*w ww .  j a v a  2s .  c  o  m*/
        sb.appendHtmlConstant("<div class=" + style.tree()
                + " style=\"position: relative;\"><table cellpadding=0 cellspacing=0 width=100%><tr><td></td></tr></table></div>");
    }
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.widget.Css3CollapsePanelAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb, LayoutRegion region) {
    String cls = style.panel();//  w  ww  . j  av  a2 s  .  co m

    switch (region) {
    case WEST:
        cls += " " + style.west();
        break;
    case EAST:
        cls += " " + style.east();
        break;
    case NORTH:
        cls += " " + style.north();
        break;
    case SOUTH:
        cls += " " + style.south();
        break;
    }

    sb.appendHtmlConstant("<div class='" + cls + "'>");
    sb.appendHtmlConstant("<div class='" + style.iconWrap() + "'></div>");
    sb.appendHtmlConstant("</div>");
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.widget.Css3DatePickerAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb) {
    sb.appendHtmlConstant("<div class=" + style.datePicker() + ">");

    sb.appendHtmlConstant("<table width=100% cellpadding=0 cellspacing=0 class=" + style.header() + "><tr>");
    sb.appendHtmlConstant(/*from   ww  w  . ja  v a2s. c om*/
            "<td class=" + style.monthLeft() + "><div class=" + style.monthLeftButton() + "></div></td>");
    sb.appendHtmlConstant("<td class=" + style.middle() + " align=center>");

    sb.appendHtmlConstant("<table cellpadding=0 cellspacing=0 class=" + style.monthButton() + "><tr>");
    sb.appendHtmlConstant("<td class=" + style.monthButtonText() + "></td><td><div class=" + style.downIcon()
            + ">&nbsp;</div></td></tr></table>");

    sb.appendHtmlConstant("</td>");
    sb.appendHtmlConstant("<td class=" + style.monthRight() + "><div class=" + style.monthRightButton()
            + "></div></td></tr></table>");

    sb.appendHtmlConstant("<div role=grid><table width=100% cellpadding=0 cellspacing=0 class="
            + style.daysWrap() + "><thead><tr>");
    for (int i = 0; i < 7; i++) {
        sb.appendHtmlConstant("<th class=" + style.columnHeader() + "><span class=" + style.columnHeaderInner()
                + ">" + i + "</span></th>");
    }
    sb.appendHtmlConstant("</tr></thead>");

    sb.appendHtmlConstant("<tbody>");
    for (int i = 0; i < 6; i++) {
        sb.appendHtmlConstant("<tr>");
        for (int j = 0; j < 7; j++) {
            sb.appendHtmlConstant(
                    "<td class=" + style.date() + "><a href=# class=" + style.dateAnchor() + "></a></td>");
        }
        sb.appendHtmlConstant("</tr>");
    }
    sb.appendHtmlConstant("</tbody></table></div>");

    sb.appendHtmlConstant("<table width=100% cellpadding=0 cellspacing=0><tr><td class=" + style.bottom()
            + " align=center></td></tr></table>");

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

}