Search in sources :

Example 6 with IndexedCvTableModel

use of jmri.jmrit.symbolicprog.IndexedCvTableModel in project JMRI by JMRI.

the class PaneProgPaneTest method testColumn.

// test creating columns in a pane
@Test
public void testColumn() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    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);
    log.debug("CvTableModel ctor complete");
    String[] args = { "CV", "Name" };
    VariableTableModel varModel = new VariableTableModel(null, args, cvModel, icvModel);
    log.debug("VariableTableModel ctor complete");
    // create test object with special implementation of the newColumn(String) operation
    colCount = 0;
    PaneProgPane pane = new PaneProgPane(pFrame, "name", pane1, cvModel, icvModel, varModel, null, null) {

        @Override
        public JPanel newColumn(Element e, boolean a, Element el) {
            colCount++;
            return new JPanel();
        }
    };
    assertNotNull("exists", pane);
    assertEquals("column count", 2, colCount);
}
Also used : IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel) CvTableModel(jmri.jmrit.symbolicprog.CvTableModel) VariableTableModel(jmri.jmrit.symbolicprog.VariableTableModel) JPanel(javax.swing.JPanel) Element(org.jdom2.Element) JLabel(javax.swing.JLabel) RosterEntry(jmri.jmrit.roster.RosterEntry) IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel) Test(org.junit.Test)

Example 7 with IndexedCvTableModel

use of jmri.jmrit.symbolicprog.IndexedCvTableModel in project JMRI by JMRI.

the class VSDConfigDialog method storeFile.

/**
     * Write roster settings to the Roster file
     */
protected boolean storeFile(RosterEntry _rosterEntry) {
    log.debug("storeFile starts");
    // We need to create a programmer, a cvTableModel, an iCvTableModel, and a variableTableModel.
    // Doesn't matter which, so we'll use the Global programmer.
    Programmer p = InstanceManager.getDefault(jmri.ProgrammerManager.class).getGlobalProgrammer();
    CvTableModel cvModel = new CvTableModel(null, p);
    IndexedCvTableModel iCvModel = new IndexedCvTableModel(null, p);
    VariableTableModel variableModel = new VariableTableModel(null, new String[] { "Name", "Value" }, cvModel, iCvModel);
    // Now, in theory we can call _rosterEntry.writeFile...
    if (_rosterEntry.getFileName() != null) {
        // set the loco file name in the roster entry
        // read, but don't yet process
        _rosterEntry.readFile();
        _rosterEntry.loadCvModel(variableModel, cvModel, iCvModel);
    }
    // id has to be set!
    if (_rosterEntry.getId().equals("")) {
        log.debug("storeFile without a filename; issued dialog");
        return false;
    }
    // if there isn't a filename, store using the id
    _rosterEntry.ensureFilenameExists();
    // create the RosterEntry to its file
    // where to get the models???
    _rosterEntry.writeFile(cvModel, iCvModel, variableModel);
    // mark this as a success
    variableModel.setFileDirty(false);
    // and store an updated roster file
    Roster.getDefault().writeRoster();
    return true;
}
Also used : CvTableModel(jmri.jmrit.symbolicprog.CvTableModel) IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel) VariableTableModel(jmri.jmrit.symbolicprog.VariableTableModel) Programmer(jmri.Programmer) IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel)

Example 8 with IndexedCvTableModel

use of jmri.jmrit.symbolicprog.IndexedCvTableModel in project JMRI by JMRI.

the class DecoderFileTest method testMinFn.

public void testMinFn() {
    setupDecoder();
    // this test should probably be done in terms of a test class instead of the real one...
    JLabel progStatus = new JLabel(" OK ");
    CvTableModel cvModel = new CvTableModel(progStatus, p);
    IndexedCvTableModel icvModel = new IndexedCvTableModel(new JLabel(), p);
    VariableTableModel variableModel = new VariableTableModel(progStatus, new String[] { "Name", "Value" }, cvModel, icvModel);
    DecoderFile d = new DecoderFile("mfg", "mfgID", "model", "23", "24", "family", "filename", 3, 16, null);
    d.loadVariableModel(decoder, variableModel);
    Assert.assertEquals("read rows ", 2, variableModel.getRowCount());
}
Also used : IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel) CvTableModel(jmri.jmrit.symbolicprog.CvTableModel) VariableTableModel(jmri.jmrit.symbolicprog.VariableTableModel) JLabel(javax.swing.JLabel) IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel)

Example 9 with IndexedCvTableModel

use of jmri.jmrit.symbolicprog.IndexedCvTableModel in project JMRI by JMRI.

the class DecoderFileTest method testLoadTable.

public void testLoadTable() {
    setupDecoder();
    // this test should probably be done in terms of a test class instead of the real one...
    JLabel progStatus = new JLabel(" OK ");
    CvTableModel cvModel = new CvTableModel(progStatus, p);
    IndexedCvTableModel icvModel = new IndexedCvTableModel(new JLabel(), p);
    VariableTableModel variableModel = new VariableTableModel(progStatus, new String[] { "Name", "Value" }, cvModel, icvModel);
    DecoderFile d = new DecoderFile("mfg", "mfgID", "model", "23", "24", "family", "filename", 16, 16, null);
    d.loadVariableModel(decoder, variableModel);
    Assert.assertEquals("read rows ", 3, variableModel.getRowCount());
    Assert.assertEquals("first row name ", "Address", variableModel.getLabel(0));
    Assert.assertEquals("third row name ", "Normal direction of motion", variableModel.getLabel(2));
}
Also used : IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel) CvTableModel(jmri.jmrit.symbolicprog.CvTableModel) VariableTableModel(jmri.jmrit.symbolicprog.VariableTableModel) JLabel(javax.swing.JLabel) IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel)

Example 10 with IndexedCvTableModel

use of jmri.jmrit.symbolicprog.IndexedCvTableModel in project JMRI by JMRI.

the class VSDConfigPanel method storeFile.

protected boolean storeFile(RosterEntry _rosterEntry) {
    log.debug("storeFile starts");
    // We need to create a programmer, a cvTableModel, an iCvTableModel, and a variableTableModel.
    // Doesn't matter which, so we'll use the Global programmer.
    Programmer p = InstanceManager.getDefault(jmri.ProgrammerManager.class).getGlobalProgrammer();
    CvTableModel cvModel = new CvTableModel(null, p);
    IndexedCvTableModel iCvModel = new IndexedCvTableModel(null, p);
    VariableTableModel variableModel = new VariableTableModel(null, new String[] { "Name", "Value" }, cvModel, iCvModel);
    // Now, in theory we can call _rosterEntry.writeFile...
    if (_rosterEntry.getFileName() != null) {
        // set the loco file name in the roster entry
        // read, but don't yet process
        _rosterEntry.readFile();
        _rosterEntry.loadCvModel(variableModel, cvModel, iCvModel);
    }
    // id has to be set!
    if (_rosterEntry.getId().equals("")) {
        log.debug("storeFile without a filename; issued dialog");
        return false;
    }
    // if there isn't a filename, store using the id
    _rosterEntry.ensureFilenameExists();
    // create the RosterEntry to its file
    // where to get the models???
    _rosterEntry.writeFile(cvModel, iCvModel, variableModel);
    // mark this as a success
    variableModel.setFileDirty(false);
    // and store an updated roster file
    Roster.getDefault().writeRoster();
    return true;
}
Also used : IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel) CvTableModel(jmri.jmrit.symbolicprog.CvTableModel) VariableTableModel(jmri.jmrit.symbolicprog.VariableTableModel) Programmer(jmri.Programmer) IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel)

Aggregations

CvTableModel (jmri.jmrit.symbolicprog.CvTableModel)13 IndexedCvTableModel (jmri.jmrit.symbolicprog.IndexedCvTableModel)13 VariableTableModel (jmri.jmrit.symbolicprog.VariableTableModel)13 JLabel (javax.swing.JLabel)10 RosterEntry (jmri.jmrit.roster.RosterEntry)6 Element (org.jdom2.Element)6 Test (org.junit.Test)6 JPanel (javax.swing.JPanel)2 Programmer (jmri.Programmer)2 BorderLayout (java.awt.BorderLayout)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 JButton (javax.swing.JButton)1 JComponent (javax.swing.JComponent)1 TitledBorder (javax.swing.border.TitledBorder)1 jmri (jmri)1 XmlFile (jmri.jmrit.XmlFile)1 ResetTableModel (jmri.jmrit.symbolicprog.ResetTableModel)1