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);
}
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;
}
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());
}
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));
}
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;
}
Aggregations