001package jmri.jmrit.mastbuilder;
002
003import java.awt.FlowLayout;
004import javax.swing.Box;
005import javax.swing.BoxLayout;
006import javax.swing.ImageIcon;
007import javax.swing.JButton;
008import javax.swing.JComboBox;
009import javax.swing.JLabel;
010import javax.swing.JPanel;
011import javax.swing.JSeparator;
012import javax.swing.JSpinner;
013import javax.swing.SpinnerNumberModel;
014import javax.swing.JTextField;
015import jmri.util.FileUtil;
016
017/**
018 * Pane for building Signal Mast definitions.
019 * Demo, not in any JMRI menu or tool as of 4.9.6
020 *
021 * TODO: add code behind buttons, add to jmri.jmrit.ToolsMenu using
022 * {@literal add(new jmri.jmrit.mastbuilder.MastBuilderAction(Bundle.getMessage("MastBuilderTitle") + "..."));}
023 *
024 * @author Bob Jacobsen Copyright (C) 2010
025 */
026public class MastBuilderPane extends jmri.util.JmriJFrame {
027
028    public MastBuilderPane() {
029        super();
030    }
031
032    @Override
033    public void initComponents() {
034        setTitle(Bundle.getMessage("MastBuilderTitle"));
035
036        JPanel builderPane = new JPanel();
037        builderPane.setLayout(new BoxLayout(builderPane, BoxLayout.Y_AXIS));
038
039        String head = Bundle.getMessage("BeanNameSignalHead");
040        String turnout = Bundle.getMessage("BeanNameTurnout");
041        String closed = Bundle.getMessage("TurnoutStateClosed");
042        String thrown = Bundle.getMessage("TurnoutStateThrown");
043        String delete = Bundle.getMessage("ButtonDelete");
044        String aspclear = Bundle.getMessage("AspectClear");
045        String aspadvappmed = Bundle.getMessage("AspectAdvApprMed");
046        String aspapprlim = Bundle.getMessage("AspectApprLim");
047        String asplimclear = Bundle.getMessage("AspectLimClear");
048
049        JPanel p = new JPanel();
050        p.setLayout(new jmri.util.javaworld.GridLayout2(1, 3));
051        builderPane.add(p);
052
053        p.add(new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("SigSys"))));
054        p.add(new JComboBox<String>(new String[]{
055                Bundle.getMessage("OptionBasic"),
056                Bundle.getMessage("OptionAAR"),
057                Bundle.getMessage("OptionNYCS")
058        }));
059
060        JPanel p2 = new JPanel();
061        p2.add(new JLabel(Bundle.getMessage("NumOutputsLabel")));
062        p2.add(new JSpinner(new SpinnerNumberModel(4, 1, 10,1)));
063        p.add(p2);
064
065        builderPane.add(new JSeparator());
066
067        p = new JPanel();
068        p.setLayout(new jmri.util.javaworld.GridLayout2(1 + 4, 5));
069        builderPane.add(p);
070
071        // first how is titles
072        p.add(new JLabel(Bundle.getMessage("NameTypeLabel")));
073        p.add(new JComboBox<String>(new String[]{head, turnout}));
074        p.add(new JComboBox<String>(new String[]{head, turnout}));
075        p.add(new JComboBox<String>(new String[]{head, turnout}));
076        p.add(new JLabel(""));
077
078        p.add(new JComboBox<String>(new String[]{aspclear, aspadvappmed, aspapprlim, asplimclear}));
079        p.add(new JComboBox<Object>(icons()));
080        p.add(new JComboBox<String>(new String[]{closed, thrown}));
081        p.add(new JComboBox<Object>(icons()));
082        p.add(new JButton(delete));
083
084        p.add(new JComboBox<String>(new String[]{aspclear, aspadvappmed, aspapprlim, asplimclear}));
085        p.add(new JComboBox<Object>(icons()));
086        p.add(new JComboBox<String>(new String[]{closed, thrown}));
087        p.add(new JComboBox<Object>(icons()));
088        p.add(new JButton(delete));
089
090        p.add(new JComboBox<String>(new String[]{aspclear, aspadvappmed, aspapprlim, asplimclear}));
091        p.add(new JComboBox<Object>(icons()));
092        p.add(new JComboBox<String>(new String[]{closed, thrown}));
093        p.add(new JComboBox<Object>(icons()));
094        p.add(new JButton(delete));
095
096        p.add(new JComboBox<String>(new String[]{aspclear, aspadvappmed, aspapprlim, asplimclear}));
097        p.add(new JComboBox<Object>(icons()));
098        p.add(new JComboBox<String>(new String[]{closed, thrown}));
099        p.add(new JComboBox<Object>(icons()));
100        p.add(new JButton(delete));
101
102        p = new JPanel();
103        p.setLayout(new FlowLayout());
104        builderPane.add(p);
105        p.add(new JButton(Bundle.getMessage("AddAspectButton")));
106
107        builderPane.add(new JSeparator());
108
109        p = new JPanel();
110        p.setLayout(new FlowLayout());
111        builderPane.add(p);
112        p.add(new JLabel(Bundle.getMessage("NewAppTableLabel")));
113        p.add(new JTextField(30));
114        p.add(new JButton(Bundle.getMessage("ButtonSave")));
115
116        builderPane.add(Box.createVerticalGlue());
117        getContentPane().add(builderPane);
118    }
119
120    Object[] icons() {
121        Object[] list = new Object[3];
122        list[0] = new ImageIcon(FileUtil.findURL("resources/icons/smallschematics/aspects/AAR-1946/SL-1-low/rule-287.gif"));
123        list[1] = new ImageIcon(FileUtil.findURL("resources/icons/smallschematics/aspects/AAR-1946/SL-1-low/rule-290.gif"));
124        list[2] = new ImageIcon(FileUtil.findURL("resources/icons/smallschematics/aspects/AAR-1946/SL-1-low/rule-292.gif"));
125        return list;
126    }
127
128}