Refine search
/** * Render a list of row values. * * @param values the row values * @param start the absolute start index of the values * @param selectionModel the {@link SelectionModel} * @return null, unless the implementation renders using SafeHtml */ private SafeHtml renderRowValues(List<T> values, int start, SelectionModel<? super T> selectionModel) { try { SafeHtmlBuilder sb = new SafeHtmlBuilder(); hasData.renderRowValues(sb, values, start, selectionModel); return sb.toSafeHtml(); } catch (UnsupportedOperationException e) { // If renderRowValues throws, the implementation will render directly in // the replaceChildren method. return null; } } }
public void setValue(Context context, Element parent, C value) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); render(context, value, sb); parent.setInnerSafeHtml(sb.toSafeHtml()); }
/** * 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(); }
public void render(Context context, C value, SafeHtmlBuilder sb) { SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder(); cell.render(context, value, cellBuilder); sb.append(template.outerDiv(outerDivPadding, isIconUsed(value) ? getIconHtml(value) : placeHolderHtml, cellBuilder.toSafeHtml())); }
SafeHtmlBuilder accum = new SafeHtmlBuilder(); accum.toSafeHtml().asString()); suggestions.add(suggestion);
@Override protected void renderRowValues(SafeHtmlBuilder sb, List<T> values, int start, SelectionModel<? super T> selectionModel) { String keyboardSelectedItem = " " + style.cellListKeyboardSelectedItem(); String selectedItem = " " + style.cellListSelectedItem(); String evenItem = style.cellListEvenItem(); String oddItem = style.cellListOddItem(); int keyboardSelectedRow = getKeyboardSelectedRow() + getPageStart(); int length = values.size(); int end = start + length; for (int i = start; i < end; i++) { T value = values.get(i - start); boolean isSelected = selectionModel == null ? false : selectionModel.isSelected(value); StringBuilder classesBuilder = new StringBuilder(); classesBuilder.append(i % 2 == 0 ? evenItem : oddItem); if (isSelected) { classesBuilder.append(selectedItem); } if (i == keyboardSelectedRow) { classesBuilder.append(keyboardSelectedItem); } SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder(); Context context = new Context(i, 0, getValueKey(value)); cell.render(context, value, cellBuilder); sb.append(TEMPLATE.div(i, classesBuilder.toString(), cellBuilder.toSafeHtml())); } }
SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder(); if (column instanceof Column) { column.getCell().render(context, column.getValue(rowValue), cellBuilder); builder.html(cellBuilder.toSafeHtml());
SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder(); Context context = new Context(i, 0, getValueKey(value)); cell.render(context, value, cellBuilder); if (accessKey != 0) { sb.append(template.divFocusableWithKey(i, classesBuilder.toString(), padding, getTabIndex(), getAccessKey(), image, cellBuilder.toSafeHtml())); } else { sb.append(template.divFocusable(i, classesBuilder.toString(), padding, getTabIndex(), image, cellBuilder.toSafeHtml())); .toSafeHtml()));
/** * Renders a given Header into a given ElementBuilderBase. This method ensures * that the CellTable widget will handle events events originating in the * Header. * * @param <H> the data type of the header * @param out the {@link ElementBuilderBase} to render into. The builder * should be a child element of a row returned by {@link #startRow} * and must be in a state that allows both attributes and elements to * be added * @param context the {@link Context} of the header being rendered * @param header the {@link Header} to render */ protected final <H> void renderHeader(ElementBuilderBase<?> out, Context context, Header<H> header) { // Generate a unique ID for the header. String headerId = idToHeaderMap.getKey(header); if (headerId == null) { headerId = "header-" + Document.get().createUniqueId(); idToHeaderMap.put(headerId, header); } out.attribute(HEADER_ATTRIBUTE, headerId); // Render the cell into the builder. SafeHtmlBuilder sb = new SafeHtmlBuilder(); header.render(context, sb); out.html(sb.toSafeHtml()); }
/** * Redraw the widget. */ public void redraw() { SafeHtmlBuilder sb = new SafeHtmlBuilder(); cell.render(createContext(), value, sb); getElement().setInnerSafeHtml(sb.toSafeHtml()); /* * The rendered Cell should fill the root element so height and width styles * applied to the widget also apply to the Cell. If there is exactly one * child element, the height and width are set to 100% to fill the parent. */ Element child = getElement().getFirstChildElement(); if (child != null && child.getNextSiblingElement() == null) { child.getStyle().setHeight(100, Unit.PCT); child.getStyle().setWidth(100, Unit.PCT); } }
@Override public void render(ButtonCellBase<C> cell, Context context, C value, SafeHtmlBuilder sb) { SafeHtmlBuilder classes = new SafeHtmlBuilder(); classes.appendEscaped(style.buttonCellBase()); Decoration decoration = cell.getDecoration(); StringBuilder openTag = new StringBuilder(); openTag.append("<button type=\"button\""); openTag.append(" class=\"" + classes.toSafeHtml().asString() + "\""); openTag.append(" tabindex=\"" + tabIndex + "\" "); openTag.append(attributes.toString()).append(">");
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 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); } }
SafeHtmlBuilder trBuilder = new SafeHtmlBuilder(); int curColumn = 0; for (Column<T, ?> column : columns) { SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder(); if (value != null) { column.render(context, value, cellBuilder); contents = template.div(cellBuilder.toSafeHtml()); sb.append(template.tr(trClasses, trBuilder.toSafeHtml()));
private SafeHtml getSafeHtml( final String message ) { final SafeHtmlBuilder shb = new SafeHtmlBuilder(); shb.appendEscaped( message ); return shb.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(); } }
/** * Creates an HTML panel with the specified HTML contents inside a DIV * element. Any element within this HTML that has a specified id can contain a * child widget. * The actual element that will hold this HTML isn't initialized until it is * needed. * * @param html the panel's HTML */ public RenderablePanel(String html) { this(new SafeHtmlBuilder().appendHtmlConstant(html).toSafeHtml()); }
private SafeHtml getSafeHtml(final String message) { final SafeHtmlBuilder shb = new SafeHtmlBuilder(); shb.appendEscaped(message); return shb.toSafeHtml(); }
private SafeHtml getSafeHtml(final String message) { final SafeHtmlBuilder shb = new SafeHtmlBuilder(); shb.appendEscaped(message); return shb.toSafeHtml(); }
private void renderEscaped(String iri, StringBuilder sb) { SafeHtmlBuilder htmlBuilder = new SafeHtmlBuilder(); htmlBuilder.appendEscaped(iri); sb.append(htmlBuilder.toSafeHtml().asString()); }