List of usage examples for org.w3c.dom Node setTextContent
public void setTextContent(String textContent) throws DOMException;
From source file:org.gvnix.web.screen.roo.addon.SeleniumServicesImpl.java
/** * Add command click and wait for a URL. * //from w w w. j a v a 2s . com * @param document Document to write command * @param linkTarget Destination URL * @return Click and wait node */ protected Node clickAndWaitCommand(Document document, String linkTarget) { Node tr = document.createElement("tr"); Node td1 = tr.appendChild(document.createElement("td")); td1.setTextContent("clickAndWait"); Node td2 = tr.appendChild(document.createElement("td")); td2.setTextContent(linkTarget); Node td3 = tr.appendChild(document.createElement("td")); td3.setTextContent(" "); return tr; }
From source file:org.gvnix.web.screen.roo.addon.SeleniumServicesImpl.java
/** * Add command click for a URL./* ww w.ja v a 2 s .c o m*/ * * @param document Document to write command * @param linkTarget Destination URL * @return Click node */ protected Node clickCommand(Document document, String linkTarget) { Node tr = document.createElement("tr"); Node td1 = tr.appendChild(document.createElement("td")); td1.setTextContent("click"); Node td2 = tr.appendChild(document.createElement("td")); td2.setTextContent(linkTarget); Node td3 = tr.appendChild(document.createElement("td")); td3.setTextContent(" "); return tr; }
From source file:org.gvnix.web.screen.roo.addon.SeleniumServicesImpl.java
/** * Add type value command for register pattern. * //from w w w. j av a 2 s .c om * @param document Document to write command * @param field Field to add value * @return Type node */ protected Node typeCommandRegister(Document document, FieldMetadata field, boolean random) { Node tr = document.createElement("tr"); Node td1 = tr.appendChild(document.createElement("td")); td1.setTextContent("type"); Node td2 = tr.appendChild(document.createElement("td")); td2.setTextContent("_" + field.getFieldName().getSymbolName() + "_id"); Node td3 = tr.appendChild(document.createElement("td")); td3.setTextContent(convertToInitializer(field, random)); return tr; }
From source file:org.gvnix.web.screen.roo.addon.SeleniumServicesImpl.java
/** * Add type value command for tabular pattern. * //from w w w.j ava 2s . co m * @param document Document to write command * @param field Field to add value * @param entity Field parent entity * @return Type node */ protected Node typeCommandTabular(Document document, FieldMetadata field, JavaType entity, boolean random) { Node tr = document.createElement("tr"); Node td1 = tr.appendChild(document.createElement("td")); td1.setTextContent("type"); Node td2 = tr.appendChild(document.createElement("td")); String id = "_" + XmlUtils.convertId("fu:" + entity.getFullyQualifiedTypeName()) + "[0]_" + field.getFieldName() + "_id_create"; td2.setTextContent(id); Node td3 = tr.appendChild(document.createElement("td")); td3.setTextContent(convertToInitializer(field, random)); return tr; }
From source file:org.gvnix.web.screen.roo.addon.SeleniumServicesImpl.java
/** * Add verification value command for register pattern field. * /*from ww w.jav a 2s .c o m*/ * @param document Document to write command * @param entity Field parent entity * @param field Field to verify value * @return Verification node */ protected Node verifyCommandRegister(Document document, JavaType entity, FieldMetadata field) { Node tr = document.createElement("tr"); Node td1 = tr.appendChild(document.createElement("td")); td1.setTextContent("verifyText"); Node td2 = tr.appendChild(document.createElement("td")); td2.setTextContent(XmlUtils.convertId("_s_" + entity.getFullyQualifiedTypeName() + "_" + field.getFieldName().getSymbolName() + "_" + field.getFieldName().getSymbolName() + "_id")); Node td3 = tr.appendChild(document.createElement("td")); td3.setTextContent(convertToInitializer(field)); return tr; }
From source file:org.gvnix.web.screen.roo.addon.SeleniumServicesImpl.java
/** * Add verification value command for tabular pattern field. * // w ww . j a va 2 s .c o m * @param document Document to write command * @param entity Field parent entity * @param field Field to verify value * @return Verification node */ protected Node verifyCommandTabular(Document document, JavaType entity, FieldMetadata field) { Node tr = document.createElement("tr"); Node td1 = tr.appendChild(document.createElement("td")); td1.setTextContent("verifyValue"); Node td2 = tr.appendChild(document.createElement("td")); String id = "_" + XmlUtils.convertId("fu:" + entity.getFullyQualifiedTypeName()) + "[0]_" + field.getFieldName() + "_id_update"; td2.setTextContent(XmlUtils.convertId(id)); Node td3 = tr.appendChild(document.createElement("td")); td3.setTextContent(convertToInitializer(field)); return tr; }
From source file:org.gvnix.web.screen.roo.addon.SeleniumServicesImpl.java
/** * Add store confirmation command, required before a javascript * confirmation./*from w ww .j ava 2 s. co m*/ * * @param document Document to write command * @param varName Name of variable to store confirmation value * @return Confirmation node */ protected Node storeConfirmationCommand(Document document, String varName) { Node tr = document.createElement("tr"); Node td1 = tr.appendChild(document.createElement("td")); td1.setTextContent("storeConfirmation"); Node td2 = tr.appendChild(document.createElement("td")); td2.setTextContent(XmlUtils.convertId(varName)); Node td3 = tr.appendChild(document.createElement("td")); td3.setTextContent(" "); return tr; }
From source file:org.gvnix.web.screen.roo.addon.SeleniumServicesImpl.java
/** * Add check command, to check a checkbox or radio. * /*w w w . j ava 2 s .co m*/ * @param document Document to write command * @param entity Entity owner of check property * @return Check node */ protected Node checkCommand(Document document, JavaType entity) { Node tr = document.createElement("tr"); Node td1 = tr.appendChild(document.createElement("td")); td1.setTextContent("check"); Node td2 = tr.appendChild(document.createElement("td")); String id = GVNIX_CHECKBOX + XmlUtils.convertId(entity.getFullyQualifiedTypeName()) + "_0"; td2.setTextContent(id); Node td3 = tr.appendChild(document.createElement("td")); td3.setTextContent(" "); return tr; }
From source file:org.jboss.tools.aerogear.hybrid.android.core.adt.AndroidProjectGenerator.java
private void updateAppName(String appName) throws CoreException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true);/*from w w w. ja v a2 s . c o m*/ DocumentBuilder db; try { db = dbf.newDocumentBuilder(); IPath stringsPath = new Path(getDestination().toString()).append(DIR_RES).append(DIR_VALUES) .append(FILE_XML_STRINGS); File strings = stringsPath.toFile(); Document configDocument = db.parse(strings); XPath xpath = XPathFactory.newInstance().newXPath(); try { XPathExpression expr = xpath.compile("//string[@name=\"app_name\"]"); Node node = (Node) expr.evaluate(configDocument, XPathConstants.NODE); node.setTextContent(appName); configDocument.setXmlStandalone(true); Source source = new DOMSource(configDocument); StreamResult result = new StreamResult(strings); // Write the DOM document to the file TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer xformer = transformerFactory.newTransformer(); xformer.transform(source, result); } catch (XPathExpressionException e) {//We continue because this affects the displayed app name // which is not a show stopper during development AndroidCore.log(IStatus.ERROR, "Error when updating the application name", e); } catch (TransformerConfigurationException e) { AndroidCore.log(IStatus.ERROR, "Error when updating the application name", e); } catch (TransformerException e) { AndroidCore.log(IStatus.ERROR, "Error when updating the application name", e); } } catch (ParserConfigurationException e) { throw new CoreException(new Status(IStatus.ERROR, HybridCore.PLUGIN_ID, "Parser error when parsing /res/values/strings.xml", e)); } catch (SAXException e) { throw new CoreException( new Status(IStatus.ERROR, HybridCore.PLUGIN_ID, "Parsing error on /res/values/strings.xml", e)); } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, HybridCore.PLUGIN_ID, "IO error when parsing /res/values/strings.xml", e)); } }
From source file:org.kramerius.replications.SecondPhase.java
private void replicateImg(String pid, String url, File foxml) throws PhaseException { try {//from w w w . ja v a2s . c o m String handlePid = K4ReplicationProcess.pidFrom(url); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(foxml); String relsExt = RelsExtHelper.getRelsExtTilesUrl(document); // url of tiles if (relsExt != null) { InputStream stream = orignalImgData(pid, url); String imageserverDir = KConfiguration.getInstance().getConfiguration() .getString("convert.imageServerDirectory"); String path = imageserverDir + File.separator + handlePid.substring(5) + File.separator; FileUtils.forceMkdir(new File(path)); File replicatedImage = new File(path + pid.substring(5) + ".jp2"); FileUtils.copyInputStreamToFile(stream, replicatedImage); XPathFactory xpfactory = XPathFactory.newInstance(); XPath xpath = xpfactory.newXPath(); xpath.setNamespaceContext(new FedoraNamespaceContext()); Node nodeTilesUrl = (Node) xpath.evaluate("//kramerius:tiles-url", document, XPathConstants.NODE); String imageServerTilesUrl = KConfiguration.getInstance().getConfiguration() .getString("convert.imageServerTilesURLPrefix"); String suffixTiles = KConfiguration.getInstance().getConfiguration() .getString("convert.imageServerSuffix.tiles"); String imageTilesUrl; if (KConfiguration.getInstance().getConfiguration() .getBoolean("convert.imageServerSuffix.removeFilenameExtensions", false)) { imageTilesUrl = imageServerTilesUrl + "/" + handlePid.substring(5) + pid.substring(5) + suffixTiles; } else { imageTilesUrl = imageServerTilesUrl + "/" + handlePid.substring(5) + pid.substring(5) + ".jp2" + suffixTiles; } nodeTilesUrl.setTextContent(imageTilesUrl); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(new DOMSource(document), new StreamResult(foxml)); } } catch (ParserConfigurationException | IOException | XPathExpressionException | SAXException | TransformerException e) { throw new PhaseException(this, e); } }