+ (-left + "px ") + (-top + "px"); SafeStylesBuilder builder = new SafeStylesBuilder(); builder.trustedNameAndValue("background", background) .width(width, Unit.PX).height(height, Unit.PX) .paddingRight(paddingRight, Unit.PX); .toSafeStyles().asString());
/** * 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); }
@Override public SafeStyles forOpacity(double value) { SafeStylesBuilder sb = new SafeStylesBuilder(); sb.append(super.forOpacity(value)); sb.append(implIE.forOpacity(value)); return sb.toSafeStyles(); } }
SafeHtml iconOnly = proto.getSafeHtml(); int halfHeight = (int) Math.round(icon.getHeight() / 2.0); SafeStylesBuilder styles = new SafeStylesBuilder(); styles.marginTop(-halfHeight, Unit.PX); if (LocaleInfo.getCurrentLocale().isRTL()) { styles.right(0, Unit.PX); } else { styles.left(0, Unit.PX); iconSafeHtml = template.iconWrapper(styles.toSafeStyles(), iconOnly); SafeStylesBuilder styles = new SafeStylesBuilder(); int iconWidth = (icon == null) ? 0 : icon.getWidth(); int iconPadding = iconWidth + DEFAULT_ICON_PADDING; if (LocaleInfo.getCurrentLocale().isRTL()) { styles.paddingRight(iconPadding, Unit.PX); } else { styles.paddingLeft(iconPadding, Unit.PX); CommonResources.getInlineBlockStyle(), styles.toSafeStyles(), iconSafeHtml, safeValue); int tabIndex = cell.getTabIndex(); StringBuilder openTag = new StringBuilder();
/** * Append the margin-left css property. */ public SafeStylesBuilder marginLeft(double value, Unit unit) { return append(SafeStylesUtils.forMarginLeft(value, unit)); }
@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()); }
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); } }
$(ChosenTemplate.templates.container(containerId, cssClasses).asString()).width(fWidth); final SafeStylesBuilder ssb = new SafeStylesBuilder(); if (isRTL) { ssb.right(HORIZONTAL_OFFSET, Style.Unit.PX); } else { ssb.left(HORIZONTAL_OFFSET, Style.Unit.PX); ssb.top(VERTICAL_OFFSET, Style.Unit.PX);
@Override public final SafeHtml getValue(LunModel object) { // TODO this should use a cell to render, not return HTML itself ScrollableTextCell.CellTemplate template = GWT.create(ScrollableTextCell.CellTemplate.class); SafeStylesBuilder builder = new SafeStylesBuilder(); if (object != null) { boolean isLunUnExtendable = object.getIsIncluded() && object.getAdditionalAvailableSize() == 0; if (object.isRemoveLunSelected()) { builder.trustedColor("black"); //$NON-NLS-1$ builder.textDecoration(TextDecoration.LINE_THROUGH); } else if (object.getIsLunRemovable()) { builder.trustedColor("black"); //$NON-NLS-1$ } else if ((!object.getIsIncluded() && object.getIsGrayedOut()) || isLunUnExtendable) { builder.trustedColor("gray"); //$NON-NLS-1$ } else if (!object.getIsAccessible() && !object.getIsGrayedOut()) { builder.trustedColor("orange"); //$NON-NLS-1$ } else if (object.getIsSelected() || object.isAdditionalAvailableSizeSelected()) { builder.trustedColor("black"); //$NON-NLS-1$ builder.fontWeight(FontWeight.BOLD); } else { builder.trustedColor("black"); //$NON-NLS-1$ } } // TODO use a proper ID return template.input(getRawValue(object), builder.toSafeStyles(), DOM.createUniqueId()); //$NON-NLS-1$ }
protected SafeHtml getRenderedImage(IconType value, String color) { SafeStyles styles = new SafeStylesBuilder().trustedColor(color).toSafeStyles(); return TEMPLATE.icon(value.getCssName(), styles); }
@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()); }
SafeHtml iconOnly = SafeHtmlUtils.fromTrustedString(proto.getHTML()); int halfHeight = (int) Math.round(icon.getHeight() / 2.0); SafeStylesBuilder styles = new SafeStylesBuilder(); styles.marginTop(-halfHeight, Unit.PX); if (LocaleInfo.getCurrentLocale().isRTL()) { styles.right(0, Unit.PX); } else { styles.left(0, Unit.PX); iconSafeHtml = template.iconWrapper(styles.toSafeStyles(), iconOnly); SafeStylesBuilder styles = new SafeStylesBuilder(); int iconWidth = (icon == null) ? 0 : icon.getWidth(); int iconPadding = iconWidth + DEFAULT_ICON_PADDING; if (LocaleInfo.getCurrentLocale().isRTL()) { styles.paddingRight(iconPadding, Unit.PX); } else { styles.paddingLeft(iconPadding, Unit.PX); CommonResources.getInlineBlockStyle(), styles.toSafeStyles(), iconSafeHtml, safeValue); int tabIndex = cell.getTabIndex(); StringBuilder openTag = new StringBuilder();
/** * Append the overflow-x CSS property. */ public SafeStylesBuilder overflowX(Overflow value) { return append(SafeStylesUtils.forOverflowX(value)); }
$(ChosenTemplate.templates.container(containerId, cssClasses).asString()).width(fWidth); final SafeStylesBuilder ssb = new SafeStylesBuilder(); if (isRTL) { ssb.right(HORIZONTAL_OFFSET, Style.Unit.PX); } else { ssb.left(HORIZONTAL_OFFSET, Style.Unit.PX); ssb.top(VERTICAL_OFFSET, Style.Unit.PX);
@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()); }
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. 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); } }
SafeHtml iconOnly = SafeHtmlUtils.fromTrustedString(proto.getHTML()); int halfHeight = (int) Math.round(icon.getHeight() / 2.0); SafeStylesBuilder styles = new SafeStylesBuilder(); styles.marginTop(-halfHeight, Unit.PX); if (LocaleInfo.getCurrentLocale().isRTL()) { styles.right(0, Unit.PX); } else { styles.left(0, Unit.PX); iconSafeHtml = template.iconWrapper(styles.toSafeStyles(), iconOnly); SafeStylesBuilder styles = new SafeStylesBuilder(); int iconWidth = (icon == null) ? 0 : icon.getWidth(); int iconPadding = iconWidth + DEFAULT_ICON_PADDING; if (LocaleInfo.getCurrentLocale().isRTL()) { styles.paddingRight(iconPadding, Unit.PX); } else { styles.paddingLeft(iconPadding, Unit.PX); CommonResources.getInlineBlockStyle(), styles.toSafeStyles(), iconSafeHtml, safeValue); int tabIndex = cell.getTabIndex(); StringBuilder openTag = new StringBuilder();
@Override public SafeStyles forOpacity(double value) { SafeStylesBuilder sb = new SafeStylesBuilder(); sb.append(super.forOpacity(value)); sb.append(implIE.forOpacity(value)); return sb.toSafeStyles(); } }
/** * Append the right css property. */ public SafeStylesBuilder right(double value, Unit unit) { return append(SafeStylesUtils.forRight(value, unit)); }