Search in sources :

Example 61 with XMLOutputter

use of org.jdom.output.XMLOutputter in project vcell by virtualcell.

the class Translator method print.

private void print(Writer outStream, String printedDoc) throws IllegalStateException {
    if ((printedDoc.equals("source") && sRoot == null) || (printedDoc.equals("target") && tRoot == null))
        throw new IllegalStateException("Nothing to print.");
    XMLOutputter xmlOut = new XMLOutputter();
    // xmlOut.setNewlines(true);
    try {
        if (printedDoc.equals("source")) {
            xmlOut.getFormat().setTextMode(Format.TextMode.TRIM_FULL_WHITE);
            xmlOut.output(sRoot, outStream);
        } else {
            xmlOut.output(tRoot, outStream);
        }
    } catch (IOException e) {
        System.err.println("Unable to write out XML file.");
        e.printStackTrace();
    }
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) IOException(java.io.IOException)

Example 62 with XMLOutputter

use of org.jdom.output.XMLOutputter in project vcell by virtualcell.

the class BiomodelsDB_TestSuite method write.

private static void write(Document doc, File file) throws IOException {
    PrintWriter reportFileWriter = new PrintWriter(file);
    XMLOutputter outputter = new XMLOutputter();
    outputter.getFormat().setLineSeparator("\n");
    outputter.output(doc, reportFileWriter);
    reportFileWriter.flush();
    reportFileWriter.close();
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) PrintWriter(java.io.PrintWriter)

Example 63 with XMLOutputter

use of org.jdom.output.XMLOutputter in project vcell by virtualcell.

the class VisMeshUtils method writeCellDataToVtu.

public static void writeCellDataToVtu(File inputMeshFile, String dataName, double[] data, File outputMeshFile) throws IOException {
    Document meshDocument = XmlUtil.readXML(inputMeshFile);
    addCellDataToVtuXml(meshDocument, dataName, data);
    FileWriter fw = null;
    try {
        fw = new FileWriter(outputMeshFile);
        XMLOutputter xmlOut = new XMLOutputter();
        Format f = Format.getRawFormat();
        f.setLineSeparator("\n");
        f.setOmitEncoding(true);
        f.setExpandEmptyElements(true);
        xmlOut.setFormat(f);
        xmlOut.output(meshDocument, fw);
    } finally {
        if (fw != null) {
            fw.close();
        }
    }
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format) FileWriter(java.io.FileWriter) Document(org.jdom.Document)

Example 64 with XMLOutputter

use of org.jdom.output.XMLOutputter in project yamcs-studio by yamcs.

the class CopyPropertiesAction method run.

@Override
public void run() {
    PropertiesSelectDialog dialog = new PropertiesSelectDialog(null, getSelectedWidgetModels().get(0));
    if (dialog.open() == Window.OK) {
        List<String> propList = dialog.getOutput();
        if (!propList.isEmpty()) {
            AbstractWidgetModel widget = getSelectedWidgetModels().get(0);
            Element widgetElement = XMLUtil.widgetToXMLElement(widget);
            Element propertisElement = new Element(PROPID_ELEMENT);
            for (String propID : propList) {
                propertisElement.addContent(new Element(propID));
            }
            Element rootElement = new Element(ROOT_ELEMENT);
            rootElement.addContent(widgetElement);
            rootElement.addContent(propertisElement);
            XMLOutputter xmlOutputter = new XMLOutputter(Format.getRawFormat());
            String xmlString = xmlOutputter.outputString(rootElement);
            ((OPIEditor) getWorkbenchPart()).getClipboard().setContents(new Object[] { xmlString }, new Transfer[] { PropertiesCopyDataTransfer.getInstance() });
        }
    }
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) Element(org.jdom.Element) PropertiesSelectDialog(org.csstudio.opibuilder.visualparts.PropertiesSelectDialog)

Aggregations

XMLOutputter (org.jdom.output.XMLOutputter)64 Element (org.jdom.Element)34 Document (org.jdom.Document)22 Format (org.jdom.output.Format)22 IOException (java.io.IOException)16 StringWriter (java.io.StringWriter)14 ArrayList (java.util.ArrayList)7 StringReader (java.io.StringReader)5 Writer (java.io.Writer)5 SAXBuilder (org.jdom.input.SAXBuilder)5 FileWriter (java.io.FileWriter)4 List (java.util.List)3 TreeMap (java.util.TreeMap)3 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)3 JDOMException (org.jdom.JDOMException)3 ElementFilter (org.jdom.filter.ElementFilter)3 BufferedOutputStream (java.io.BufferedOutputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2