Search in sources :

Example 51 with Element

use of org.eclipse.xtext.parsetree.impl.bug305397.Element in project JMRI by JMRI.

the class QualifierAdderTest method testNotExistsOk1.

public void testNotExistsOk1() {
    Element e = new Element("variable").addContent(new Element("qualifier").addContent(new Element("variableref").addContent("none")).addContent(new Element("relation").addContent("exists")).addContent(new Element("value").addContent("1")));
    // create a JDOM tree with just some elements
    Element root = new Element("decoder-config");
    Document doc = new Document(root);
    doc.setDocType(new DocType("decoder-config", "decoder-config.dtd"));
    root.addContent(// the sites information here lists all relevant
    new Element("decoder").addContent(new Element("variables").addContent(e)));
    // test Exists
    processModifierElements(e, v2);
    Assert.assertFalse(v2.getAvailable());
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) DocType(org.jdom2.DocType)

Example 52 with Element

use of org.eclipse.xtext.parsetree.impl.bug305397.Element in project JMRI by JMRI.

the class QualifierCombinerTest method setUp.

// The minimal setup for log4J
@Before
public void setUp() {
    apps.tests.Log4JFixture.setUp();
    p = new ProgDebugger();
    cvtable = new CvTableModel(new JLabel(""), p);
    model = new VariableTableModel(new JLabel(""), new String[] { "Name", "Value" }, cvtable, new IndexedCvTableModel(new JLabel(""), p));
    // create a JDOM tree with just some elements
    Element root = new Element("decoder-config");
    Document doc = new Document(root);
    doc.setDocType(new DocType("decoder-config", "decoder-config.dtd"));
    // add some elements
    Element el1, el2, el3;
    root.addContent(// the sites information here lists all relevant
    new Element("decoder").addContent(new Element("variables").addContent(el1 = new Element("variable").setAttribute("CV", "1").setAttribute("item", "one").addContent(new Element("decVal").setAttribute("max", "31").setAttribute("min", "1"))).addContent(el2 = new Element("variable").setAttribute("CV", "2").setAttribute("item", "two").addContent(new Element("decVal").setAttribute("max", "31").setAttribute("min", "1"))).addContent(el3 = new Element("variable").setAttribute("CV", "3").setAttribute("item", "three").addContent(new Element("decVal").setAttribute("max", "31").setAttribute("min", "1")))));
    // end of adding contents
    // and test reading this
    model.setRow(0, el1);
    model.setRow(1, el2);
    model.setRow(1, el3);
    v1 = model.findVar("one");
    v2 = model.findVar("two");
    v3 = model.findVar("three");
}
Also used : ProgDebugger(jmri.progdebugger.ProgDebugger) Element(org.jdom2.Element) JLabel(javax.swing.JLabel) Document(org.jdom2.Document) DocType(org.jdom2.DocType) Before(org.junit.Before)

Example 53 with Element

use of org.eclipse.xtext.parsetree.impl.bug305397.Element in project JMRI by JMRI.

the class CdiPanelDemo method getRootFromFile.

Element getRootFromFile(String name) {
    Element root = null;
    try {
        // argument controls validation
        SAXBuilder builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser", false);
        Document doc = builder.build(new BufferedInputStream(new FileInputStream(new File(name))));
        root = doc.getRootElement();
    } catch (Exception e) {
        System.out.println("While reading file: " + e);
    }
    return root;
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) BufferedInputStream(java.io.BufferedInputStream) Element(org.jdom2.Element) Document(org.jdom2.Document) DemoReadWriteAccess.demoRepFromFile(org.openlcb.cdi.impl.DemoReadWriteAccess.demoRepFromFile) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 54 with Element

use of org.eclipse.xtext.parsetree.impl.bug305397.Element in project JMRI by JMRI.

the class SampleFactory method getBasicSample.

public static Element getBasicSample() {
    Element root = new Element("cdi");
    root.addContent(new Element("identification").addContent(new Element("manufacturer").addContent("OpenLCB Prototype")).addContent(new Element("model").addContent("Basic sketch")).addContent(new Element("hardwareVersion").addContent("Arduino (any)")).addContent(new Element("softwareVersion").addContent("0.4")).addContent(new Element("map").addContent(new Element("relation").addContent(new Element("property").addContent("size")).addContent(new Element("value").addContent("8 cm by 12 cm"))).addContent(new Element("relation").addContent(new Element("property").addContent("weight")).addContent(new Element("value").addContent("220g"))).addContent(new Element("relation").addContent(new Element("property").addContent("power")).addContent(new Element("value").addContent("12V at 100mA")))));
    root.addContent(new Element("segment").setAttribute("space", "0").setAttribute("origin", "0").addContent(new Element("name").addContent("Content")).addContent(new Element("description").addContent("Variables for controlling general operation")).addContent(new Element("group").addContent(new Element("name").addContent("Produced Events")).addContent(new Element("description").addContent("The EventIDs for the producers")).addContent(new Element("eventid")).addContent(new Element("eventid"))).addContent(new Element("group").addContent(new Element("name").addContent("Consumed Events")).addContent(new Element("description").addContent("The EventIDs for the consumers")).addContent(new Element("eventid")).addContent(new Element("eventid"))).addContent(new Element("int").setAttribute("size", "1").addContent(new Element("name").addContent("Regular bit variable")).addContent(new Element("description").addContent("Demonstrate how a standard bit (boolean) variable can be shown"))).addContent(new Element("int").setAttribute("size", "1").addContent(new Element("name").addContent("Bit variable with named states")).addContent(new Element("description").addContent("Demonstrate how a map relabels the states of a bit (boolean) variable")).addContent(new Element("map").addContent(new Element("relation").addContent(new Element("property").addContent("1")).addContent(new Element("value").addContent("Lit"))).addContent(new Element("relation").addContent(new Element("property").addContent("0")).addContent(new Element("value").addContent("Not Lit"))))));
    root.addContent(new Element("segment").setAttribute("space", "1").setAttribute("origin", "128").addContent(new Element("name").addContent("Resets")).addContent(new Element("description").addContent("Memory locations controlling resets")).addContent(new Element("int").setAttribute("size", "1").addContent(new Element("name").addContent("Reset")).addContent(new Element("description").addContent("Controls reloading and clearing node memory. Board must be restarted for this to take effect.")).addContent(new Element("map").addContent(new Element("relation").addContent(new Element("property").addContent("85")).addContent(new Element("value").addContent("(No reset)"))).addContent(new Element("relation").addContent(new Element("property").addContent("0")).addContent(new Element("value").addContent("Reset all to defaults"))).addContent(new Element("relation").addContent(new Element("property").addContent("170")).addContent(new Element("value").addContent("Reset just EventIDs to defaults"))))));
    root.addContent(new Element("segment").setAttribute("space", "3").setAttribute("origin", "0").addContent(new Element("name").addContent("Demos")).addContent(new Element("description").addContent("Demonstrations of various CDI capabilities")).addContent(new Element("group").setAttribute("replication", "2").addContent(new Element("name").addContent("Outer Group")).addContent(new Element("description").addContent("The contents of this group are replicated by 2")).addContent(new Element("group").setAttribute("replication", "3").addContent(new Element("name").addContent("Inner Group")).addContent(new Element("repname").addContent("Inner Label")).addContent(new Element("description").addContent("The contents of this group are replicated by 3")).addContent(new Element("int").setAttribute("size", "1").addContent(new Element("name").addContent("Int inside groups")).addContent(new Element("description").addContent("This is inside a 2x3 group"))))));
    return root;
}
Also used : Element(org.jdom2.Element)

Example 55 with Element

use of org.eclipse.xtext.parsetree.impl.bug305397.Element in project JMRI by JMRI.

the class SampleFactory method main.

// Main entry point for standalone run
public static void main(String[] args) {
    // dump a document to stdout
    Element root = getBasicSample();
    Document doc = new Document(root);
    try {
        org.jdom2.output.XMLOutputter fmt = new org.jdom2.output.XMLOutputter();
        fmt.setFormat(org.jdom2.output.Format.getPrettyFormat());
        fmt.output(doc, System.out);
    } catch (Exception e) {
        System.err.println("Exception writing file: " + e);
    }
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document)

Aggregations

Element (org.jdom2.Element)829 Attribute (org.jdom2.Attribute)76 Document (org.jdom2.Document)75 Test (org.junit.Test)70 File (java.io.File)53 ArrayList (java.util.ArrayList)45 JDOMException (org.jdom2.JDOMException)37 IOException (java.io.IOException)34 HashMap (java.util.HashMap)28 NamedIcon (jmri.jmrit.catalog.NamedIcon)27 List (java.util.List)26 XmlFile (jmri.jmrit.XmlFile)24 SAXBuilder (org.jdom2.input.SAXBuilder)21 Turnout (jmri.Turnout)20 DataConversionException (org.jdom2.DataConversionException)20 DocType (org.jdom2.DocType)19 Editor (jmri.jmrit.display.Editor)18 XMLOutputter (org.jdom2.output.XMLOutputter)18 Namespace (org.jdom2.Namespace)17 Point (java.awt.Point)15