Java Code Examples for com.google.gwt.dom.client.Element#appendChild()
The following examples show how to use
com.google.gwt.dom.client.Element#appendChild() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PasteFormatRenderers.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
@Override public ContentNode renderSequence( ReadableDocumentView<ContentNode, ContentElement, ContentTextNode> view, ContentNode firstItem, ContentNode stopAt, Element dstParent, SelectionMatcher selectionMatcher) { if (firstItem instanceof ContentElement) { EditorStaticDeps.logger.trace().log( "deep cloning: " + ((ContentElement) firstItem).getTagName()); } Node implNodelet = firstItem.getImplNodelet(); Node clone = (implNodelet != null ? implNodelet.cloneNode(true) : null); if (clone != null) { dstParent.appendChild(clone); selectionMatcher.maybeNoteHtml(firstItem, clone); } else { selectionMatcher.noteSelectionInNode(firstItem, dstParent, true); } return firstItem; }
Example 2
Source File: DomHelper.java From swellrt with Apache License 2.0 | 6 votes |
/** * Ensures the given container contains exactly one child, the given one. * Provides the important property that if the container is already the parent * of the given child, then the child is not removed and re-added, it is left * there; any siblings, if present, are removed. * * @param container * @param child */ public static void setOnlyChild(Element container, Node child) { if (child.getParentElement() != container) { // simple case emptyElement(container); container.appendChild(child); } else { // tricky case - avoid removing then re-appending the same child while (child.getNextSibling() != null) { child.getNextSibling().removeFromParent(); } while (child.getPreviousSibling() != null) { child.getPreviousSibling().removeFromParent(); } } }
Example 3
Source File: ContentElement.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
/** * Add back in the impl nodelets of the children. * * Override this to provide specific functionality as needed. For example, * ensuring certain children live in certain specific locations of the * doodad's dom. */ protected void reattachImplChildren() { ContentView renderedContent = getRenderedContentView(); Element container = getContainerNodelet(); if (container != null) { while (container.getFirstChild() != null) { container.getFirstChild().removeFromParent(); } for (ContentNode node = renderedContent.getFirstChild(this); node != null; node = renderedContent.getNextSibling(node)) { container.appendChild(node.getImplNodelet()); } } else { EditorStaticDeps.logger.error().log( "You need to override this method for your doodad: " + tagName); } }
Example 4
Source File: DomHelper.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
/** * Ensures the given container contains exactly one child, the given one. * Provides the important property that if the container is already the parent * of the given child, then the child is not removed and re-added, it is left * there; any siblings, if present, are removed. * * @param container * @param child */ public static void setOnlyChild(Element container, Node child) { if (child.getParentElement() != container) { // simple case emptyElement(container); container.appendChild(child); } else { // tricky case - avoid removing then re-appending the same child while (child.getNextSibling() != null) { child.getNextSibling().removeFromParent(); } while (child.getPreviousSibling() != null) { child.getPreviousSibling().removeFromParent(); } } }
Example 5
Source File: ContentElement.java From swellrt with Apache License 2.0 | 6 votes |
/** * Add back in the impl nodelets of the children. * * Override this to provide specific functionality as needed. For example, * ensuring certain children live in certain specific locations of the * doodad's dom. */ protected void reattachImplChildren() { ContentView renderedContent = getRenderedContentView(); Element container = getContainerNodelet(); if (container != null) { while (container.getFirstChild() != null) { container.getFirstChild().removeFromParent(); } for (ContentNode node = renderedContent.getFirstChild(this); node != null; node = renderedContent.getNextSibling(node)) { container.appendChild(node.getImplNodelet()); } } else { EditorStaticDeps.logger.error().log( "You need to override this method for your doodad: " + tagName); } }
Example 6
Source File: SolutionReportsPage.java From unitime with Apache License 2.0 | 5 votes |
protected void print(final TableInterface data) { final DataTable table = new DataTable(data); Element headerRow = table.getRowFormatter().getElement(0); Element tableElement = table.getElement(); Element thead = DOM.createTHead(); tableElement.insertFirst(thead); headerRow.getParentElement().removeChild(headerRow); thead.appendChild(headerRow); Page page = new Page() { @Override public String getName() { return data.getName(); } @Override public String getUser() { return ""; } @Override public String getSession() { return ""; } @Override public Element getBody() { return table.getElement(); } }; ToolBox.print(page); }
Example 7
Source File: ParagraphNiceHtmlRenderer.java From swellrt with Apache License 2.0 | 5 votes |
private ContentNode renderAndAppendParagraph( ReadableDocumentView<ContentNode, ContentElement, ContentTextNode> contentView, Element dest, ContentNode child, SelectionMatcher selectionMatcher) { PasteFormatRenderer.renderChildren(contentView, dest, child, selectionMatcher); Element br = Document.get().createBRElement(); dest.appendChild(br); selectionMatcher.maybeNoteHtml(child, br); return child; }
Example 8
Source File: Clipboard.java From swellrt with Apache License 2.0 | 5 votes |
/** * {@link #fillBufferAndSetSelection(Node, PointRange, XmlStringBuilder, Iterable, boolean) * same as above, but with the entire fragment. } * * @param htmlFragment * @param waveXml * @param normalizedAnnotation */ public void fillBufferAndSetSelection(Node htmlFragment, XmlStringBuilder waveXml, Iterable<RangedAnnotation<String>> normalizedAnnotation, boolean restoreSelection) { Element parent = Document.get().createDivElement(); parent.appendChild(htmlFragment); PointRange<Node> selection = new PointRange<Node>(Point.inElement(parent, htmlFragment), Point.<Node> end(parent)); fillBufferAndSetSelection(parent, selection, waveXml, normalizedAnnotation, restoreSelection); }
Example 9
Source File: DiffDeleteRenderer.java From swellrt with Apache License 2.0 | 5 votes |
/** Adds internal html of deleted contents to a diff element. */ public void setInnards(ContentElement element, List<Element> deletedStuff) { Element nodelet = element.getContainerNodelet(); // first find DOM element for (Element e : deletedStuff) { nodelet.appendChild(e); } }
Example 10
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 5 votes |
/** * Default constructor */ SuggestionPopup() { super(true, false); debug("VComboBoxMultiselect.SP: constructor()"); setOwner(VComboBoxMultiselect.this); this.menu = new SuggestionMenu(); setWidget(this.menu); getElement().getStyle() .setZIndex(Z_INDEX); final Element root = getContainerElement(); this.up.setInnerHTML("<span>Prev</span>"); DOM.sinkEvents(this.up, Event.ONCLICK); this.down.setInnerHTML("<span>Next</span>"); DOM.sinkEvents(this.down, Event.ONCLICK); root.insertFirst(this.up); root.appendChild(this.down); root.appendChild(this.status); DOM.sinkEvents(root, Event.ONMOUSEDOWN | Event.ONMOUSEWHEEL); addCloseHandler(this); Roles.getListRole() .set(getElement()); setPreviewingAllNativeEvents(true); }
Example 11
Source File: DemoGwtWebApp.java From demo-gwt-springboot with Apache License 2.0 | 5 votes |
private void addMetaElements() { logger.info("Add viewport"); MetaElement element = Document.get().createMetaElement(); element.setName("viewport"); element.setContent("width=device-width, initial-scale=1.0"); NodeList<Element> node = Document.get().getElementsByTagName("head"); Element elementHead = node.getItem(0); elementHead.appendChild(element); }
Example 12
Source File: SelectionImplIE.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * @param range * @param element * @return input range collapsed at end of element */ private JsTextRangeIE collapseAtEnd(JsTextRangeIE range, Element element) { try { element.appendChild(setter); return collapseBeforeSetter(range); } finally { setter.removeFromParent(); } }
Example 13
Source File: ParagraphNiceHtmlRenderer.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
private ContentNode renderAndAppendParagraph( ReadableDocumentView<ContentNode, ContentElement, ContentTextNode> contentView, Element dest, ContentNode child, SelectionMatcher selectionMatcher) { PasteFormatRenderer.renderChildren(contentView, dest, child, selectionMatcher); Element br = Document.get().createBRElement(); dest.appendChild(br); selectionMatcher.maybeNoteHtml(child, br); return child; }
Example 14
Source File: Clipboard.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * {@link #fillBufferAndSetSelection(Node, PointRange, XmlStringBuilder, Iterable, boolean) * same as above, but with the entire fragment. } * * @param htmlFragment * @param waveXml * @param normalizedAnnotation */ public void fillBufferAndSetSelection(Node htmlFragment, XmlStringBuilder waveXml, Iterable<RangedAnnotation<String>> normalizedAnnotation, boolean restoreSelection) { Element parent = Document.get().createDivElement(); parent.appendChild(htmlFragment); PointRange<Node> selection = new PointRange<Node>(Point.inElement(parent, htmlFragment), Point.<Node> end(parent)); fillBufferAndSetSelection(parent, selection, waveXml, normalizedAnnotation, restoreSelection); }
Example 15
Source File: RepairerGwtTest.java From swellrt with Apache License 2.0 | 4 votes |
public void testRevertRange() { init(); initHelloThere(); // blow it all away p.getImplNodelet().setInnerHTML(""); assertEquals("", p.getImplNodelet().getInnerHTML()); r.revertInner(Point.before(c, t1), Point.after(c, t3)); assertEquals("hello <b>th</b>ere", p.getImplNodelet().getInnerHTML()); // insert stuff at start and end, revert whole p p.getImplNodelet().appendChild(ca()); t1.getImplNodelet().getParentNode().insertBefore(ca(), t1.getImplNodelet()); r.revertInner(Point.before(c, p), Point.after(c, p)); assertEquals("hello <b>th</b>ere", p.getImplNodelet().getInnerHTML()); // insert stuff at start and end, revert parts of p p.getImplNodelet().appendChild(ca()); t1.getImplNodelet().getParentNode().insertBefore(ca(), t1.getImplNodelet()); r.revertInner(Point.before(c, t1), Point.before(c, t3)); assertEquals("hello <b>th</b>ere<a></a>", p.getImplNodelet().getInnerHTML()); r.revertInner(Point.before(c, t1), Point.end((ContentNode)p)); assertEquals("hello <b>th</b>ere", p.getImplNodelet().getInnerHTML()); // insert stuff inside inner element b.getImplNodelet().appendChild(ca()); r.revertInner(Point.after(c, t1), Point.before(c, t3)); assertEquals("hello <b>th</b>ere", p.getImplNodelet().getInnerHTML()); // reorganise stuff b.getImplNodelet().appendChild(t3.getImplNodelet()); assertEquals("hello <b>there</b>", p.getImplNodelet().getInnerHTML()); r.revertInner(Point.before(c, t1), Point.after(c, t3)); assertEquals("hello <b>th</b>ere", p.getImplNodelet().getInnerHTML()); // wrap stuff randomly b.getImplNodelet().appendChild(t3.getImplNodelet()); assertEquals("hello <b>there</b>", p.getImplNodelet().getInnerHTML()); Element wrapper = ca(); Node bit = t1.getImplNodelet().splitText(2); bit.getParentNode().insertBefore(wrapper, bit); wrapper.appendChild(bit); r.revertInner(Point.before(c, t1), Point.after(c, t3)); assertEquals("hello <b>th</b>ere", p.getImplNodelet().getInnerHTML()); l.check(0, 0); // calls through revertInner, so none reported }
Example 16
Source File: CaretAnnotationHandler.java From swellrt with Apache License 2.0 | 4 votes |
public void renderAt(Element parent) { if (parent == null || caretView.getElement() == null) return; parent.appendChild(caretView.getElement()); }
Example 17
Source File: GwtRenderingMutationHandler.java From swellrt with Apache License 2.0 | 3 votes |
/** * Assigns a widget to an element and optionally attaches it to a parent html * node. Does not do any GWT logical attachment * * @param element the element the widget is associated with * @param w the widget to insert into the logical hierarchy * @param physicalParent the physical place in the dom to attach the widget. * May be null, in which case no physical attachment will take place. */ private void associateWidget(Renderable element, Widget w, Element physicalParent) { element.setProperty(WIDGET, w); if (physicalParent != null) { physicalParent.appendChild(w.getElement()); } element.setAutoAppendContainer(getContainerNodelet(w)); }
Example 18
Source File: CaretWidget.java From swellrt with Apache License 2.0 | 3 votes |
public void attachToParent(Element parent) { if (parent == null) return; parent.appendChild(getElement()); }
Example 19
Source File: ParagraphHelperBr.java From incubator-retired-wave with Apache License 2.0 | 2 votes |
/** * Appends a spacer <br sp='t'/> element to paragraph * Each paragraph owns a spacer which gets reused, so it * is safe to call this method multiple times. * * @param paragraph */ protected void appendSpacer(Element paragraph) { Element spacer = getSpacer(paragraph); paragraph.appendChild(spacer); }
Example 20
Source File: ParagraphHelperBr.java From swellrt with Apache License 2.0 | 2 votes |
/** * Appends a spacer <br sp='t'/> element to paragraph * Each paragraph owns a spacer which gets reused, so it * is safe to call this method multiple times. * * @param paragraph */ protected void appendSpacer(Element paragraph) { Element spacer = getSpacer(paragraph); paragraph.appendChild(spacer); }