List of usage examples for com.google.gwt.xml.client Document importNode
Node importNode(Node importedNode, boolean deep);
Document. From source file:org.openxdata.designer.client.CenterPanel.java
/** * Builds the language xml and puts it in the language xml tab. *///from w w w . j a va 2 s . c om public void buildLanguageXml() { Document doc = LanguageUtil.createNewLanguageDoc(); Element rootNode = doc.getDocumentElement(); Element node = null; if (formDef != null) { node = formDef.getLanguageNode(); if (node != null) rootNode.appendChild(doc.importNode(node, true)); } node = designSurfaceView.getLanguageNode(); if (node != null) rootNode.appendChild(doc.importNode(node, true)); txtLanguageXml.setText(FormDesignerUtil.formatXml(doc.toString())); if (formDef != null) formDef.setLanguageXml(txtLanguageXml.getText()); }
From source file:org.openxdata.designer.client.util.LanguageUtil.java
/** * Gets an xml text which combines locale text for the xform and layout text. * //w ww . j a v a 2s .co m * @param xform the xform locale text. * @param layout the layout locale text. * @return the combined text. */ public static String getLocaleText(String xform, String layout) { Document doc = createNewLanguageDoc(); if (xform != null && xform.trim().length() > 0) doc.getDocumentElement().appendChild(doc.importNode(XMLParser.parse(xform).getDocumentElement(), true)); if (layout != null && layout.trim().length() > 0) doc.getDocumentElement() .appendChild(doc.importNode(XMLParser.parse(layout).getDocumentElement(), true)); return doc.toString(); }
From source file:org.openxdata.designer.client.xforms.OpenXdataFormBuilder.java
public static String build(FormDef formDef, HashMap<String, String> localeText) { Document doc = XMLParser.createDocument(); doc.appendChild(doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"")); Element openXdataFormNode = doc.createElement("PurcForm"); doc.appendChild(openXdataFormNode);/* ww w . jav a 2 s. co m*/ Element xformNode = doc.createElement("Xform"); Element node = (Element) formDef.getDoc().getDocumentElement().cloneNode(true); doc.importNode(node, true); xformNode.appendChild(node); openXdataFormNode.appendChild(xformNode); String xml = formDef.getLayoutXml(); if (xml != null && xml.trim().length() > 0) { node = (Element) XmlUtil.getDocument(xml).getDocumentElement().cloneNode(true); doc.importNode(node, true); Element layoutNode = doc.createElement("Layout"); layoutNode.appendChild(node); openXdataFormNode.appendChild(layoutNode); } String src = formDef.getJavaScriptSource(); if (src != null && src.trim().length() > 0) { Element javaScriptNode = doc.createElement("JavaScript"); javaScriptNode.appendChild(doc.createCDATASection(src)); openXdataFormNode.appendChild(javaScriptNode); } openXdataFormNode.appendChild(getLanguageNode(doc, localeText)); return XmlUtil.fromDoc2String(doc); }
From source file:org.openxdata.designer.client.xforms.OpenXdataFormBuilder.java
private static Element getLanguageNode(Document doc, HashMap<String, String> localeText) { Element languageNode = doc.createElement("Language"); Set<String> locales = localeText.keySet(); for (String locale : locales) { Element node = (Element) XmlUtil.getDocument(localeText.get(locale)).getDocumentElement() .cloneNode(true);//w ww.j a v a 2s .c om doc.importNode(node, true); languageNode.appendChild(node); } return languageNode; }
From source file:org.openxdata.sharedlib.client.xforms.XformUtil.java
/** * Copies the xforms model instance from one document to another. * //from ww w . j a v a 2 s . c o m * @param srcDoc the xforms document with the model instance to copy. * @param destDoc the xforms document whose model instance we are to replace with the copied one. */ public static void copyModel(Document srcDoc, Document destDoc) { if (srcDoc != null) { Element oldModel = getModelNode(srcDoc.getDocumentElement()); Element newModel = getModelNode(destDoc.getDocumentElement()); if (oldModel != null && newModel != null) { oldModel = (Element) oldModel.cloneNode(true); destDoc.importNode(oldModel, true); newModel.getParentNode().appendChild(oldModel); newModel.getParentNode().removeChild(newModel); } } }