List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder append
public SafeHtmlBuilder append(SafeHtml html)
From source file:com.sencha.gxt.theme.base.client.button.IconButtonDefaultAppearance.java
License:sencha.com license
@Override public void render(SafeHtmlBuilder sb) { sb.append(template.render(style)); }
From source file:com.sencha.gxt.theme.base.client.colorpalette.ColorPaletteBaseAppearance.java
License:sencha.com license
@Override public void render(Context context, String value, String[] colors, String[] labels, SafeHtmlBuilder result) { result.appendHtmlConstant("<table class=\"" + style.colorPalette() + "\">"); int mark = 0; int rows = (colors.length + (columnCount - 1)) / columnCount; for (int i = 0; i < rows; i++) { result.appendHtmlConstant("<tr>"); for (int j = 0; j < columnCount && mark < colors.length; j++) { String c = colors[mark]; String label = labels[mark]; SafeHtml cellTemplate = template.cellTemplate(style, label, XDOM.getUniqueId(), i, j, c, SafeStylesUtils/*www . j av a2s . c om*/ .fromTrustedString("background-color: #" + SafeHtmlUtils.htmlEscape(c) + ";"), c.equals(value) ? style.selected() : ""); result.append(cellTemplate); mark++; } result.appendHtmlConstant("</tr>"); } result.appendHtmlConstant("</table>"); }
From source file:com.sencha.gxt.theme.base.client.container.PortalLayoutDefaultAppearance.java
License:sencha.com license
@Override public void renderInsert(SafeHtmlBuilder sb) { sb.append(template.render(resources.css())); }
From source file:com.sencha.gxt.theme.base.client.container.ViewportDefaultAppearance.java
License:sencha.com license
@Override public void render(SafeHtmlBuilder sb) { sb.append(templates.template(resources.style())); }
From source file:com.sencha.gxt.theme.base.client.field.CheckBoxDefaultAppearance.java
License:sencha.com license
@Override public void render(SafeHtmlBuilder sb, Boolean value, CheckBoxCellOptions options) { String checkBoxId = XDOM.getUniqueId(); String nameParam = options.getName() != null ? " name='" + options.getName() + "' " : ""; String disabledParam = options.isDisabled() ? " disabled=true" : ""; String readOnlyParam = options.isReadonly() ? " readonly" : ""; String idParam = " id=" + checkBoxId; String typeParam = " type=" + type; String checkedParam = value ? " checked" : ""; sb.appendHtmlConstant("<div class=" + style.wrap() + ">"); sb.appendHtmlConstant(//from w w w . j a v a2 s .c om "<input " + typeParam + nameParam + disabledParam + readOnlyParam + idParam + checkedParam + " />"); sb.appendHtmlConstant("<label for=" + checkBoxId + " class=" + style.checkBoxLabel() + ">"); sb.append(options.getBoxLabel()); sb.appendHtmlConstant("</label></div>"); }
From source file:com.sencha.gxt.theme.base.client.field.FieldLabelDefaultAppearance.java
License:sencha.com license
@Override public void onUpdateOptions(XElement parent, FieldLabelOptions options) { LabelAlign labelAlign = options.getLabelAlign(); XElement fieldElement = getChildElementWrapper(parent); XElement labelElement = getLabelElement(parent); // Adjust for label content, label separator SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.append(options.getContent()); sb.appendEscaped(options.getLabelSeparator()); labelElement.setInnerSafeHtml(sb.toSafeHtml()); // Adjust for label alignment if (labelAlign == LabelAlign.TOP) { parent.addClassName(style.fieldItemLabelTop()); } else {/* w ww . j av a2 s .c om*/ parent.removeClassName(style.fieldItemLabelTop()); } // Adjust for label width if (labelAlign == LabelAlign.TOP) { labelElement.getStyle().setProperty("width", "auto"); fieldElement.getStyle().setPaddingLeft(0, Unit.PX); } else { int pad = options.getLabelPad(); if (pad == 0) pad = 5; labelElement.getStyle().setWidth(options.getLabelWidth(), Unit.PX); fieldElement.getStyle().setPaddingLeft(options.getLabelWidth() + pad, Unit.PX); } // Adjust for label word wrap labelElement.getStyle().setProperty("whiteSpace", options.getWordWrap() ? "normal" : "nowrap"); }
From source file:com.sencha.gxt.theme.base.client.field.FieldLabelDefaultAppearance.java
License:sencha.com license
@Override public void render(SafeHtmlBuilder sb, String id, FieldLabelOptions options) { int labelWidth = options.getLabelWidth(); LabelAlign align = options.getLabelAlign(); int pad = options.getLabelPad(); if (pad == 0) pad = 5;// ww w.j av a 2 s . c o m String fieldLabelWidth = align == LabelAlign.TOP ? "auto" : (labelWidth + "px"); SafeStylesBuilder fieldLabelStylesBuilder = new SafeStylesBuilder() .appendTrustedString("width:" + fieldLabelWidth + ";"); fieldLabelStylesBuilder .appendTrustedString("white-space: " + (options.getWordWrap() ? "normal" : "nowrap") + ";"); SafeStyles fieldLabelStyles = fieldLabelStylesBuilder.toSafeStyles(); String fieldElementPadding = align == LabelAlign.TOP ? "0" : (labelWidth + pad + "px"); SafeStyles fieldElementStyles = SafeStylesUtils .fromTrustedString("padding-left:" + fieldElementPadding + ";"); sb.append(template.render(id, style, fieldLabelStyles, fieldElementStyles)); }
From source file:com.sencha.gxt.theme.base.client.field.FieldSetDefaultAppearance.java
License:sencha.com license
@Override public void render(SafeHtmlBuilder sb) { sb.append(template.render(style, GXT.isGecko())); }
From source file:com.sencha.gxt.theme.base.client.field.TextAreaDefaultAppearance.java
License:sencha.com license
@Override public void render(SafeHtmlBuilder sb, String value, FieldAppearanceOptions options) { int width = options.getWidth(); int height = options.getHeight(); boolean empty = false; String name = options.getName() != null ? " name='" + options.getName() + "' " : ""; String disabled = options.isDisabled() ? " disabled=true" : ""; String ro = options.isReadonly() ? " readonly" : ""; String placeholder = options.getEmptyText() != null ? " placeholder='" + SafeHtmlUtils.htmlEscape(options.getEmptyText()) + "' " : ""; if ((value == null || value.equals("")) && options.getEmptyText() != null) { if (GXT.isIE8() || GXT.isIE9()) { value = options.getEmptyText(); }//from ww w . j a v a 2 s. co m empty = true; } if (width == -1) { width = 150; } String inputStyles = ""; String wrapStyles = ""; 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(); } 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:com.sencha.gxt.theme.base.client.field.TriggerFieldDefaultAppearance.java
License:sencha.com license
/** * Helper method to render the input in the trigger field. *///from w w w. j a va2 s.c om protected void renderInput(SafeHtmlBuilder shb, String value, SafeStyles inputStyles, FieldAppearanceOptions options) { // Deliberately using a StringBuilder, not SafeHtmlBuilder, as each append isn't adding // complete elements, but building up this single element, one attribute at a time. StringBuilder sb = new StringBuilder(); sb.append("<input "); if (options.isDisabled()) { sb.append("disabled=true "); } if (options.getName() != null) { // if set, escape the name property so it is a valid attribute sb.append("name='").append(SafeHtmlUtils.htmlEscape(options.getName())).append("' "); } if (options.isReadonly() || !options.isEditable()) { sb.append("readonly "); } if (inputStyles != null) { sb.append("style='").append(inputStyles.asString()).append("' "); } sb.append("class='").append(getStyle().field()).append(" ").append(getStyle().text()); String placeholder = options.getEmptyText() != null ? " placeholder='" + SafeHtmlUtils.htmlEscape(options.getEmptyText()) + "' " : ""; if (value.equals("") && options.getEmptyText() != null) { sb.append(" ").append(getStyle().empty()); if (GXT.isIE8() || GXT.isIE9()) { value = options.getEmptyText(); } } if (!options.isEditable()) { sb.append(" ").append(getStyle().noedit()); } sb.append("' "); sb.append(placeholder); //escaping the value string so it is a valid attribute sb.append("type='text' value='").append(SafeHtmlUtils.htmlEscape(value)).append("'/>"); // finally, converting stringbuilder into a SafeHtml instance and appending it // to the buidler we were given shb.append(SafeHtmlUtils.fromTrustedString(sb.toString())); }