@Override protected void doHtmlImpl(SafeHtml html) { getCurrentElement().setInnerSafeHtml(html); }
/** * Convenience method to convert the specified HTML into DOM elements and * return the parent of the DOM elements. * * @param html the HTML to convert * @param tmpElem a temporary element * @return the parent element */ static Element convertToElements(Widget widget, Element tmpElem, SafeHtml html) { // Attach an event listener so we can catch synchronous load events from // cached images. DOM.setEventListener(tmpElem, widget); tmpElem.setInnerSafeHtml(html); // Detach the event listener. DOM.setEventListener(tmpElem, null); return tmpElem; }
public void setValue(Context context, Element parent, C value) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); render(context, value, sb); parent.setInnerSafeHtml(sb.toSafeHtml()); }
@Override protected Element doFinishImpl() { Element tmp = Document.get().createDivElement(); tmp.setInnerSafeHtml(asSafeHtml()); return tmp.getFirstChildElement(); }
tmpElem.setInnerSafeHtml(template.tbody(rowHtml)); } else if ("thead".equals(sectionTag)) { tmpElem.setInnerSafeHtml(template.thead(rowHtml)); } else if ("tfoot".equals(sectionTag)) { tmpElem.setInnerSafeHtml(template.tfoot(rowHtml)); } else { throw new IllegalArgumentException("Invalid table section tag: " + sectionTag);
private void createFrame() { // Attach a hidden IFrame to the form. This is the target iframe to which // the form will be submitted. We have to create the iframe using innerHTML, // because setting an iframe's 'name' property dynamically doesn't work on // most browsers. Element dummy = Document.get().createDivElement(); dummy.setInnerSafeHtml(IFrameTemplate.INSTANCE.get(frameName)); synthesizedFrame = dummy.getFirstChildElement(); }
/** * Creates an HTML IFRAME element with a name. * * @param name the name of the frame, which must contain at least one * non-whitespace character and must not contain reserved HTML markup * characters such as '<code><</code>', '<code>></code>', * or '<code>&</code>' * @return the newly-created element * @throws IllegalArgumentException if the supplied name is not allowed */ private static IFrameElement createIFrame(String name) { if (name == null || !isValidName(name.trim())) { throw new IllegalArgumentException( "expecting one or more non-whitespace chars with no '<', '>', or '&'"); } // Use innerHTML to implicitly create the <iframe>. This is necessary // because most browsers will not respect a dynamically-set iframe name. Element div = DOM.createDiv(); div.setInnerSafeHtml(IFrameTemplate.INSTANCE.get(name)); return div.getFirstChild().cast(); }
public Element createStructure(SafeUri url, int left, int top, int width, int height) { Element tmp = Document.get().createSpanElement(); tmp.setInnerSafeHtml(getSafeHtml(url, left, top, width, height)); Element elem = tmp.getFirstChildElement(); elem.setPropertyJSO("onload", createOnLoadHandlerFunction()); return elem; }
/** * Convenience method to replace all children of a Widget. * * @param widget the widget who's contents will be replaced * @param childContainer the container that holds the contents * @param html the html to set */ static void replaceAllChildren(Widget widget, Element childContainer, SafeHtml html) { // If the widget is not attached, attach an event listener so we can catch // synchronous load events from cached images. if (!widget.isAttached()) { DOM.setEventListener(widget.getElement(), widget); } // Render the HTML. childContainer.setInnerSafeHtml(CellBasedWidgetImpl.get().processHtml(html)); // Detach the event listener. if (!widget.isAttached()) { DOM.setEventListener(widget.getElement(), null); } }
@Override public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) { // The loading indicator can fire its own load or error event, so we check // that the event actually occurred on the main image. String type = event.getType(); if (BrowserEvents.LOAD.equals(type) && eventOccurredOnImage(event, parent)) { // Remove the loading indicator. parent.getFirstChildElement().getStyle().setDisplay(Display.NONE); // Show the image. Element imgWrapper = parent.getChild(1).cast(); imgWrapper.getStyle().setProperty("height", "auto"); imgWrapper.getStyle().setProperty("width", "auto"); imgWrapper.getStyle().setProperty("overflow", "auto"); } else if (BrowserEvents.ERROR.equals(type) && eventOccurredOnImage(event, parent)) { // Replace the loading indicator with an error message. parent.getFirstChildElement().setInnerSafeHtml(errorRenderer.render(value)); } }
Element td = DOM.createTD(); td.setPropertyString("vAlign", "middle"); td.setInnerSafeHtml(subMenuIcon.getSafeHtml()); setStyleName(td, "subMenuIcon"); DOM.appendChild(tr, td);
element.setInnerSafeHtml(getInnerHtml());
@Override protected void setKeyboardSelected(int index, boolean selected, boolean stealFocus) { super.setKeyboardSelected(index, selected, stealFocus); if (!isRowWithinBounds(index)) { return; } // Update the style. Element elem = getRowElement(index); T value = getPresenter().getVisibleItem(index); boolean isOpen = selected && isOpen(index); setStyleName(elem, style.cellBrowserOpenItem(), isOpen); // Update the image. SafeHtml image = null; if (isOpen) { image = openImageHtml; } else if (getTreeViewModel().isLeaf(value)) { image = LEAF_IMAGE; } else { image = closedImageHtml; } tmpElem.setInnerSafeHtml(image); elem.replaceChild(tmpElem.getFirstChildElement(), elem.getFirstChildElement()); // Update the open state. updateChildState(this, true); }
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); }
@Override protected void doHtmlImpl(SafeHtml html) { getCurrentElement().setInnerSafeHtml(html); }
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); } }
tmp.setInnerSafeHtml(html); Element imageElem = tmp.getFirstChildElement();
public Element createStructure(SafeUri url, int left, int top, int width, int height) { Element tmp = Document.get().createSpanElement(); tmp.setInnerSafeHtml(getSafeHtml(url, left, top, width, height)); return tmp.getFirstChildElement(); }
private void createFrame() { // Attach a hidden IFrame to the form. This is the target iframe to // which the form will be submitted. We have to create the iframe using // innerHTML, because setting an iframe's 'name' property dynamically // doesn't work on most browsers. Element dummy = Document.get().createDivElement(); dummy.setInnerSafeHtml(IFrameTemplate.INSTANCE.get(frameName)); synthesizedFrame = dummy.getFirstChildElement(); }
private void createFrame() { // Attach a hidden IFrame to the form. This is the target iframe to // which the form will be submitted. We have to create the iframe using // innerHTML, because setting an iframe's 'name' property dynamically // doesn't work on most browsers. Element dummy = Document.get().createDivElement(); dummy.setInnerSafeHtml(IFrameTemplate.INSTANCE.get(frameName)); synthesizedFrame = dummy.getFirstChildElement(); }