Java Code Examples for elemental.client.Browser#getDocument()
The following examples show how to use
elemental.client.Browser#getDocument() .
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: ResourceLoader.java From flow with Apache License 2.0 | 6 votes |
/** * Populates the resource loader with the scripts currently added to the * page. */ private void initLoadedResourcesFromDom() { Document document = Browser.getDocument(); // detect already loaded scripts and stylesheets NodeList scripts = document.getElementsByTagName("script"); for (int i = 0; i < scripts.getLength(); i++) { ScriptElement element = (ScriptElement) scripts.item(i); String src = element.getSrc(); if (src != null && src.length() != 0) { loadedResources.add(src); } } NodeList links = document.getElementsByTagName("link"); for (int i = 0; i < links.getLength(); i++) { LinkElement linkElement = (LinkElement) links.item(i); String rel = linkElement.getRel(); String href = linkElement.getHref(); if (("stylesheet".equalsIgnoreCase(rel) || "import".equalsIgnoreCase(rel)) && href != null && href.length() != 0) { loadedResources.add(href); } } }
Example 2
Source File: SystemErrorHandler.java From flow with Apache License 2.0 | 4 votes |
private Element handleError(String caption, String message, String details, String querySelector) { Document document = Browser.getDocument(); Element systemErrorContainer = document.createDivElement(); systemErrorContainer.setClassName("v-system-error"); if (caption != null) { Element captionDiv = document.createDivElement(); captionDiv.setClassName("caption"); captionDiv.setInnerHTML(caption); systemErrorContainer.appendChild(captionDiv); Console.error(caption); } if (message != null) { Element messageDiv = document.createDivElement(); messageDiv.setClassName("message"); messageDiv.setInnerHTML(message); systemErrorContainer.appendChild(messageDiv); Console.error(message); } if (details != null) { Element detailsDiv = document.createDivElement(); detailsDiv.setClassName("details"); detailsDiv.setInnerHTML(details); systemErrorContainer.appendChild(detailsDiv); Console.error(details); } if (querySelector != null) { Element baseElement = document.querySelector(querySelector); // if querySelector does not match an element on the page, the // error will not be displayed if (baseElement != null) { // if the baseElement has a shadow root, add the warning to // the shadow - otherwise add it to the baseElement findShadowRoot(baseElement).orElse(baseElement) .appendChild(systemErrorContainer); } } else { document.getBody().appendChild(systemErrorContainer); } return systemErrorContainer; }
Example 3
Source File: ResourceLoader.java From flow with Apache License 2.0 | 4 votes |
private static Document getDocument() { return Browser.getDocument(); }
Example 4
Source File: Elements.java From core with GNU Lesser General Public License v2.1 | 4 votes |
public Builder() { this(Browser.getDocument()); }