Search in sources :

Example 86 with Element

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

the class WiThrottlePreferences method store.

@Override
public Element store() {
    if (this.isDirty()) {
        this.isRestartRequired = true;
    }
    Element element = new Element("WiThrottlePreferences");
    element.setAttribute("isUseEStop", "" + isUseEStop());
    this.asLoadedUseEStop = this.isUseEStop();
    element.setAttribute("getEStopDelay", "" + getEStopDelay());
    this.asLoadedEStopDelay = this.getEStopDelay();
    element.setAttribute("isUseMomF2", "" + isUseMomF2());
    this.asLoadedUseMomF2 = this.isUseMomF2();
    element.setAttribute("getPort", "" + getPort());
    this.asLoadedPort = this.getPort();
    element.setAttribute("isAllowTrackPower", "" + isAllowTrackPower());
    this.asLoadedAllowTrackPower = this.isAllowTrackPower();
    element.setAttribute("isAllowTurnout", "" + isAllowTurnout());
    this.asLoadedAllowTurnout = this.isAllowTurnout();
    element.setAttribute("isAllowRoute", "" + isAllowRoute());
    this.asLoadedAllowRoute = this.isAllowRoute();
    element.setAttribute("isAllowConsist", "" + isAllowConsist());
    this.asLoadedAllowConsist = this.isAllowConsist();
    element.setAttribute("isUseWiFiConsist", "" + isUseWiFiConsist());
    this.asLoadedUseWiFiConsist = this.isUseWiFiConsist();
    return element;
}
Also used : Element(org.jdom2.Element)

Example 87 with Element

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

the class AbstractConnectionConfigXml method saveOptions.

protected void saveOptions(Element e, PortAdapter adapter) {
    Element element = new Element("options");
    String[] options = adapter.getOptions();
    for (String i : options) {
        Element elem = new Element("option");
        elem.addContent(new Element("name").addContent(i));
        elem.addContent(new Element("value").addContent(adapter.getOptionState(i)));
        element.addContent(elem);
    }
    e.addContent(element);
}
Also used : Element(org.jdom2.Element)

Example 88 with Element

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

the class AbstractSerialConnectionConfigXml method store.

/**
     * Default implementation for storing the static contents of the serial port
     * implementation
     *
     * @param object Object to store, of type AbstractSerialConnectionConfig
     * @return Element containing the complete info
     */
@Override
public Element store(Object object) {
    getInstance(object);
    Element e = new Element("connection");
    if (adapter == null) {
        log.warn("No adapter found while saving serial port configuration {}", object.toString());
        return null;
    }
    // many of the following are required by the DTD; failing to include
    // them makes the XML file unreadable, but at least the next
    // invocation of the program can then continue.
    storeCommon(e, adapter);
    if (adapter.getCurrentPortName() != null) {
        e.setAttribute("port", adapter.getCurrentPortName());
    } else {
        e.setAttribute("port", rb.getString("noneSelected"));
    }
    if (adapter.getCurrentBaudRate() != null) {
        e.setAttribute("speed", adapter.getCurrentBaudRate());
    } else {
        e.setAttribute("speed", rb.getString("noneSelected"));
    }
    e.setAttribute("class", this.getClass().getName());
    extendElement(e);
    return e;
}
Also used : Element(org.jdom2.Element)

Example 89 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 90 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) {
    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)

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