+ (-left + "px ") + (-top + "px"); SafeStylesBuilder builder = new SafeStylesBuilder(); builder.trustedNameAndValue("background", background) .width(width, Unit.PX).height(height, Unit.PX)
@Override public SafeStyles forOpacity(double value) { SafeStylesBuilder sb = new SafeStylesBuilder(); sb.append(super.forOpacity(value)); sb.append(implIE.forOpacity(value)); return sb.toSafeStyles(); } }
/** * 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); }
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()) { SafeStylesBuilder styles = new SafeStylesBuilder(); int iconWidth = (icon == null) ? 0 : icon.getWidth(); int iconPadding = iconWidth + DEFAULT_ICON_PADDING;
/** * 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); } }
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 * @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); } }
/** * 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 = SafeHtmlUtils.fromTrustedString(proto.getHTML()); return template .imageWrapper(classesBuilder.toString(), cssBuilder.toSafeStyles(), image); }
/** * 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 = SafeHtmlUtils.fromTrustedString(proto.getHTML()); return template .imageWrapper(classesBuilder.toString(), cssBuilder.toSafeStyles(), image); }
@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()); }
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())); } }
/** * 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 = SafeHtmlUtils.fromTrustedString(proto.getHTML()); 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); }
/** * 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 = SafeHtmlUtils.fromTrustedString(proto.getHTML()); 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 void render(SafeHtmlBuilder sb, String value, FieldCell.FieldAppearanceOptions options) { int width = options.getWidth(); if (width == -1) { width = 150; } SafeStylesBuilder inputStylesBuilder = new SafeStylesBuilder(); inputStylesBuilder.appendTrustedString("width:100%;"); sb.appendHtmlConstant("<div style='width:" + width + "px;'>"); sb.appendHtmlConstant("<div class='" + RESOURCES.style().wrap() + "'>"); renderInput(sb, value, inputStylesBuilder.toSafeStyles(), options); sb.appendHtmlConstant("<span class='" + InputResources.INSTANCE.style().fieldUnits() + "'>"); sb.appendEscaped(units); sb.appendHtmlConstant("</span>"); sb.appendHtmlConstant("</div></div>"); }
@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$ }