Search in sources :

Example 91 with Element

use of com.zhan_dui.utils.m3u8.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 92 with Element

use of com.zhan_dui.utils.m3u8.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 93 with Element

use of com.zhan_dui.utils.m3u8.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)

Example 94 with Element

use of com.zhan_dui.utils.m3u8.Element in project JMRI by JMRI.

the class ConnectionConfigXml method unpackElement.

@Override
protected void unpackElement(Element shared, Element perNode) {
    List<Element> l = shared.getChildren("node");
    for (int i = 0; i < l.size(); i++) {
        Element n = l.get(i);
        int addr = Integer.parseInt(n.getAttributeValue("name"));
        int type = Integer.parseInt(findParmValue(n, "nodetype"));
        // create node (they register themselves)
        SerialNode node = new SerialNode(addr, type);
        // Trigger initialization of this Node to reflect these parameters
        SerialTrafficController.instance().initializeSerialNode(node);
    }
}
Also used : SerialNode(jmri.jmrix.oaktree.SerialNode) Element(org.jdom2.Element)

Example 95 with Element

use of com.zhan_dui.utils.m3u8.Element in project JMRI by JMRI.

the class PerformActionModelXml method load.

@Override
public boolean load(Element shared, Element perNode) throws Exception {
    boolean result = true;
    String className = shared.getAttribute("name").getValue();
    PerformActionModel model = new PerformActionModel();
    Exception exception = null;
    model.setClassName(className);
    for (Element child : shared.getChildren("property")) {
        // NOI18N
        if (// NOI18N
        child.getAttributeValue("name").equals("systemPrefix") && child.getAttributeValue("value") != null) {
            // NOI18N
            // NOI18N
            model.setSystemPrefix(child.getAttributeValue("value"));
        }
    }
    InstanceManager.getDefault(StartupActionsManager.class).addAction(model);
    if (exception != null) {
        throw exception;
    }
    return result;
}
Also used : PerformActionModel(apps.PerformActionModel) Element(org.jdom2.Element) StartupActionsManager(apps.StartupActionsManager)

Aggregations

Element (org.jdom2.Element)673 Attribute (org.jdom2.Attribute)73 Document (org.jdom2.Document)58 File (java.io.File)49 ArrayList (java.util.ArrayList)36 NamedIcon (jmri.jmrit.catalog.NamedIcon)27 IOException (java.io.IOException)26 JDOMException (org.jdom2.JDOMException)26 XmlFile (jmri.jmrit.XmlFile)24 Test (org.junit.Test)24 Turnout (jmri.Turnout)20 DataConversionException (org.jdom2.DataConversionException)20 DocType (org.jdom2.DocType)19 Editor (jmri.jmrit.display.Editor)18 Point (java.awt.Point)15 HashMap (java.util.HashMap)15 Dimension (java.awt.Dimension)14 FileNotFoundException (java.io.FileNotFoundException)13 SignalHead (jmri.SignalHead)13 List (java.util.List)12