Search in sources :

Example 1 with XmlDocumentUtilities

use of net.sourceforge.usbdm.deviceEditor.xmlParser.XmlDocumentUtilities in project usbdm-eclipse-plugins by podonoghue.

the class FamilyXmlWriter method writeXmlFile.

/**
 * Writes XML file
 *
 * @param xmlFilePath      Path to write XML to
 * @param deviceInfomation Data to write
 * @throws Exception
 */
public void writeXmlFile(Path xmlFilePath) throws Exception {
    String xmlFilename = xmlFilePath.getFileName().toString();
    BufferedWriter writer = Files.newBufferedWriter(xmlFilePath, StandardCharsets.UTF_8);
    XmlDocumentUtilities documentUtilities = new XmlDocumentUtilities(writer);
    documentUtilities.writeXmlFilePreamble(xmlFilename, DeviceInfo.DTD_FILE, "Generated from " + fDeviceInfo.getSourceFilename());
    documentUtilities.openTag("root");
    documentUtilities.writeAttribute("version", DeviceInfo.VERSION);
    documentUtilities.openTag("family");
    documentUtilities.writeAttribute("name", fDeviceInfo.getDeviceSubFamily());
    for (String key : fDeviceInfo.getDeviceVariants().keySet()) {
        DeviceVariantInformation deviceInformation = fDeviceInfo.findVariant(key);
        documentUtilities.openTag("device");
        documentUtilities.writeAttribute("name", deviceInformation.getName());
        documentUtilities.writeAttribute("manual", deviceInformation.getManual());
        documentUtilities.writeAttribute("package", deviceInformation.getPackage().getName());
        documentUtilities.closeTag();
    }
    documentUtilities.closeTag();
    writePeripherals(documentUtilities);
    // writeSignals(documentUtilities);
    writePins(documentUtilities);
    writePackages(documentUtilities);
    documentUtilities.closeTag();
    writer.close();
}
Also used : XmlDocumentUtilities(net.sourceforge.usbdm.deviceEditor.xmlParser.XmlDocumentUtilities) BufferedWriter(java.io.BufferedWriter) DeviceVariantInformation(net.sourceforge.usbdm.deviceEditor.information.DeviceVariantInformation)

Example 2 with XmlDocumentUtilities

use of net.sourceforge.usbdm.deviceEditor.xmlParser.XmlDocumentUtilities in project usbdm-eclipse-plugins by podonoghue.

the class Settings method save.

/**
 * Save persistent settings to path
 *
 * @param path
 */
public void save(Path path) {
    try {
        BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8);
        fDocumentUtilities = new XmlDocumentUtilities(writer);
        fDocumentUtilities.writeXmlFilePreamble(path.getFileName().toString(), null, "Settings");
        save();
        writer.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : XmlDocumentUtilities(net.sourceforge.usbdm.deviceEditor.xmlParser.XmlDocumentUtilities) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Aggregations

BufferedWriter (java.io.BufferedWriter)2 XmlDocumentUtilities (net.sourceforge.usbdm.deviceEditor.xmlParser.XmlDocumentUtilities)2 IOException (java.io.IOException)1 DeviceVariantInformation (net.sourceforge.usbdm.deviceEditor.information.DeviceVariantInformation)1