Java Code Examples for com.google.gwt.dom.client.Element#setInnerHTML()
The following examples show how to use
com.google.gwt.dom.client.Element#setInnerHTML() .
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: MaterialToastTest.java From gwt-material with Apache License 2.0 | 6 votes |
public void testToastWithCallback() { final boolean[] isCallbackFired = new boolean[1]; new MaterialToast(() -> { isCallbackFired[0] = true; }).toast("callback", 1000); Timer t = new Timer() { @Override public void run() { assertTrue(isCallbackFired[0]); } }; t.schedule(1000); Element toastContainer = $("body").find("#toast-container").asElement(); assertNotNull(toastContainer); toastContainer.setInnerHTML(""); }
Example 2
Source File: BreadcrumbLink.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void redraw() { StyleUtils.toggleStyle(this, LinkStyle.ACTIVE, this.active); Element elem = getElement(); elem.removeAllChildren(); if (!active) { elem = Document.get().createAnchorElement(); getElement().appendChild(elem); if (this.link != null) { AnchorElement.as(elem).setHref(this.link); } } if (this.label != null) { elem.setInnerHTML(this.label); } if (this.iconType != null) { Icon icon = new Icon(); icon.setType(this.iconType); elem.insertFirst(icon.getElement()); } }
Example 3
Source File: UndercurrentHarness.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
void dump(Element timeBox) { final SafeHtmlBuilder timeHtml = new SafeHtmlBuilder(); timeHtml.appendHtmlConstant("<table cellpadding='0' cellspacing='0'>"); events.each(new ProcV<Integer>() { @Override public void apply(String key, Integer value) { timeHtml.appendHtmlConstant("<tr><td>"); timeHtml.appendEscaped(key); timeHtml.appendHtmlConstant(":</td><td>"); timeHtml.appendEscaped("" + value); timeHtml.appendHtmlConstant("</td></tr>"); } }); timeHtml.appendHtmlConstant("</table>"); timeBox.setInnerHTML(timeHtml.toSafeHtml().asString()); }
Example 4
Source File: JoinDataTool.java From geowe-core with GNU General Public License v3.0 | 6 votes |
private SubmitCompleteHandler getSubmitCompleteHandler() { return new SubmitCompleteHandler() { public void onSubmitComplete(final SubmitCompleteEvent event) { final Element label = DOM.createLabel(); label.setInnerHTML(event.getResults()); final String csvData = label.getInnerText(); if (hasError(csvData)) { showAlert("Error: " + csvData); } else { parseCsvData(csvData); autoMessageBox.hide(); } } private boolean hasError(final String contentFile) { return contentFile.startsWith("413") || contentFile.startsWith("500"); } }; }
Example 5
Source File: UndercurrentHarness.java From swellrt with Apache License 2.0 | 6 votes |
void dump(Element timeBox) { final SafeHtmlBuilder timeHtml = new SafeHtmlBuilder(); timeHtml.appendHtmlConstant("<table cellpadding='0' cellspacing='0'>"); events.each(new ProcV<Integer>() { @Override public void apply(String key, Integer value) { timeHtml.appendHtmlConstant("<tr><td>"); timeHtml.appendEscaped(key); timeHtml.appendHtmlConstant(":</td><td>"); timeHtml.appendEscaped("" + value); timeHtml.appendHtmlConstant("</td></tr>"); } }); timeHtml.appendHtmlConstant("</table>"); timeBox.setInnerHTML(timeHtml.toSafeHtml().asString()); }
Example 6
Source File: EventDispatcherPanelGwtTest.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** Injects some HTML into the DOM. */ private static Element load(SafeHtml html) { Element container = Document.get().createDivElement(); container.setInnerHTML(html.asString()); Element content = container.getFirstChildElement(); RootPanel.get().getElement().appendChild(content); return content; }
Example 7
Source File: XmlStructureGwtTest.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * Creates an xml block structure from a model, and injects it into the page. */ private XmlStructure createXml(ConversationView model) { String xml = XmlRenderer.render(new ViewIdMapper(ModelIdMapperImpl.create(model, "empty")), model); Element dom = Document.get().createElement("xml"); dom.setInnerHTML(xml); Document.get().getBody().appendChild(dom); return XmlStructure.create(XmlRenderer.ROOT_ID); }
Example 8
Source File: HtmlDomRenderer.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** Turns a UiBuilder rendering into a DOM element. */ private Element parseHtml(UiBuilder ui) { if (ui == null) { return null; } SafeHtmlBuilder html = new SafeHtmlBuilder(); ui.outputHtml(html); Element div = com.google.gwt.dom.client.Document.get().createDivElement(); div.setInnerHTML(html.toSafeHtml().asString()); Element ret = div.getFirstChildElement(); // Detach, in order that this element looks free-floating (required by some // preconditions). ret.removeFromParent(); return ret; }
Example 9
Source File: XmlStructureGwtTest.java From swellrt with Apache License 2.0 | 5 votes |
/** * Creates an xml block structure from a model, and injects it into the page. */ private XmlStructure createXml(ConversationView model) { String xml = XmlRenderer.render(new ViewIdMapper(ModelIdMapperImpl.create(model, "empty")), model); Element dom = Document.get().createElement("xml"); dom.setInnerHTML(xml); Document.get().getBody().appendChild(dom); return XmlStructure.create(XmlRenderer.ROOT_ID); }
Example 10
Source File: HtmlDomRenderer.java From swellrt with Apache License 2.0 | 5 votes |
/** Turns a UiBuilder rendering into a DOM element. */ private Element parseHtml(UiBuilder ui) { if (ui == null) { return null; } SafeHtmlBuilder html = new SafeHtmlBuilder(); ui.outputHtml(html); Element div = com.google.gwt.dom.client.Document.get().createDivElement(); div.setInnerHTML(html.toSafeHtml().asString()); Element ret = div.getFirstChildElement(); // Detach, in order that this element looks free-floating (required by some // preconditions). ret.removeFromParent(); return ret; }
Example 11
Source File: MaterialToastTest.java From gwt-material with Apache License 2.0 | 5 votes |
public void testToastStructure() { MaterialToast.fireToast("test"); Element toastContainer = $("body").find("#toast-container").asElement(); assertNotNull(toastContainer); assertEquals(toastContainer.getChildCount(), 1); assertNotNull(toastContainer.getChild(0)); assertTrue(toastContainer.getChild(0) instanceof Element); Element toastElement = (Element) toastContainer.getChild(0); assertEquals(toastElement.getInnerHTML(), "test"); toastContainer.setInnerHTML(""); }
Example 12
Source File: MaterialToastTest.java From gwt-material with Apache License 2.0 | 5 votes |
public void testToastWithWidget() { MaterialLink link = new MaterialLink(); new MaterialToast(link).toast("test"); Element toastContainer = $("body").find("#toast-container").asElement(); assertNotNull(toastContainer); assertEquals(toastContainer.getChildCount(), 1); assertNotNull(toastContainer.getChild(0)); assertTrue(toastContainer.getChild(0) instanceof Element); Element toastElement = (Element) toastContainer.getChild(0); // Check the span text assertEquals($(toastElement.getChild(0)).text(), "test"); // Check the added link to toast component assertEquals(link.getElement(), toastElement.getChild(1)); toastContainer.setInnerHTML(""); }
Example 13
Source File: MaterialToastTest.java From gwt-material with Apache License 2.0 | 5 votes |
public void testToastWithStyling() { MaterialToast.fireToast("test", "rounded"); Element toastContainer = $("body").find("#toast-container").asElement(); assertNotNull(toastContainer); assertEquals(toastContainer.getChildCount(), 1); assertNotNull(toastContainer.getChild(0)); assertTrue(toastContainer.getChild(0) instanceof Element); Element toastElement = (Element) toastContainer.getChild(0); assertTrue(toastElement.hasClassName("rounded")); toastContainer.setInnerHTML(""); }
Example 14
Source File: MaterialToastTest.java From gwt-material with Apache License 2.0 | 5 votes |
public void testMultipleToasts() { for (int i = 1; i <= 5; i++) { MaterialToast.fireToast("test" + i); } Element toastContainer = $("body").find("#toast-container").asElement(); assertNotNull(toastContainer); assertEquals(toastContainer.getChildCount(), 5); // Check each toasts for (int i = 0; i < 5; i++) { Element toastElement = (Element) toastContainer.getChild(i); assertEquals(toastElement.getInnerHTML(), "test" + (i + 1)); } toastContainer.setInnerHTML(""); assertEquals(toastContainer.getChildCount(), 0); }
Example 15
Source File: ToDoCell.java From blog with MIT License | 4 votes |
/** * Renders the cell, replacing the contents of the parent with the newly rendered content. */ private void renderCell(Context context, Element parent, ToDoItem value) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); render(context, value, sb); parent.setInnerHTML(sb.toSafeHtml().asString()); }
Example 16
Source File: WeekGrid.java From calendar-component with Apache License 2.0 | 4 votes |
private void createTimeBar(boolean format24h) { setStylePrimaryName("v-calendar-times"); // Fist "time" is empty Element e = DOM.createDiv(); setStyleName(e, "v-calendar-time"); e.setInnerText(""); getElement().appendChild(e); DateTimeService dts = new DateTimeService(); if (format24h) { for (int i = firstHour + 1; i <= lastHour; i++) { e = DOM.createDiv(); setStyleName(e, "v-calendar-time"); String delimiter = dts.getClockDelimeter(); e.setInnerHTML("<span>" + i + "</span>" + delimiter + "00"); getElement().appendChild(e); } } else { // FIXME Use dts.getAmPmStrings(); and make sure that // DateTimeService has a some Locale set. String[] ampm = new String[] { "AM", "PM" }; int amStop = (lastHour < 11) ? lastHour : 11; int pmStart = (firstHour > 11) ? firstHour % 11 : 0; if (firstHour < 12) { for (int i = firstHour + 1; i <= amStop; i++) { e = DOM.createDiv(); setStyleName(e, "v-calendar-time"); e.setInnerHTML("<span>" + timesFor12h[i] + "</span>" + " " + ampm[0]); getElement().appendChild(e); } } if (lastHour > 11) { for (int i = pmStart; i < lastHour - 11; i++) { e = DOM.createDiv(); setStyleName(e, "v-calendar-time"); e.setInnerHTML("<span>" + timesFor12h[i] + "</span>" + " " + ampm[1]); getElement().appendChild(e); } } } }
Example 17
Source File: ParagraphHelperIE.java From swellrt with Apache License 2.0 | 3 votes |
/** * IE-specific trick to keep an empty paragraph "open" (i.e. prevent it from * collapsing to zero height). See class javadoc for details. * * Since we know of no direct way to set the magic flag, we mimic the user * deleting the last char. * * TODO(user): can we get away with only doing this when creating new, empty * paragraphs? It seems our own emptying should already set the magic flag, * but for some reason it doesn't seem to happen... * * NB(user): The flag only gets set when the nodelet is attached to the * editor. See also ImplementorImpl.Helper#beforeImplementation(Element) */ public static void openEmptyParagraph(Element nodelet) { // Add + delete an arbitrary char from the paragraph // TODO(user): why does this throw exception in <caption> elements? try { Point<Node> point = IeNodeletHelper.beforeImplementation(nodelet); nodelet.setInnerHTML("x"); nodelet.setInnerHTML(""); IeNodeletHelper.afterImplementation(nodelet, point); } catch (JavaScriptException t) {} }
Example 18
Source File: ParagraphHelperIE.java From incubator-retired-wave with Apache License 2.0 | 3 votes |
/** * IE-specific trick to keep an empty paragraph "open" (i.e. prevent it from * collapsing to zero height). See class javadoc for details. * * Since we know of no direct way to set the magic flag, we mimic the user * deleting the last char. * * TODO(user): can we get away with only doing this when creating new, empty * paragraphs? It seems our own emptying should already set the magic flag, * but for some reason it doesn't seem to happen... * * NB(user): The flag only gets set when the nodelet is attached to the * editor. See also ImplementorImpl.Helper#beforeImplementation(Element) */ public static void openEmptyParagraph(Element nodelet) { // Add + delete an arbitrary char from the paragraph // TODO(user): why does this throw exception in <caption> elements? try { Point<Node> point = IeNodeletHelper.beforeImplementation(nodelet); nodelet.setInnerHTML("x"); nodelet.setInnerHTML(""); IeNodeletHelper.afterImplementation(nodelet, point); } catch (JavaScriptException t) {} }
Example 19
Source File: PasteExtractorGwtTest.java From swellrt with Apache License 2.0 | 2 votes |
/** * Performs a paste operation and checks the initial content with the expected. * @param initialContent The initial XML fragment inside the document. * @param expectedContent The expected XML fragment inside the document * as a result of the paste. * @param pastedHtml The SGML fragment that would exist at the point of * the vertical bar in <p>x|x</p>, if something were pasted there. */ protected void executePaste(String initialContent, String pastedHtml, String expectedContent) { Element scratchContainer = Document.get().createDivElement(); scratchContainer.setInnerHTML(pastedHtml); executeScenario(initialContent, expectedContent, scratchContainer, Operation.PASTE); }
Example 20
Source File: PasteExtractorGwtTest.java From incubator-retired-wave with Apache License 2.0 | 2 votes |
/** * Performs a paste operation and checks the initial content with the expected. * @param initialContent The initial XML fragment inside the document. * @param expectedContent The expected XML fragment inside the document * as a result of the paste. * @param pastedHtml The SGML fragment that would exist at the point of * the vertical bar in <p>x|x</p>, if something were pasted there. */ protected void executePaste(String initialContent, String pastedHtml, String expectedContent) { Element scratchContainer = Document.get().createDivElement(); scratchContainer.setInnerHTML(pastedHtml); executeScenario(initialContent, expectedContent, scratchContainer, Operation.PASTE); }