001package apps.gui3.paned;
002
003import javax.swing.tree.DefaultMutableTreeNode;
004import javax.swing.tree.TreeNode;
005import jmri.jmrix.loconet.LocoNetSystemConnectionMemo;
006import jmri.util.swing.JTreeUtil;
007import jmri.util.swing.multipane.MultiPaneWindow;
008import jmri.util.swing.multipane.PanedInterface;
009import org.slf4j.Logger;
010import org.slf4j.LoggerFactory;
011
012/**
013 * Standalone, but paned, PanelPro window. Note: This is test code!
014 *
015 * Ignores WindowInterface, since standalone.
016 *
017 * @author Bob Jacobsen Copyright (C) 2010
018 */
019public class PanelProFrame extends MultiPaneWindow {
020
021    /**
022     * Enhanced constructor for placing the pane in various GUIs
023     *
024     * @param title The title of the Window
025     */
026    public PanelProFrame(String title) {
027        super(title, "xml/config/apps/panelpro/Gui3LeftTree.xml",
028                "xml/config/apps/panelpro/Gui3Menus.xml",
029                "xml/config/apps/panelpro/Gui3MainToolBar.xml");
030    }
031
032    /**
033     * Make a PanelPro tree, and add the LocoNet stuff, because we assume those
034     * systems active here
035     */
036    @Override
037    protected TreeNode makeNavTreeTopNode(String treeFile, PanedInterface rightTopWI) {
038        DefaultMutableTreeNode top = JTreeUtil.loadTree(treeFile, rightTopWI, null);  // no context
039
040        // as a test, we manually create a loconet tree
041        log.info("Manually attempting to create two LocoNet trees for testing purposes");
042
043        LocoNetSystemConnectionMemo lm1 = jmri.InstanceManager.getList(LocoNetSystemConnectionMemo.class).get(0);
044        if (lm1 != null) {
045            DefaultMutableTreeNode l1 = JTreeUtil.loadTree("xml/config/parts/jmri/jmrix/loconet/ToolsTree.xml", rightTopWI, lm1);
046            l1.setUserObject("LocoNet");
047            top.add(l1);
048        }
049        LocoNetSystemConnectionMemo lm2 = jmri.InstanceManager.getList(LocoNetSystemConnectionMemo.class).get(1);
050        if (lm2 != null) {
051            DefaultMutableTreeNode l2 = JTreeUtil.loadTree("xml/config/parts/jmri/jmrix/loconet/ToolsTree.xml", rightTopWI, lm2);
052            l2.setUserObject("LocoNet2");
053            top.add(l2);
054        }
055
056        return top;
057    }
058
059    private final static Logger log = LoggerFactory.getLogger(PanelProFrame.class);
060}