/** * Creates an html tree node corresponding to the given element. Also * initializes its attributes by calling writeDesign. As a result of the * writeDesign() call, this method creates the entire subtree rooted at the * returned Node. * * @param childComponent * The component with state that is written in to the node * @return An html tree node corresponding to the given component. The tag * name of the created node is derived from the class name of * childComponent. */ public Element createElement(Component childComponent) { ComponentMapper componentMapper = Design.getComponentMapper(); String tagName = componentMapper.componentToTag(childComponent, this); Element newElement = doc.createElement(tagName); childComponent.writeDesign(newElement, this); // Handle the local id. Global id and caption should have been taken // care of by writeDesign. String localId = componentToLocalId.get(childComponent); if (localId != null) { newElement.attr(LOCAL_ID_ATTRIBUTE, localId); } return newElement; }
/** * Writes the package mappings (prefix -> package name) of this object to * the specified document. * <p> * The prefixes are stored as <meta> tags under <head> in the document. * * @param doc * the Jsoup document tree where the package mappings are written */ public void writePackageMappings(Document doc) { Element head = doc.head(); for (String prefix : getPackagePrefixes()) { // Only store the prefix-name mapping if it is not a default mapping // (such as "vaadin" -> "com.vaadin.ui") if (!VAADIN_PREFIX.equals(prefix) && !VAADIN7_PREFIX.equals(prefix) && !LEGACY_PREFIX.equals(prefix)) { Node newNode = doc.createElement("meta"); newNode.attr("name", "package-mapping"); String prefixToPackageName = prefix + ":" + getPackage(prefix); newNode.attr("content", prefixToPackageName); head.appendChild(newNode); } } }
DocumentType docType = new DocumentType("html", "", "", ""); doc.appendChild(docType); Element html = doc.createElement("html"); doc.appendChild(html); html.appendChild(doc.createElement("head")); Element body = doc.createElement("body"); html.appendChild(body);
private void addVersionNumber(Document document) { Element versionNumber = document.createElement("div") .attr("id", "versionList") .attr("class", "process-version"); document.appendChild(versionNumber); versionNumber.append(description + " v. " + version); }
protected void includeMetaViewport(String content, BootstrapPageResponse response, Element head) { Element meta = response.getDocument().createElement("meta"); meta.attr("name", "viewport"); meta.attr("content", content); head.appendChild(meta); } }
protected void includeScript(String src, BootstrapPageResponse response, Element head) { Element script = response.getDocument().createElement("script"); script.attr("src", src); head.appendChild(script); }
/** * Get the article title as an H1. Currently just uses document.title, we * might want to be smarter in the future. * * @return */ protected Element getArticleTitle() { Element articleTitle = mDocument.createElement("h1"); articleTitle.html(mDocument.title()); return articleTitle; }
private void createButton(Element parent, String actionButtonId, String buttonClass, String iconClass, String messageKey, String descriptionKey, String clickFunction) { Element buttonNode = parent.ownerDocument().createElement("button") .attr("class", buttonClass != null ? "btn btn-" + buttonClass : "btn") .attr("disabled", "true") .attr("id", actionButtonId) .attr("data-toggle", "tooltip") .attr("data-placement", "bottom") .attr("title", i18Source.getMessage(descriptionKey)); Element buttonIcon = parent.ownerDocument().createElement("span") .attr("class", iconClass != null ? "glyphicon glyphicon-" + iconClass : "glyphicon"); parent.appendChild(buttonNode); buttonNode.appendChild(buttonIcon); buttonNode.appendText(i18Source.getMessage(messageKey)); scriptBuilder.append("$('#").append(actionButtonId).append("').click(function() { ").append(clickFunction).append("('").append(getViewedObjectId()).append("'); });"); scriptBuilder.append("$('#").append(actionButtonId).append("').tooltip();"); }
@Override public void modifyBootstrapPage(BootstrapPageResponse response) { // Obtain electron UI API end point Element head = response.getDocument().getElementsByTag("head").get(0); Element script = response.getDocument().createElement("script"); script.attr("type", "text/javascript"); URL jsBridge = AppServlet.class.getResource("/org/strangeway/electronvaadin/resources/electron-bridge.js"); try { script.text(IOUtils.toString(jsBridge, StandardCharsets.UTF_8)); } catch (IOException e) { throw new RuntimeException("Unable to load JS bridge", e); } head.appendChild(script); } }
private Element changeElementTag(Element e, String newTag) { Element newElement = document.createElement(newTag); /* JSoup gives us the live child list, so we need to make a copy. */ List<Node> copyOfChildNodeList = new ArrayList<Node>(); copyOfChildNodeList.addAll(e.childNodes()); for (Node n : copyOfChildNodeList) { n.remove(); newElement.appendChild(n); } e.replaceWith(newElement); return newElement; }
private void addClaimActionButton(Element parent) { String actionButtonId = "action-button-claim"; Element buttonNode = parent.ownerDocument().createElement("button") .attr("class", "btn btn-warning") .attr("disabled", "true") .attr("id", actionButtonId); parent.appendChild(buttonNode); Element cancelButtonIcon = parent.ownerDocument().createElement("span") .attr("class", "glyphicon glyphicon-download"); parent.appendChild(buttonNode); buttonNode.appendChild(cancelButtonIcon); buttonNode.appendText(i18Source.getMessage("button.claim")); Long processStateConfigurationId = task.getCurrentProcessStateConfiguration().getId(); scriptBuilder.append("$('#").append(actionButtonId) .append("').click(function() { claimTaskFromQueue('#action-button-claim','null', '") .append(processStateConfigurationId).append("','") .append(task.getInternalTaskId()) .append("'); });") .append("$('#").append(actionButtonId) .append("').tooltip({placement: 'bottom', title: '").append(i18Source.getMessage("button.claim.descrition")).append("'});"); }
run = document.createElement("p");
@Override public void modifyBootstrapPage(BootstrapPageResponse response) { Document document = response.getDocument(); Element head = document.getElementsByTag("head").get(0); for (ApplicationIcon icon : applicationIcon) { // <link rel="apple-touch-icon" sizes="114x114" // href="touch-icon-iphone4.png" /> Element iconEl = document.createElement("link"); iconEl.attr("rel", "apple-touch-icon"); String sizes = icon.getSizes(); if (sizes != null) { iconEl.attr("sizes", sizes); } iconEl.attr("href", icon.getHref()); head.appendChild(iconEl); } }
run = document.createElement("p");
public StringBuilder build() throws Exception { final StringBuilder stringBuilder = new StringBuilder(8 * 1024); scriptBuilder.append("<script type=\"text/javascript\">"); final Document document = Jsoup.parse(""); if (!hasUserPriviledgesToViewTask()) { final Element widgetsNode = document.createElement("div") .attr("role", "alert") .attr("class", "alert alert-warning"); widgetsNode.text(i18Source.getMessage("task.noright.to.view")); document.appendChild(widgetsNode); stringBuilder.append(document.toString()); return stringBuilder; } if (showGenericButtons()) buildActionButtons(document); final Element widgetsNode = document.createElement("div") .attr("id", getVaadinWidgetsHtmlId()) .attr("class", "vaadin-widgets-view"); document.appendChild(widgetsNode); buildWidgets(document, widgetsNode); buildAdditionalData(document); stringBuilder.append(document.toString()); scriptBuilder.append("vaadinWidgetsCount = ").append(vaadinWidgetsCount).append(';'); scriptBuilder.append("</script>"); stringBuilder.append(scriptBuilder); return stringBuilder; }
final Element e = document.createElement("details").addClass("footnote") .text(matcher.group("content")); p.appendChild(e);
/** * Add actions buttons to the output document. */ protected void buildActionButtons(final Document document) { Element actionsNode = document.createElement("div") //.attr("id", "actions-list") .attr("id", getActionsListHtmlId()) .attr("class", "actions-view") .addClass("fixed-element-action-buttons"); document.appendChild(actionsNode); Element genericActionButtons = document.createElement("div") .attr("id", getActionsGenericListHtmlId()) .attr("class", "btn-group pull-left actions-generic-view"); Element specificActionButtons = document.createElement("div") .attr("id", getActionsSpecificListHtmlId()) .attr("class", "btn-group pull-right actions-process-view"); actionsNode.appendChild(genericActionButtons); actionsNode.appendChild(specificActionButtons); document.appendElement("div").addClass("fixed-element-anchor-action-buttons"); /* Check if the viewed object is in a terminal state */ buildGenericActionButtons(genericActionButtons); if (!isViewedObjectClosed()) { buildSpecificActionButtons(specificActionButtons); } }
@Bean @Lazy String processedIndexHtml() throws IOException { String baseTagValue = "/".equals(ui.getBasepath()) ? "/" : ui.getBasepath() + "/"; Document soup; try (InputStream is = indexHtml.getInputStream()) { soup = Jsoup.parse(is, null, baseTagValue); } if (soup.head().getElementsByTag("base").isEmpty()) { soup.head().appendChild( soup.createElement("base") ); } soup.head().getElementsByTag("base").attr("href", baseTagValue); return soup.html(); }
doctype.replaceWith(html5doc); Element element = document.createElement("meta"); element.attr("name", "viewport"); StringBuilder content = new StringBuilder(); element = document.createElement("meta"); element.attr("name", "msapplication-tap-highlight"); element.attr("content", "no");
.createElement(element.getTag()); if (element.hasProperty("innerHTML")) { target.html((String) element.getPropertyRaw("innerHTML"));