Search in sources :

Example 46 with RosterEntry

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;
}
Also used : RosterEntry(jmri.jmrit.roster.RosterEntry) TrainCommon.splitString(jmri.jmrit.operations.trains.TrainCommon.splitString) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 47 with RosterEntry

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;
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) TrainIcon(jmri.jmrit.operations.trains.TrainIcon) Element(org.jdom2.Element) RosterEntry(jmri.jmrit.roster.RosterEntry)

Example 48 with RosterEntry

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;
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) LocoIcon(jmri.jmrit.display.LocoIcon) Element(org.jdom2.Element) RosterEntry(jmri.jmrit.roster.RosterEntry)

Example 49 with RosterEntry

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);
}
Also used : RosterEntry(jmri.jmrit.roster.RosterEntry)

Example 50 with RosterEntry

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();
}
Also used : RosterEntry(jmri.jmrit.roster.RosterEntry)

Aggregations

RosterEntry (jmri.jmrit.roster.RosterEntry)77 DecoderFile (jmri.jmrit.decoderdefn.DecoderFile)12 JPanel (javax.swing.JPanel)11 Element (org.jdom2.Element)11 JFrame (javax.swing.JFrame)9 BoxLayout (javax.swing.BoxLayout)8 JLabel (javax.swing.JLabel)8 Test (org.junit.Test)7 ActionEvent (java.awt.event.ActionEvent)6 ActionListener (java.awt.event.ActionListener)6 JMenuBar (javax.swing.JMenuBar)6 CvTableModel (jmri.jmrit.symbolicprog.CvTableModel)6 IndexedCvTableModel (jmri.jmrit.symbolicprog.IndexedCvTableModel)6 VariableTableModel (jmri.jmrit.symbolicprog.VariableTableModel)6 ArrayList (java.util.ArrayList)5 JmriJFrame (jmri.util.JmriJFrame)5 File (java.io.File)4 JButton (javax.swing.JButton)3 JMenu (javax.swing.JMenu)3 NamedIcon (jmri.jmrit.catalog.NamedIcon)3