List of usage examples for com.google.gwt.safecss.shared SafeStylesBuilder toSafeStyles
public SafeStyles toSafeStyles()
From source file:com.arcbees.chosen.client.AbstractMobileChosenImpl.java
License:Apache License
@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()); }
From source file:com.arcbees.chosen.client.DesktopMultipleChosenImpl.java
License:Apache License
@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()); }
From source file:com.arcbees.chosen.client.DesktopSingleChosenImpl.java
License:Apache License
@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()); }
From source file:com.eas.grid.cells.TreeExpandableCell.java
@Override public void render(Context context, C value, SafeHtmlBuilder sb) { if (treeProvider != null) { SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder(); cell.render(context, value, cellBuilder); int deepness = getDeepness(context); int outerDivPadding = indent * deepness; SafeStylesBuilder styles = new SafeStylesBuilder(); if (deepness > 0) { styles.paddingLeft(outerDivPadding, Style.Unit.PX); }//from w w w.java 2s. c o m styles.position(Style.Position.RELATIVE).height(100, Style.Unit.PCT).toSafeStyles(); sb.append(template.outerDiv(outerDivClasses(context), styles.toSafeStyles(), cellBuilder.toSafeHtml())); } else { cell.render(context, value, sb); } }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.layout.PortalLayoutContainerUiBinderExample.java
License:sencha.com license
@UiFactory() public Grid<Stock> createGrid() { final NumberFormat number = NumberFormat.getFormat("0.00"); ColumnConfig<Stock, String> nameCol = new ColumnConfig<Stock, String>(props.name(), 200, "Company"); ColumnConfig<Stock, String> symbolCol = new ColumnConfig<Stock, String>(props.symbol(), 100, "Symbol"); ColumnConfig<Stock, Double> lastCol = new ColumnConfig<Stock, Double>(props.last(), 75, "Last"); ColumnConfig<Stock, Double> changeCol = new ColumnConfig<Stock, Double>(props.change(), 100, "Change"); changeCol.setCell(new AbstractCell<Double>() { @Override// ww w . j a v a 2 s. co m public void render(Context context, Double value, SafeHtmlBuilder sb) { SafeStylesBuilder stylesBuilder = new SafeStylesBuilder(); stylesBuilder.appendTrustedString("color:" + (value < 0 ? "red" : "green") + ";"); String v = number.format(value); CellTemplates cellTemplates = GWT.create(CellTemplates.class); SafeHtml template = cellTemplates.template(stylesBuilder.toSafeStyles(), v, v); sb.append(template); } }); ColumnConfig<Stock, Date> lastTransCol = new ColumnConfig<Stock, Date>(props.lastTrans(), 100, "Last Updated"); lastTransCol.setCell(new DateCell(DateTimeFormat.getFormat("MM/dd/yyyy"))); List<ColumnConfig<Stock, ?>> l = new ArrayList<ColumnConfig<Stock, ?>>(); l.add(nameCol); l.add(symbolCol); l.add(lastCol); l.add(changeCol); l.add(lastTransCol); ColumnModel<Stock> cm = new ColumnModel<Stock>(l); ListStore<Stock> store = new ListStore<Stock>(props.key()); store.addAll(TestData.getStocks()); final Grid<Stock> grid = new Grid<Stock>(store, cm); grid.getView().setAutoExpandColumn(nameCol); grid.setBorders(false); grid.getView().setStripeRows(true); grid.getView().setColumnLines(true); // needed to enable quicktips (qtitle for the heading and qtip for the // content) that are setup in the change GridCellRenderer new QuickTip(grid); return grid; }
From source file:com.novartis.pcs.ontology.webapp.client.view.ActionIconCellDecorator.java
License:Apache License
private SafeHtml getImageHtml(ImageResource res, VerticalAlignmentConstant valign) { AbstractImagePrototype proto = AbstractImagePrototype.create(res); SafeHtml image = SafeHtmlUtils.fromTrustedString(proto.getHTML()); // Create the wrapper based on the vertical alignment. SafeStylesBuilder cssStyles = new SafeStylesBuilder().appendTrustedString(direction + ":0px;"); if (HasVerticalAlignment.ALIGN_TOP == valign) { return templates.imageWrapperTop(cssStyles.toSafeStyles(), image); } else if (HasVerticalAlignment.ALIGN_BOTTOM == valign) { return templates.imageWrapperBottom(cssStyles.toSafeStyles(), image); } else {//from www.java 2 s . c o m int halfHeight = (int) Math.round(res.getHeight() / 2.0); cssStyles.appendTrustedString("margin-top:-" + halfHeight + "px;"); return templates.imageWrapperMiddle(cssStyles.toSafeStyles(), image); } }
From source file:com.sencha.gxt.theme.base.client.button.ButtonCellDefaultAppearance.java
License:sencha.com license
@Override public void render(final ButtonCell<C> cell, Context context, C 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? SafeHtml valueHtml = SafeHtmlUtils.fromTrustedString(hasConstantHtml ? cell.getText() : (value != null && !isBoolean) ? SafeHtmlUtils.htmlEscape(value.toString()) : ""); ImageResource icon = cell.getIcon(); IconAlign iconAlign = cell.getIconAlign(); String cls = style.button();/*from w ww . j ava 2 s . c o m*/ String arrowCls = ""; if (cell.getMenu() != null) { if (cell instanceof SplitButtonCell) { switch (cell.getArrowAlign()) { case RIGHT: arrowCls = style.split(); break; case BOTTOM: arrowCls = style.splitBottom(); break; default: // empty } } else { switch (cell.getArrowAlign()) { case RIGHT: arrowCls = style.arrow(); break; case BOTTOM: arrowCls = style.arrowBottom(); break; } } } ButtonScale scale = cell.getScale(); switch (scale) { case SMALL: cls += " " + style.small(); break; case MEDIUM: cls += " " + style.medium(); break; case LARGE: cls += " " + style.large(); break; default: // empty } SafeStylesBuilder stylesBuilder = new SafeStylesBuilder(); int width = -1; if (cell.getWidth() != -1) { int w = cell.getWidth(); if (w < cell.getMinWidth()) { w = cell.getMinWidth(); } stylesBuilder.appendTrustedString("width:" + w + "px;"); cls += " " + style.hasWidth() + " x-has-width"; width = w; } else { if (cell.getMinWidth() != -1) { TextMetrics.get().bind(style.text()); int length = TextMetrics.get().getWidth(valueHtml); length += 6; // frames if (icon != null) { switch (iconAlign) { case LEFT: case RIGHT: length += icon.getWidth(); break; default: // empty } } if (cell.getMinWidth() > length) { stylesBuilder.appendTrustedString("width:" + cell.getMinWidth() + "px;"); cls += " " + style.hasWidth() + " x-has-width"; width = cell.getMinWidth(); } } } final int height = cell.getHeight(); if (height != -1) { stylesBuilder.appendTrustedString("height:" + height + "px;"); } if (icon != null) { switch (iconAlign) { case TOP: arrowCls += " " + style.iconTop(); break; case BOTTOM: arrowCls += " " + style.iconBottom(); break; case LEFT: arrowCls += " " + style.iconLeft(); break; case RIGHT: arrowCls += " " + style.iconRight(); break; } } else { arrowCls += " " + style.noIcon(); } // toggle button if (value == Boolean.TRUE) { cls += " " + frame.pressedClass(); } sb.append(templates.outer(cls, new SafeStylesBuilder().toSafeStyles())); SafeHtmlBuilder inside = new SafeHtmlBuilder(); String innerWrap = arrowCls; inside.appendHtmlConstant("<div class='" + innerWrap + "'>"); inside.appendHtmlConstant("<table cellpadding=0 cellspacing=0 class='" + style.mainTable() + "'>"); boolean hasText = valueHtml != null && !valueHtml.equals(""); if (icon != null) { switch (iconAlign) { case LEFT: inside.appendHtmlConstant("<tr>"); writeIcon(inside, icon, height); if (hasText) { int w = width - (icon != null ? icon.getWidth() : 0) - 4; writeValue(inside, valueHtml, w, height); } inside.appendHtmlConstant("</tr>"); break; case RIGHT: inside.appendHtmlConstant("<tr>"); if (hasText) { int w = width - (icon != null ? icon.getWidth() : 0) - 4; writeValue(inside, valueHtml, w, height); } writeIcon(inside, icon, height); inside.appendHtmlConstant("</tr>"); break; case TOP: inside.appendHtmlConstant("<tr>"); writeIcon(inside, icon, height); inside.appendHtmlConstant("</tr>"); if (hasText) { inside.appendHtmlConstant("<tr>"); writeValue(inside, valueHtml, width, height); inside.appendHtmlConstant("</tr>"); } break; case BOTTOM: if (hasText) { inside.appendHtmlConstant("<tr>"); writeValue(inside, valueHtml, width, height); inside.appendHtmlConstant("</tr>"); } inside.appendHtmlConstant("<tr>"); writeIcon(inside, icon, height); inside.appendHtmlConstant("</tr>"); break; } } else { inside.appendHtmlConstant("<tr>"); if (valueHtml != null) { writeValue(inside, valueHtml, width, height); } inside.appendHtmlConstant("</tr>"); } inside.appendHtmlConstant("</table>"); inside.appendHtmlConstant("</div>"); frame.render(sb, new Frame.FrameOptions(0, CommonStyles.get().noFocusOutline(), stylesBuilder.toSafeStyles()), inside.toSafeHtml()); sb.appendHtmlConstant("</div>"); }
From source file:com.sencha.gxt.theme.base.client.button.ButtonCellDefaultAppearance.java
License:sencha.com license
protected void writeValue(SafeHtmlBuilder builder, SafeHtml value, int width, int height) { SafeStylesBuilder sb = new SafeStylesBuilder(); if (height > 0) { int adjustedHeight = height - heightOffset; sb.append(SafeStylesUtils.fromTrustedString("height:" + adjustedHeight + "px;")); }/*w w w . j av a 2 s . co m*/ if (width > 0) { sb.append(SafeStylesUtils.fromTrustedString("width:" + width + "px;")); } builder.append(templates.textWithStyles(style.text(), sb.toSafeStyles(), value)); }
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;/*from www . j a v a 2s . com*/ 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.widget.core.client.grid.ColumnHeader.java
License:sencha.com license
protected SafeHtml renderHiddenHeaders(int[] columnWidths) { SafeHtmlBuilder heads = new SafeHtmlBuilder(); for (int i = 0; i < columnWidths.length; i++) { // unlike GridView, we do NOT render TH's for hidden elements because of support of // rowspan and colspan with header configs if (cm.isHidden(i)) { continue; }//w ww . j a va2 s . c o m SafeStylesBuilder builder = new SafeStylesBuilder(); builder.appendTrustedString("height: 0px;"); builder.appendTrustedString("width:" + columnWidths[i] + "px;"); heads.append(tpls.th("", builder.toSafeStyles())); } return tpls.tr("", heads.toSafeHtml()); }