001package jmri.jmrit.logixng.tools.swing;
002
003import java.awt.*;
004import java.awt.event.*;
005
006import javax.swing.*;
007
008import jmri.jmrit.logixng.*;
009import jmri.util.JmriJFrame;
010
011/**
012 * Show the action/expression tree.
013 * <P>
014 * Base class for ConditionalNG editors
015 *
016 * @author Daniel Bergqvist 2018
017 */
018public class TreeViewer extends JmriJFrame {
019
020    private static final int panelWidth = 500;
021    private static final int panelHeight = 300;
022
023    private boolean _rootVisible = true;
024
025    public final TreePane _treePane;
026
027
028    /**
029     * Construct a ConditionalEditor.
030     *
031     * @param femaleRootSocket the root of the tree
032     */
033    public TreeViewer(FemaleSocket femaleRootSocket) {
034        _treePane = new TreePane(femaleRootSocket);
035    }
036
037    @Override
038    public void initComponents() {
039        super.initComponents();
040
041        // build menu
042        JMenuBar menuBar = new JMenuBar();
043        JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
044        JMenuItem closeWindowItem = new JMenuItem(Bundle.getMessage("CloseWindow"));
045        closeWindowItem.addActionListener((ActionEvent e) -> {
046            dispose();
047        });
048        fileMenu.add(closeWindowItem);
049        menuBar.add(fileMenu);
050
051        setJMenuBar(menuBar);
052//        addHelpMenu("package.jmri.jmrit.operations.Operations_Settings", true); // NOI18N
053
054        _treePane.initComponents();
055
056        // add panels
057        getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
058        getContentPane().add(_treePane);
059
060        initMinimumSize(new Dimension(panelWidth, panelHeight));
061    }
062
063    public void initMinimumSize(Dimension dimension) {
064        setMinimumSize(dimension);
065        pack();
066        setVisible(true);
067    }
068
069    public boolean getRootVisible() {
070        return _rootVisible;
071    }
072
073    public void setRootVisible(boolean rootVisible) {
074        _rootVisible = rootVisible;
075    }
076
077    @Override
078    public void dispose() {
079        _treePane.dispose();
080        super.dispose();
081    }
082
083
084//    private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TreeViewer.class);
085
086}