@Override public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<button type=\"button\" tabindex=\"-1\">"); if (data != null) { sb.append(data); } sb.appendHtmlConstant("</button>"); }
/** * Construct a new {@link ActionCell}. * * @param message the message to display on the button * @param delegate the delegate that will handle events */ public ActionCell(SafeHtml message, Delegate<C> delegate) { super(CLICK, KEYDOWN); this.delegate = delegate; this.html = new SafeHtmlBuilder().appendHtmlConstant( "<button type=\"button\" tabindex=\"-1\">").append(message).appendHtmlConstant( "</button>").toSafeHtml(); }
/** * Render the composite cell as HTML into a {@link SafeHtmlBuilder}, suitable * for passing to {@link Element#setInnerHTML} on a container element. * * <p> * Note: If your cell contains natively focusable elements, such as buttons or * input elements, be sure to set the tabIndex to -1 so that they do not steal * focus away from the containing widget. * </p> * * @param context the {@link com.google.gwt.cell.client.Cell.Context Context} of the cell * @param value the cell value to be rendered * @param sb the {@link SafeHtmlBuilder} to be written to * @param hasCell a {@link HasCell} instance containing the cells to be * rendered within this cell */ protected <X> void render(Context context, C value, SafeHtmlBuilder sb, HasCell<C, X> hasCell) { Cell<X> cell = hasCell.getCell(); sb.appendHtmlConstant("<span>"); cell.render(context, hasCell.getValue(value), sb); sb.appendHtmlConstant("</span>"); }
cursor = wordBounds.endIndex; accum.appendEscaped(part1); accum.appendHtmlConstant("<strong>"); accum.appendEscaped(part2); accum.appendHtmlConstant("</strong>");
@Override public void render(Context context, String value, SafeHtmlBuilder sb) { // Get the view data. Object key = context.getKey(); String viewData = getViewData(key); if (viewData != null && viewData.equals(value)) { clearViewData(key); viewData = null; } int selectedIndex = getSelectedIndex(viewData == null ? value : viewData); sb.appendHtmlConstant("<select tabindex=\"-1\">"); int index = 0; for (String option : options) { if (index++ == selectedIndex) { sb.append(template.selected(option)); } else { sb.append(template.deselected(option)); } } sb.appendHtmlConstant("</select>"); }
@Override public void render(Context context, String value, SafeHtmlBuilder sb) { // Get the view data. Object key = context.getKey(); ViewData viewData = getViewData(key); if (viewData != null && viewData.getCurrentValue().equals(value)) { clearViewData(key); viewData = null; } String s = (viewData != null) ? viewData.getCurrentValue() : value; if (s != null) { sb.append(template.input(s)); } else { sb.appendHtmlConstant("<input type=\"text\" tabindex=\"-1\"></input>"); } }
String style = "style='color: " + (value < 0 ? "red" : "green") + "'"; String v = number.format(value); sb.appendHtmlConstant("<span " + style + " qtitle='Change' qtip='" + v + "'>" + v + "</span>");
sb.appendHtmlConstant("\u00A0");
private void buildDOM(AbstractImagePrototype thumb) { final Element topDiv = getElement(TOP); final Element bottomDiv = getElement(BOTTOM); final Element splitDiv = getSplitElement(); DOM.appendChild(getElement(), container); DOM.appendChild(container, topDiv); DOM.appendChild(container, splitDiv); DOM.appendChild(container, bottomDiv); /* * The style name is placed on the table rather than splitElem to allow the * splitter to be styled without interfering with layout. */ SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant("<div class='vsplitter' style='text-align:center;'>"); sb.append(thumb.getSafeHtml()); sb.appendHtmlConstant("</div>"); splitDiv.setInnerSafeHtml(sb.toSafeHtml()); addScrolling(topDiv); addScrolling(bottomDiv); } }
sb.append(SafeHtmlUtils.fromTrustedString(openTag.toString())); sb.append(content); sb.appendHtmlConstant("</button>");
@Override protected void render(final Context context, final SafeHtml data, final SafeHtmlBuilder builder) { builder.appendHtmlConstant("<div class=\"autocomplete-entry\">"); if (data != null) { builder.append(data); } builder.appendHtmlConstant("</div>"); } };
private void buildDOM(AbstractImagePrototype thumbImage) { final Element leftDiv = getElement(LEFT); final Element rightDiv = getElement(RIGHT); final Element splitDiv = getSplitElement(); DOM.appendChild(getElement(), container); DOM.appendChild(container, leftDiv); DOM.appendChild(container, splitDiv); DOM.appendChild(container, rightDiv); /* * Sadly, this is the only way I've found to get vertical centering in this * case. The usually CSS hacks (display: table-cell, vertical-align: middle) * don't work in an absolute positioned DIV. */ SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant("<table class='hsplitter' height='100%' cellpadding='0' " + "cellspacing='0'><tr><td align='center' valign='middle'>"); sb.append(thumbImage.getSafeHtml()); splitDiv.setInnerSafeHtml(sb.toSafeHtml()); addScrolling(leftDiv); addScrolling(rightDiv); }
private HTMLPanel createFieldsetPanel(String groupName) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendHtmlConstant("<fieldset id='"+id+"' class='default-fieldset'>"); builder.appendHtmlConstant("<legend class='default-legend'>").appendEscaped(groupName).appendHtmlConstant("</legend>"); builder.appendHtmlConstant("</fieldset>"); return new HTMLPanel(builder.toSafeHtml()); } }
public HyperlinkCell(SafeHtml message, ActionCell.Delegate<String> delegate) { super("click", "keydown"); this.delegate = delegate; this.html = new SafeHtmlBuilder().appendHtmlConstant( "<div tabindex=\"-1\" class='gwt-Hyperlink'>").append(message).appendHtmlConstant( "</div>").toSafeHtml(); }
/** * Convert String to a SafeHtml * @param html * @return */ public static SafeHtml toSafeHtml(final String html) { final SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendHtmlConstant(html); return builder.toSafeHtml(); } }
@Override public SafeHtml getValue(RuntimeInfo record) { String value = valueOrDefault(record.getUrl()); SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant("<a target=\"_blank\" href=\"" + value + "\">"); sb.appendEscaped(value); sb.appendHtmlConstant("</a>"); return sb.toSafeHtml(); } };
public static SafeHtml parseCode(String code) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); String[] splitted = code.replaceAll("\\\\s", " ").split("\\\\n\\s?"); String[] arr$ = splitted; int len$ = splitted.length; for (int i$ = 0; i$ < len$; ++i$) { String s = arr$[i$]; builder.append(SafeHtmlUtils.fromTrustedString(SafeHtmlUtils.htmlEscapeAllowEntities(s))); builder.appendHtmlConstant("<br>"); } return builder.toSafeHtml(); }
@Override public void render(Cell.Context context, final DataGridFilterSummary value, SafeHtmlBuilder sb) { AbstractImagePrototype imageProto = AbstractImagePrototype.create(images.close()); SafeHtmlBuilder mysb = new SafeHtmlBuilder(); mysb.appendHtmlConstant("<span title='" + CommonConstants.INSTANCE.RemoveFilter() + " " + value.getFilterName() + "' style='margin-right:5px;'>"); mysb.append(imageProto.getSafeHtml()); mysb.appendHtmlConstant("</span>"); sb.append(mysb.toSafeHtml()); } };
public PopupCell(String title, PopupCellDelegate delegate) { super("click", "keydown"); this.delegate = delegate; this.popup = new PopupPanel(); this.popup.setStyleName("default-popup"); this.popup.setWidget(delegate.asWidget()); this.html = new SafeHtmlBuilder().appendHtmlConstant( "<div tabindex=\"-1\" class='cell-popup'>"+title+"</div>").toSafeHtml(); }
public void render( final Cell.Context context, final T value, final SafeHtmlBuilder sb ) { final SafeHtmlBuilder mysb = new SafeHtmlBuilder(); final Button btn = GWT.create( Button.class ); btn.setText( getText( value ) ); btn.setTitle( getText( value ) ); btn.setType( ButtonType.DEFAULT ); btn.setSize( ButtonSize.SMALL ); btn.getElement().getStyle().setMarginRight( 5, Style.Unit.PX ); mysb.appendHtmlConstant( btn.getElement().getString() ); sb.append( mysb.toSafeHtml() ); }