Search in sources :

Example 66 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 67 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 68 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)

Example 69 with RosterEntry

use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.

the class RosterTreeNode method initComponents.

/**
     * Initialize the connection to the Roster.
     * <p>
     * Should be called before connecting the node to a JTree.
     */
public void initComponents() {
    // title this node
    setUserObject("Roster");
    // add every roster entry
    List<RosterEntry> list = Roster.getDefault().matchingList(null, null, null, null, null, null, null);
    for (RosterEntry r : list) {
        add(new DefaultMutableTreeNode(r.getId()));
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) RosterEntry(jmri.jmrit.roster.RosterEntry)

Example 70 with RosterEntry

use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.

the class AttributeTableModel method getValueAt.

/**
     * Provides the empty String if attribute doesn't exist.
     */
@Override
public Object getValueAt(int row, int col) {
    // get column key
    String key = getColumnName(col);
    // get roster entry for row
    RosterEntry re = Roster.getDefault().getEntry(row);
    String retval = re.getAttribute(key);
    if (retval != null) {
        return retval;
    }
    return "";
}
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