use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class JsonUtil method getRoster.
/**
*
* @param locale The locale of the requesting client
* @param data A JsonNode optionally containing a group name in the
* "group" node
* @return the Roster as a Json Array
* @deprecated since 4.3.5
*/
@Deprecated
public static JsonNode getRoster(Locale locale, JsonNode data) {
String group = (!data.path(GROUP).isMissingNode()) ? data.path(GROUP).asText() : null;
if (Roster.ALLENTRIES.equals(group)) {
group = null;
}
String roadName = (!data.path(ROAD).isMissingNode()) ? data.path(ROAD).asText() : null;
String roadNumber = (!data.path(NUMBER).isMissingNode()) ? data.path(NUMBER).asText() : null;
String dccAddress = (!data.path(ADDRESS).isMissingNode()) ? data.path(ADDRESS).asText() : null;
String mfg = (!data.path(MFG).isMissingNode()) ? data.path(MFG).asText() : null;
String decoderModel = (!data.path(DECODER_MODEL).isMissingNode()) ? data.path(DECODER_MODEL).asText() : null;
String decoderFamily = (!data.path(DECODER_FAMILY).isMissingNode()) ? data.path(DECODER_FAMILY).asText() : null;
String id = (!data.path(NAME).isMissingNode()) ? data.path(NAME).asText() : null;
ArrayNode root = mapper.createArrayNode();
for (RosterEntry re : Roster.getDefault().getEntriesMatchingCriteria(roadName, roadNumber, dccAddress, mfg, decoderModel, decoderFamily, id, group)) {
root.add(getRosterEntry(locale, re.getId()));
}
return root;
}
use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class TrainIconXml method store.
/**
* Default implementation for storing the contents of a TrainIcon
*
* @param o Object to store, of type TrainIcon
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
TrainIcon p = (TrainIcon) o;
if (!p.isActive()) {
// if flagged as inactive, don't store
return null;
}
Element element = new Element(Xml.TRAINICON);
element.setAttribute(Xml.TRAIN, p.getTrain().getId());
element.setAttribute(Xml.TRAIN_NAME, p.getTrain().getName());
storeCommonAttributes(p, element);
// include contents
if (p.getUnRotatedText() != null) {
element.setAttribute(Xml.TEXT, p.getUnRotatedText());
}
storeTextInfo(p, element);
element.setAttribute(Xml.ICON, Xml.YES);
element.setAttribute(Xml.DOCK_X, "" + p.getDockX());
element.setAttribute(Xml.DOCK_Y, "" + p.getDockY());
// element.setAttribute("iconId", p.getIconId());
element.addContent(storeIcon(Xml.ICON, (NamedIcon) p.getIcon()));
RosterEntry entry = p.getRosterEntry();
if (entry != null) {
element.setAttribute(Xml.ROSTERENTRY, entry.getId());
}
element.setAttribute(Xml.CLASS, this.getClass().getName());
return element;
}
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;
}
use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class RosterGroup method setName.
/**
* Set the RosterGroup's name, changing it in every entry associated with
* the roster.
*
* @param newName the new name
*/
public void setName(String newName) {
if (Roster.getDefault().getRosterGroups().containsKey(newName)) {
return;
}
String oldName = this.name;
String oldGroup = Roster.getRosterGroupProperty(oldName);
String newGroup = Roster.getRosterGroupProperty(newName);
Roster.getDefault().remapRosterGroup(this, newName);
for (RosterEntry re : this.getEntries()) {
// NOI18N
re.putAttribute(newGroup, "yes");
re.deleteAttribute(oldGroup);
}
this.name = newName;
Roster.getDefault().rosterGroupRenamed(oldName, newName);
}
use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.
the class RosterGroupTableModel method setValueAt.
@Override
public void setValueAt(Object value, int row, int col) {
RosterEntry re = Roster.getDefault().getEntry(row);
if ((col == ADDTOGROUPCOL) && (!group.equals("RosterGroup:"))) {
if (value.toString().equals("true")) {
re.putAttribute(group, "yes");
} else {
re.deleteAttribute(group);
}
re.updateFile();
Roster.getDefault().writeRoster();
}
//re.updateFile();
//Roster.getDefault().writeRosterFile();
}
Aggregations