Search in sources :

Example 36 with Element

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

the class QualifiedVarTest method setupDoc.

// provide a test document in the above static variables
void setupDoc() {
    // create a JDOM tree with just some elements
    root = new Element("programmer-config");
    doc = new Document(root);
    doc.setDocType(new DocType("programmer-config", "programmer-config.dtd"));
    // add some elements
    root.addContent(new Element("programmer").setAttribute("showFnLanelPane", "no").setAttribute("showRosterMediaPane", "no").addContent(new Element("pane").setAttribute("name", "Test").addContent(new Element("column").addContent(new Element("display").setAttribute("item", "Primary Address")).addContent(new Element("display").setAttribute("item", "CV2")).addContent(new Element("display").setAttribute("item", "CV3")).addContent(new Element("display").setAttribute("item", "CV4")).addContent(new Element("display").setAttribute("item", "CV5")).addContent(new Element("display").setAttribute("item", "CV6")).addContent(new Element("separator")).addContent(new Element("label").setAttribute("label", "set cv3 >= 100 to see CV4")).addContent(new Element("label").setAttribute("label", "set cv3 <=100 to see CV5, CV6"))).addContent(new Element("column").addContent(new Element("display").setAttribute("item", "Minor Version Number")).addContent(new Element("display").setAttribute("item", "Major Version Number")).addContent(new Element("display").setAttribute("item", "iCV53.5.0")).addContent(new Element("display").setAttribute("item", "iCV55.92.0")).addContent(new Element("display").setAttribute("item", "iCV55.92.1")).addContent(new Element("separator")).addContent(new Element("label").setAttribute("label", "set cv3 >= 100 to see iCV53.5.0")).addContent(new Element("label").setAttribute("label", "set minor >= 100 to see iCV55.92.0")).addContent(new Element("label").setAttribute("label", "set minor, major >= 100 to see iCV55.92.1")))).addContent(new Element("pane").setAttribute("name", "CV").addContent(new Element("column").addContent(new Element("cvtable")))).addContent(new Element("pane").setAttribute("name", "iCV").addContent(new Element("column").addContent(new Element("indxcvtable")))).addContent(new Element("pane").setAttribute("name", "CV3>50").addContent(new Element("qualifier").addContent(new Element("variableref").addContent("CV3")).addContent(new Element("relation").addContent("gt")).addContent(new Element("value").addContent("50"))).addContent(new Element("column").addContent(new Element("display").setAttribute("item", "CV3")).addContent(new Element("display").setAttribute("item", "CV4")).addContent(new Element("label").setAttribute("label", "Pane visible with CV3>100")))));
    return;
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) DocType(org.jdom2.DocType)

Example 37 with Element

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

the class FnMapPanelTest method testCtor.

public void testCtor() {
    ProgDebugger p = new ProgDebugger();
    VariableTableModel tableModel = new VariableTableModel(new JLabel(""), new String[] { "Name", "Value" }, new CvTableModel(new JLabel(""), p), new IndexedCvTableModel(new JLabel(""), p));
    List<Integer> varsUsed = null;
    Element model = new Element("model");
    new FnMapPanel(tableModel, varsUsed, model);
}
Also used : ProgDebugger(jmri.progdebugger.ProgDebugger) Element(org.jdom2.Element) JLabel(javax.swing.JLabel)

Example 38 with Element

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

the class QualifierAdderTest method setUp.

// The minimal setup for log4J
@Override
protected 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)

Example 39 with Element

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

the class QualifierAdderTest method testExistsOk1.

public void testExistsOk1() {
    Element e = new Element("variable").addContent(new Element("qualifier").addContent(new Element("variableref").addContent("one")).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)));
    // print JDOM tree, to check
    //org.jdom2.output.XMLOutputter fmt 
    //    = new org.jdom2.output.XMLOutputter(org.jdom2.output.Format.getPrettyFormat());
    //try {
    //	 fmt.output(doc, System.out);
    //} catch (Exception ex) { log.error("error writing XML", ex);}
    // test Exists
    processModifierElements(e, v2);
    Assert.assertTrue(v2.getAvailable());
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) DocType(org.jdom2.DocType)

Example 40 with Element

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

the class PaneProgPaneTest method testPaneRead.

// test storage of programming info in list
@Test
public void testPaneRead() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    log.debug("testPaneRead starts");
    // initialize the system
    // make sure XML document is ready
    setupDoc();
    PaneProgFrame pFrame = new PaneProgFrame(null, new RosterEntry(), "test frame", "programmers/Basic.xml", p, false) {

        // dummy implementations
        @Override
        protected JPanel getModePane() {
            return null;
        }
    };
    CvTableModel cvModel = new CvTableModel(new JLabel(), p);
    IndexedCvTableModel icvModel = new IndexedCvTableModel(new JLabel(), p);
    String[] args = { "CV", "Name" };
    VariableTableModel varModel = new VariableTableModel(null, args, cvModel, icvModel);
    log.debug("VariableTableModel ctor complete");
    // have to add a couple of defined variables
    Element el0 = new Element("variable").setAttribute("CV", "2").setAttribute("readOnly", "no").setAttribute("mask", "VVVVVVVV").setAttribute("label", "Start voltage").addContent(new Element("decVal"));
    Element el1 = new Element("variable").setAttribute("CV", "3").setAttribute("readOnly", "no").setAttribute("mask", "VVVVVVVV").setAttribute("label", "Primary Address").addContent(new Element("decVal"));
    varModel.setRow(0, el0);
    varModel.setRow(1, el1);
    PaneProgPane progPane = new PaneProgPane(pFrame, "name", pane1, cvModel, icvModel, varModel, null, null);
    p.resetCv(2, 20);
    p.resetCv(3, 30);
    // test by invoking
    progPane.readAllButton.setSelected(true);
    // wait for reply (normally, done by callback; will check that later)
    JUnitUtil.waitFor(() -> {
        return !progPane.isBusy();
    }, "progPane.isBusy");
    Assert.assertEquals("CV 2 value ", "20", varModel.getValString(0));
    Assert.assertEquals("CV 3 value ", "30", varModel.getValString(1));
    log.debug("testPaneRead ends ok");
}
Also used : IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel) CvTableModel(jmri.jmrit.symbolicprog.CvTableModel) VariableTableModel(jmri.jmrit.symbolicprog.VariableTableModel) Element(org.jdom2.Element) JLabel(javax.swing.JLabel) RosterEntry(jmri.jmrit.roster.RosterEntry) IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel) Test(org.junit.Test)

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