use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class EcosLocoToRoster method ecosLocoToRoster.
//Same Name as the constructor need to sort it out!
public void ecosLocoToRoster(String ecosObject) {
frame = new JFrame();
_ecosObject = ecosObject;
_ecosObjectInt = Integer.parseInt(_ecosObject);
ecosManager = adaptermemo.getLocoAddressManager();
ecosLoco = ecosManager.getByEcosObject(ecosObject);
String rosterId = ecosLoco.getEcosDescription();
if (checkDuplicate(rosterId)) {
int count = 0;
String oldrosterId = rosterId;
while (checkDuplicate(rosterId)) {
rosterId = oldrosterId + "_" + count;
count++;
}
}
re = new RosterEntry();
re.setId(rosterId);
List<DecoderFile> decoder = decoderind.matchingDecoderList(null, null, ecosLoco.getCVAsString(8), ecosLoco.getCVAsString(7), null, null);
if (decoder.size() == 1) {
pDecoderFile = decoder.get(0);
SelectedDecoder(pDecoderFile);
} else {
class WindowMaker implements Runnable {
WindowMaker() {
}
@Override
public void run() {
comboPanel();
}
}
WindowMaker t = new WindowMaker();
javax.swing.SwingUtilities.invokeLater(t);
}
}
use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class NceConsistEditPanel method rosterBoxSelect.
// load a loco from roster
private void rosterBoxSelect(JComboBox<Object> locoRosterBox, JTextField locoTextField, JButton adrButton) {
RosterEntry entry = null;
Object o = locoRosterBox.getSelectedItem();
if (o.getClass().equals(RosterEntry.class)) {
entry = (RosterEntry) o;
}
if (entry != null) {
DccLocoAddress a = entry.getDccLocoAddress();
locoTextField.setText("" + a.getNumber());
if (a.isLongAddress()) {
adrButton.setText(rb.getString("KeyLONG"));
} else {
adrButton.setText(rb.getString("KeySHORT"));
}
// if lead loco get road number and name
if (locoRosterBox == locoRosterBox1) {
textConRoadName.setText(entry.getRoadName());
textConRoadNumber.setText(entry.getRoadNumber());
textConModel.setText(entry.getModel());
}
}
}
use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class AbstractMemoryManagerConfigXML method loadValue.
void loadValue(Element memory, Memory m) {
String value = memory.getAttribute("value").getValue();
if (memory.getAttribute("valueClass") != null) {
String adapter = memory.getAttribute("valueClass").getValue();
if (adapter.equals("jmri.jmrit.roster.RosterEntry")) {
RosterEntry re = jmri.jmrit.roster.Roster.getDefault().getEntryForId(value);
m.setValue(re);
return;
}
}
m.setValue(value);
}
use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class AbstractMemoryManagerConfigXML method store.
/**
* Default implementation for storing the contents of a MemoryManager
*
* @param o Object to store, of type MemoryManager
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
Element memories = new Element("memories");
setStoreElementClass(memories);
MemoryManager tm = (MemoryManager) o;
if (tm != null) {
java.util.Iterator<String> iter = tm.getSystemNameList().iterator();
// don't return an element if there are not memories to include
if (!iter.hasNext()) {
return null;
}
// store the memories
while (iter.hasNext()) {
String sname = iter.next();
if (sname == null) {
log.error("System name null during store");
break;
}
log.debug("system name is " + sname);
Memory m = tm.getBySystemName(sname);
Element elem = new Element("memory");
elem.addContent(new Element("systemName").addContent(sname));
// store common part
storeCommon(m, elem);
// store value if non-null; null values omitted
Object obj = m.getValue();
if (obj != null) {
if (obj instanceof jmri.jmrit.roster.RosterEntry) {
String valueClass = obj.getClass().getName();
String value = ((RosterEntry) obj).getId();
elem.setAttribute("value", value);
elem.setAttribute("valueClass", valueClass);
} else {
String value = obj.toString();
elem.setAttribute("value", value);
}
}
log.debug("store Memory " + sname);
memories.addContent(elem);
}
}
return memories;
}
use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class LocoIconXml method store.
/**
* Default implementation for storing the contents of a LocoIcon
*
* @param o Object to store, of type LocoIcon
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
LocoIcon p = (LocoIcon) o;
if (!p.isActive()) {
// if flagged as inactive, don't store
return null;
}
Element element = new Element("locoicon");
storeCommonAttributes(p, element);
// include contents
if (p.getUnRotatedText() != null) {
element.setAttribute("text", p.getUnRotatedText());
}
storeTextInfo(p, element);
element.setAttribute("icon", "yes");
element.setAttribute("dockX", "" + p.getDockX());
element.setAttribute("dockY", "" + p.getDockY());
element.addContent(storeIcon("icon", (NamedIcon) p.getIcon()));
RosterEntry entry = p.getRosterEntry();
if (entry != null) {
element.setAttribute("rosterentry", entry.getId());
}
element.setAttribute("class", "jmri.jmrit.display.configurexml.LocoIconXml");
return element;
}
Aggregations