Search in sources :

Example 96 with Element

use of org.jdom2.Element in project JMRI by JMRI.

the class ConnectionConfigXml method makeParameter.

protected Element makeParameter(String name, String value) {
    Element p = new Element("parameter");
    p.setAttribute("name", name);
    p.addContent(value);
    return p;
}
Also used : Element(org.jdom2.Element)

Example 97 with Element

use of org.jdom2.Element in project JMRI by JMRI.

the class ConnectionConfigXml method extendElement.

/**
     * Write out the SerialNode objects too
     *
     * @param e Element being extended
     */
@Override
protected void extendElement(Element e) {
    XBeeConnectionMemo xcm;
    XBeeTrafficController xtc;
    try {
        xcm = (XBeeConnectionMemo) adapter.getSystemConnectionMemo();
        xtc = (XBeeTrafficController) xcm.getTrafficController();
    } catch (NullPointerException npe) {
        // The adapter doesn't have a memo, so no nodes can be defined.
        if (log.isDebugEnabled()) {
            log.debug("No memo defined; no nodes to save.");
        }
        return;
    }
    try {
        XBeeNode node = (XBeeNode) xtc.getNode(0);
        int index = 1;
        while (node != null) {
            // add node as an element
            Element n = new Element("node");
            n.setAttribute("name", "" + node.getNodeAddress());
            e.addContent(n);
            // add parameters to the node as needed
            n.addContent(makeParameter("address", "" + jmri.util.StringUtil.hexStringFromBytes(node.getUserAddress())));
            n.addContent(makeParameter("PAN", "" + jmri.util.StringUtil.hexStringFromBytes(node.getPANAddress())));
            n.addContent(makeParameter("GUID", "" + jmri.util.StringUtil.hexStringFromBytes(node.getGlobalAddress())));
            n.addContent(makeParameter("name", node.getIdentifier()));
            n.addContent(makeParameter("polled", node.getPoll() ? "yes" : "no"));
            jmri.jmrix.AbstractStreamPortController pc = null;
            if ((pc = node.getPortController()) != null) {
                n.addContent(makeParameter("StreamController", pc.getClass().getName()));
            }
            // look for the next node
            node = (XBeeNode) xtc.getNode(index);
            index++;
        }
    } catch (java.lang.NullPointerException npe2) {
        // no nodes defined.
        return;
    }
}
Also used : XBeeConnectionMemo(jmri.jmrix.ieee802154.xbee.XBeeConnectionMemo) XBeeTrafficController(jmri.jmrix.ieee802154.xbee.XBeeTrafficController) Element(org.jdom2.Element) AbstractStreamPortController(jmri.jmrix.AbstractStreamPortController) XBeeNode(jmri.jmrix.ieee802154.xbee.XBeeNode)

Example 98 with Element

use of org.jdom2.Element in project JMRI by JMRI.

the class ConnectionConfigXml method makeParameter.

protected Element makeParameter(String name, String value) {
    Element p = new Element("parameter");
    p.setAttribute("name", name);
    p.addContent(value);
    return p;
}
Also used : Element(org.jdom2.Element)

Example 99 with Element

use of org.jdom2.Element in project JMRI by JMRI.

the class ConnectionConfigXml method makeParameter.

protected Element makeParameter(String name, String value) {
    Element p = new Element("parameter");
    p.setAttribute("name", name);
    p.addContent(value);
    return p;
}
Also used : Element(org.jdom2.Element)

Example 100 with Element

use of org.jdom2.Element in project JMRI by JMRI.

the class ConnectionConfigXml method extendElement.

/**
     * Write out the SerialNode objects too
     *
     * @param e Element being extended
     */
@Override
protected void extendElement(Element e) {
    SerialNode node = (SerialNode) SerialTrafficController.instance().getNode(0);
    int index = 1;
    while (node != null) {
        // add node as an element
        Element n = new Element("node");
        n.setAttribute("name", "" + node.getNodeAddress());
        e.addContent(n);
        // add parameters to the node as needed
        n.addContent(makeParameter("transmissiondelay", "" + InputBits.getTimeoutTime()));
        n.addContent(makeParameter("inputbits", "" + InputBits.getNumInputBits()));
        n.addContent(makeParameter("senddelay", "" + OutputBits.getSendDelay()));
        n.addContent(makeParameter("outputbits", "" + OutputBits.getNumOutputBits()));
        //            n.addContent(makeParameter("pulsewidth", ""+node.getPulseWidth()));
        // look for the next node
        node = (SerialNode) SerialTrafficController.instance().getNode(index);
        index++;
    }
}
Also used : SerialNode(jmri.jmrix.maple.SerialNode) Element(org.jdom2.Element)

Aggregations

Element (org.jdom2.Element)673 Attribute (org.jdom2.Attribute)103 Document (org.jdom2.Document)64 File (java.io.File)49 ArrayList (java.util.ArrayList)36 NamedIcon (jmri.jmrit.catalog.NamedIcon)28 IOException (java.io.IOException)27 DataConversionException (org.jdom2.DataConversionException)26 JDOMException (org.jdom2.JDOMException)26 XmlFile (jmri.jmrit.XmlFile)24 Test (org.junit.Test)24 Editor (jmri.jmrit.display.Editor)22 DocType (org.jdom2.DocType)21 Turnout (jmri.Turnout)20 ProcessingInstruction (org.jdom2.ProcessingInstruction)16 Point (java.awt.Point)15 HashMap (java.util.HashMap)15 SignalHead (jmri.SignalHead)15 LayoutEditor (jmri.jmrit.display.layoutEditor.LayoutEditor)15 Dimension (java.awt.Dimension)14