.toSafeStyles().asString());
/** * Get the HTML representation of an image. Visible for testing. * * @param res the {@link ImageResource} to render as HTML * @param valign the vertical alignment * @param isPlaceholder if true, do not include the background image * @return the rendered HTML */ SafeHtml getImageHtml(ImageResource res, VerticalAlignmentConstant valign, boolean isPlaceholder) { // Get the HTML for the image. SafeHtml image; if (isPlaceholder) { image = SafeHtmlUtils.fromSafeConstant("<div></div>"); } else { AbstractImagePrototype proto = AbstractImagePrototype.create(res); image = proto.getSafeHtml(); } // Create the wrapper based on the vertical alignment. SafeStylesBuilder cssStyles = new SafeStylesBuilder().appendTrustedString(direction + ":0px;"); if (HasVerticalAlignment.ALIGN_TOP == valign) { return template.imageWrapperTop(cssStyles.toSafeStyles(), image); } else if (HasVerticalAlignment.ALIGN_BOTTOM == valign) { return template.imageWrapperBottom(cssStyles.toSafeStyles(), image); } else { int halfHeight = (int) Math.round(res.getHeight() / 2.0); cssStyles.appendTrustedString("margin-top:-" + halfHeight + "px;"); return template.imageWrapperMiddle(cssStyles.toSafeStyles(), image); } }
@Override public SafeStyles forOpacity(double value) { SafeStylesBuilder sb = new SafeStylesBuilder(); sb.append(super.forOpacity(value)); sb.append(implIE.forOpacity(value)); return sb.toSafeStyles(); } }
public SafeHtml getSafeHtml(SafeUri url, int left, int top, int width, int height, boolean isDraggable) { SafeStylesBuilder builder = new SafeStylesBuilder(); builder.width(width, Unit.PX).height(height, Unit.PX).trustedNameAndValue("background", "url(" + url.asString() + ") " + "no-repeat " + (-left + "px ") + (-top + "px")); if (!isDraggable) { return getTemplate().image(clearImage, SafeStylesUtils.fromTrustedString(builder.toSafeStyles().asString())); } else { return getDraggableTemplate().image(clearImage, SafeStylesUtils.fromTrustedString(builder.toSafeStyles().asString())); } }
/** * Get the HTML representation of an image. * * @param res the {@link ImageResource} to render as HTML * @param isTop true if the image is for a top level element. * @return the rendered HTML */ private SafeHtml getImageHtml(ImageResource res, boolean isTop) { // Build the classes. StringBuilder classesBuilder = new StringBuilder(style.cellTreeItemImage()); if (isTop) { classesBuilder.append(" ").append(style.cellTreeTopItemImage()); } // Build the css. SafeStylesBuilder cssBuilder = new SafeStylesBuilder(); if (LocaleInfo.getCurrentLocale().isRTL()) { cssBuilder.appendTrustedString("right: 0px;"); } else { cssBuilder.appendTrustedString("left: 0px;"); } cssBuilder.appendTrustedString("width: " + res.getWidth() + "px;"); cssBuilder.appendTrustedString("height: " + res.getHeight() + "px;"); AbstractImagePrototype proto = AbstractImagePrototype.create(res); SafeHtml image = proto.getSafeHtml(); return template .imageWrapper(classesBuilder.toString(), cssBuilder.toSafeStyles(), image); }
styles.left(0, Unit.PX); iconSafeHtml = template.iconWrapper(styles.toSafeStyles(), iconOnly); CommonResources.getInlineBlockStyle(), styles.toSafeStyles(), iconSafeHtml, safeValue); int tabIndex = cell.getTabIndex(); StringBuilder openTag = new StringBuilder();
/** * Get the HTML representation of an image. * * @param res the {@link ImageResource} to render as HTML * @return the rendered HTML */ private SafeHtml getImageHtml(ImageResource res) { // Right-justify image if LTR, left-justify if RTL AbstractImagePrototype proto = AbstractImagePrototype.create(res); SafeHtml image = proto.getSafeHtml(); SafeStylesBuilder cssBuilder = new SafeStylesBuilder(); if (LocaleInfo.getCurrentLocale().isRTL()) { cssBuilder.appendTrustedString("left:0px;"); } else { cssBuilder.appendTrustedString("right:0px;"); } cssBuilder.appendTrustedString("width: " + res.getWidth() + "px;"); cssBuilder.appendTrustedString("height: " + res.getHeight() + "px;"); return template.imageWrapper(cssBuilder.toSafeStyles(), image); }
protected SafeHtml getRenderedImage(IconType value, String color) { SafeStyles styles = new SafeStylesBuilder().trustedColor(color).toSafeStyles(); return TEMPLATE.icon(value.getCssName(), styles); }
@Override public SafeStyles forOpacity(double value) { SafeStylesBuilder sb = new SafeStylesBuilder(); sb.append(super.forOpacity(value)); sb.append(implIE.forOpacity(value)); return sb.toSafeStyles(); } }
@Override public SafeStyles forOpacity(double value) { SafeStylesBuilder sb = new SafeStylesBuilder(); sb.append(super.forOpacity(value)); sb.append(implIE.forOpacity(value)); return sb.toSafeStyles(); } }
protected static SafeHtml getRenderedImage(IconType value, String color) { SafeStylesBuilder builder = new SafeStylesBuilder(); builder.trustedColor(color); builder.textAlign(TextAlign.CENTER); builder.verticalAlign(VerticalAlign.MIDDLE); SafeStyles styles = builder.toSafeStyles(); return TEMPLATE.icon(value.getCssName(), styles); } }
public SafeHtml getSafeHtml(SafeUri url, int left, int top, int width, int height, boolean isDraggable) { SafeStylesBuilder builder = new SafeStylesBuilder(); builder.width(width, Unit.PX).height(height, Unit.PX).trustedNameAndValue("background", "url(" + url.asString() + ") " + "no-repeat " + (-left + "px ") + (-top + "px")); if (!isDraggable) { return getTemplate().image(clearImage, SafeStylesUtils.fromTrustedString(builder.toSafeStyles().asString())); } else { return getDraggableTemplate().image(clearImage, SafeStylesUtils.fromTrustedString(builder.toSafeStyles().asString())); } }
public SafeHtml getSafeHtml(SafeUri url, int left, int top, int width, int height, boolean isDraggable) { SafeStylesBuilder builder = new SafeStylesBuilder(); builder.width(width, Unit.PX).height(height, Unit.PX).trustedNameAndValue("background", "url(" + url.asString() + ") " + "no-repeat " + (-left + "px ") + (-top + "px")); if (!isDraggable) { return getTemplate().image(clearImage, SafeStylesUtils.fromTrustedString(builder.toSafeStyles().asString())); } else { return getDraggableTemplate().image(clearImage, SafeStylesUtils.fromTrustedString(builder.toSafeStyles().asString())); } }
@Override public SafeHtml getValue(T object) { Integer progressValue = getProgressValue(object); int progress = progressValue != null ? progressValue : 0; String text = getProgressText(object); // Choose color by progress String color = getColorByProgress(progress); SafeStylesBuilder builder = new SafeStylesBuilder(); builder.width(progress, Unit.PCT); builder.trustedBackgroundColor(color); return templates.progressBar(builder.toSafeStyles(), text, getStyle(), DOM.createUniqueId()); }
@Override protected SafeHtml buildContainerHtml(String defaultText, SafeStylesBuilder ssb) { return ChosenTemplate.templates.contentMultiple(getCss().chznChoices(), getCss().searchField(), defaultText, getCss().defaultClass(), getCss().chznDrop(), getCss().chznResults(), ssb.toSafeStyles()); }
@Override protected SafeHtml buildContainerHtml(String defaultText, SafeStylesBuilder ssb) { return ChosenTemplate.templates.contentMultiple(getCss().chznChoices(), getCss().searchField(), defaultText, getCss().defaultClass(), getCss().chznDrop(), getCss().chznResults(), ssb.toSafeStyles()); }
@Override protected SafeHtml buildContainerHtml(String defaultText, SafeStylesBuilder ssb) { return ChosenTemplate.templates.contentSingle(getCss().chznSingle(), getCss().chznDefault(), defaultText, getCss().chznDrop(), getCss().chznSearch(), getCss().chznResults(), ssb.toSafeStyles(), getCss().iconArrow(), getCss().iconSearch()); }
@Override protected SafeHtml buildContainerHtml(String defaultText, SafeStylesBuilder ssb) { return ChosenTemplate.templates.contentSingle(getCss().chznSingle(), getCss().chznDefault(), defaultText, getCss().chznDrop(), getCss().chznSearch(), getCss().chznResults(), ssb.toSafeStyles(), getCss().iconArrow(), getCss().iconSearch()); }
@Override protected SafeHtml buildContainerHtml(String defaultText, SafeStylesBuilder ssb) { // TODO close icon... return ChosenTemplate.templates.contentMobile(getCss().chznSingle(), getCss().chznDefault(), defaultText, getCss().chznDrop(), getCss().chznSearch(), getCss().chznResults(), ssb.toSafeStyles(), getCss().iconArrow(), getCss().iconCross(), getCss().chznResultsHolder()); }
@Override protected SafeHtml buildContainerHtml(String defaultText, SafeStylesBuilder ssb) { // TODO close icon... return ChosenTemplate.templates.contentMobile(getCss().chznSingle(), getCss().chznDefault(), defaultText, getCss().chznDrop(), getCss().chznSearch(), getCss().chznResults(), ssb.toSafeStyles(), getCss().iconArrow(), getCss().iconCross(), getCss().chznResultsHolder()); }