List of usage examples for org.dom4j.tree DefaultDocument processingInstructions
public List<ProcessingInstruction> processingInstructions()
From source file:com.cladonia.xml.viewer.Viewer.java
License:Open Source License
private void update() { if (tree != null && document != null) { if (showPI()) { XElement dummyElement = new XElement(XNGR_DUMMY_ROOT); DefaultDocument doc = (DefaultDocument) document.getDocument(); List pis = doc.processingInstructions(); Vector allPIs = new Vector(); ;/*from ww w . j av a 2s . c o m*/ for (int i = 0; i < pis.size(); i++) { ProcessingInstruction pi = (ProcessingInstruction) pis.get(i); if (!addedPI(allPIs, pi.getTarget() + pi.getText())) { dummyElement.addProcessingInstruction(pi.getTarget(), pi.getText()); allPIs.add(pi.getTarget() + pi.getText()); } } XmlElementNode dummyRoot = new XmlElementNode(this, dummyElement); XmlElementNode node = new XmlElementNode(this, (XElement) document.getRoot()); dummyRoot.add(node); tree.setRoot(dummyRoot); tree.expand(4); tree.setRootVisible(false); } else { XmlElementNode node = new XmlElementNode(this, (XElement) document.getRoot()); tree.setRoot(node); tree.expand(3); tree.setRootVisible(true); } } }
From source file:com.cladonia.xml.viewer.Viewer.java
License:Open Source License
public void setDocument(ExchangerDocument document) { if (DEBUG)/* w w w. j a va 2 s .c o m*/ System.out.println("Viewer.setDocument( " + document + ")"); if (this.document != null) { this.document.removeListener(this); } this.document = document; if (document != null) { document.addListener(this); } if (document != null && !document.isError()) { if (showPI()) { XElement dummyElement = new XElement(XNGR_DUMMY_ROOT); DefaultDocument doc = (DefaultDocument) document.getDocument(); List pis = doc.processingInstructions(); for (int i = 0; i < pis.size(); i++) { ProcessingInstruction pi = (ProcessingInstruction) pis.get(i); dummyElement.addProcessingInstruction(pi.getTarget(), pi.getText()); } XmlElementNode dummyRoot = new XmlElementNode(this, dummyElement); XmlElementNode node = new XmlElementNode(this, (XElement) document.getRoot()); dummyRoot.add(node); tree.setRoot(dummyRoot); tree.expand(4); tree.setRootVisible(false); } else { XmlElementNode node = new XmlElementNode(this, (XElement) document.getRoot()); tree.setRoot(node); tree.expand(3); tree.setRootVisible(true); } } else { tree.setRoot(null); } hasLatest = true; }