List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder append
public SafeHtmlBuilder append(SafeHtml html)
From source file:com.tmc.client.ui.field.LookupFieldAppearance.java
License:sencha.com license
protected void renderInput(SafeHtmlBuilder shb, String value, SafeStyles inputStyles, FieldAppearanceOptions options) { StringBuilder sb = new StringBuilder(); sb.append("<input "); if (options.isDisabled()) { sb.append("disabled=true "); }/* ww w. j ava 2 s. c o m*/ if (options.getName() != null) { 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 ("".equals(value) && 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); sb.append("type='text' value='").append(SafeHtmlUtils.htmlEscape(value)).append("' "); sb.append("/>"); shb.append(SafeHtmlUtils.fromTrustedString(sb.toString())); }
From source file:com.ui.gwt.mobile.client.components.ContactListPanel.java
License:Apache License
private void render() { PerfTimer timer = PerfTimer.get(this, "render"); SafeHtmlBuilder builder = new SafeHtmlBuilder(); if (data != null) { for (Contact c : data) { builder.append(TEMPLATE.item("", AppResources.INSTANCE.css().profilePic(), c.getPicURL(), AppResources.INSTANCE.css().detailBlock(), c.getName(), c.getEmail(), c.getPhone())); }/*from www.ja va 2s .com*/ } else { builder.append(TEMPLATE.loading(AppResources.INSTANCE.css().loading(), AppResources.INSTANCE.loadingImage().getURL(), Messages.INSTANCE.listLoading())); } getElement().setInnerHTML(builder.toSafeHtml().asString()); timer.end(); }
From source file:com.ui.gwt.mobile.client.components.DetailPanel.java
License:Apache License
public void setData(Contact data) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.append(TEMPLATE.activeItem("tel:" + data.getPhone(), data.getPhone())); builder.append(TEMPLATE.activeItem("mailto:" + data.getEmail(), data.getEmail())); builder.append(TEMPLATE.activeItem(data.getWebAddr(), data.getWebAddr())); builder.append(TEMPLATE.spacer());//from www.j av a2s.com builder.append(TEMPLATE.item(data.getAddr1())); builder.append(TEMPLATE.item(data.getAddr2())); String template = TEMPLATE.detail(AppResources.INSTANCE.css().details(), "", AppResources.INSTANCE.css().profilePic(), data.getPicURL(), AppResources.INSTANCE.css().detailBlock(), data.getName(), builder.toSafeHtml()).asString(); detail.setInnerHTML(template); // buildMap(data); }
From source file:com.watopi.chosen.client.ChosenImpl.java
License:Open Source License
private void resultsBuild() { selectItems = new SelectParser().parse(selectElement); if (isMultiple && choices > 0) { searchChoices.find("li." + css.searchChoice()).remove(); choices = 0;/*from ww w .j a v a 2s . c om*/ } 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()); }
From source file:com.webgocommerce.client.uiutil.CheckCellHead.java
@Override public void render(Context context, Boolean value, SafeHtmlBuilder sb) { if (isSelected) { sb.append(INPUT_CHECKED); } else {//from w ww . j a v a 2 s . c om sb.append(INPUT_UNCHECKED); } }
From source file:com.webgocommerce.client.uiutil.CheckCellMenu.java
@Override public void render(Context context, MenuBar value, SafeHtmlBuilder sb) { if (isSelected) { sb.append(INPUT_CHECKED); } else {//w w w. j a va 2 s. c o m sb.append(INPUT_UNCHECKED); } }
From source file:de.eckhartarnold.client.Caption.java
License:Apache License
/** * Returns the current Text the caption displays. * // w ww. j av a2 s . co m * @return the HTML formatted Text of the caption */ public SafeHtml getText() { if (current == -1) return (spacing == NO_SPACING) ? emptySpacer : spacer; else { SafeHtmlBuilder builder = new SafeHtmlBuilder(); if (spacing == BOTTOM_SPACING) { builder.append(stuffings[current]); builder.append(captions[current]); return builder.toSafeHtml(); } else if (spacing == TOP_SPACING) { builder.append(captions[current]); builder.append(stuffings[current]); return builder.toSafeHtml(); } else { return captions[current]; } } }
From source file:de.knightsoftnet.navigation.client.ui.navigation.AbstractNavigationStructure.java
License:Apache License
protected SafeHtml createMenuEntry(final ImageResource pimage, final String ptext) { final SafeHtmlBuilder menuShb = new SafeHtmlBuilder(); menuShb.append(AbstractImagePrototype.create(pimage).getSafeHtml()).append(' ').appendEscaped(ptext); return menuShb.toSafeHtml(); }
From source file:de.uni_koeln.spinfo.maalr.webapp.ui.editor.client.entry.list.wrapper.LemmaVersionCellWrapper.java
License:Apache License
@Override public SafeHtml getUserDetails() { LightUserInfo userInfo = lemma.getUserInfo(); SafeHtmlBuilder builder = new SafeHtmlBuilder(); if (userInfo != null && userInfo.getRole() != Role.GUEST_1) { String firstName = userInfo.getFirstName(); String lastName = userInfo.getLastName(); if (firstName != null && lastName != null) { builder.append(templates.userName(firstName, lastName)); } else {//from ww w. ja v a 2 s . co m builder.append(templates.login(userInfo.getLogin())); } if (lemma.getIP() != null) { builder.append(templates.ipSmall(lemma.getIP())); } else { builder.append(templates.ipSmall(constants.unknownIp())); } } else { if (lemma.getIP() != null) { builder.append(templates.ipDefault(lemma.getIP())); } else { builder.append(templates.ipDefault(constants.unknownIp())); } } return builder.toSafeHtml(); }
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; }// www . ja va2 s. 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()); }