001package jmri.jmrit.roster.swing.rostertree;
002
003import java.util.List;
004import javax.swing.tree.DefaultMutableTreeNode;
005import jmri.jmrit.roster.Roster;
006import jmri.jmrit.roster.RosterEntry;
007
008/**
009 * Create a TreeNode representing the entire Roster.
010 *
011 *
012 * @author Bob Jacobsen Copyright (C) 2010
013 */
014public class RosterTreeNode extends DefaultMutableTreeNode {
015
016    public RosterTreeNode() {
017        super();
018    }
019
020    /**
021     * Initialize the connection to the Roster.
022     * <p>
023     * Should be called before connecting the node to a JTree.
024     */
025    public void initComponents() {
026
027        // title this node
028        setUserObject("Roster");
029
030        // add every roster entry
031        List<RosterEntry> list = Roster.getDefault().matchingList(null, null, null, null, null, null, null);
032
033        for (RosterEntry r : list) {
034            add(new DefaultMutableTreeNode(r.getId()));
035        }
036    }
037}