001package jmri.jmrix.loconet.duplexgroup.swing;
002
003import java.awt.BorderLayout;
004
005import jmri.jmrix.loconet.LocoNetSystemConnectionMemo;
006import jmri.jmrix.loconet.swing.LnPanel;
007import jmri.util.JmriJFrame;
008
009/**
010 * Implements a panel with tabs which allows:
011 * <ul>
012 *     <li>configuration of Duplex Group identity information
013 *     <li>scanning of Duplex channels for interfering signal sources
014 * </ul>
015 * This tool works equally well with UR92 and UR92CE devices. The UR92 and
016 * UR92CE behave identically with respect to this tool. For the purpose of
017 * clarity, only the term UR92 is used herein.
018 *
019 * @author B. Milhaupt, Copyright 2011
020 */
021public class DuplexGroupTabbedPanel extends LnPanel {
022
023    javax.swing.JTabbedPane tabbedPane = null;
024    DuplexGroupInfoPanel dgip = null;
025    DuplexGroupScanPanel dgsp = null;
026    DuplexGroupTabbedPanel thisone = null;
027
028    public DuplexGroupTabbedPanel() {
029        super();
030        thisone = this;
031    }
032
033    /**
034     * {@inheritDoc}
035     */
036    @Override
037    public void initComponents() {
038        tabbedPane = new javax.swing.JTabbedPane();
039        setLayout(new BorderLayout());
040        dgsp = new DuplexGroupScanPanel();
041        dgip = new DuplexGroupInfoPanel();
042        tabbedPane.addTab(Bundle.getMessage("TabTextGroupIdentity"), null,
043                dgip, Bundle.getMessage("TabToolTipGroupIdentity"));
044        tabbedPane.addTab(Bundle.getMessage("TabTextChannelScan"), null,
045                dgsp, Bundle.getMessage("TabToolTipChannelScan"));
046        add(tabbedPane);
047        dgip.initComponents();
048        dgsp.initComponents();
049        // uses swing operations
050    }
051
052    /**
053     * {@inheritDoc}
054     */
055    @Override
056    public void initComponents(LocoNetSystemConnectionMemo memo) {
057        super.initComponents(memo);
058        dgip.initComponents(memo);
059        dgsp.initComponents(memo);
060    }
061    javax.swing.Timer tmr = null;
062
063    /**
064     * {@inheritDoc}
065     */
066    @Override
067    public void initContext(Object context) {
068
069        tmr = new javax.swing.Timer(10, new java.awt.event.ActionListener() {
070            @Override
071            public void actionPerformed(java.awt.event.ActionEvent e) {
072                tmr.stop();
073                java.awt.Container f = thisone.getRootPane().getParent();
074                if (f != null) {
075                    if (f instanceof JmriJFrame) {
076                        JmriJFrame jf = (JmriJFrame) f;
077                        jf.setPreferredSize(null);
078                        jf.pack();
079                    }
080                }
081            }
082        });
083        // need to trigger first delay to get first channel to be scanned
084        tmr.setInitialDelay(10);
085        tmr.setRepeats(false);
086        tmr.start();
087        return;
088    }
089
090    /**
091     * {@inheritDoc}
092     */
093    @Override
094    public String getHelpTarget() {
095        return "package.jmri.jmrix.loconet.duplexgroup.DuplexGroupTabbedPanel"; // NOI18N
096    }
097
098    /**
099     * {@inheritDoc}
100     */
101    @Override
102    public String getTitle() {
103        return Bundle.getMessage("TabbedTitle");
104    }
105
106    /**
107     * {@inheritDoc}
108     */
109    @Override
110    public void dispose() {
111        dgip.dispose();
112        dgsp.dispose();
113    }
114
115}