001package jmri.jmrit.display.layoutEditor;
002
003import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
004import javax.annotation.Nonnull;
005import javax.swing.*;
006import javax.swing.border.*;
007
008/**
009 * This is the horizontal toolbar panel
010 *
011 * @author George Warner Copyright: (c) 2019
012 */
013public class LayoutEditorHorizontalToolBarPanel extends LayoutEditorToolBarPanel {
014
015    /**
016     * constructor for LayoutEditorHorizontalToolBarPanel
017     *
018     * @param layoutEditor the layout editor that this is for
019     */
020    public LayoutEditorHorizontalToolBarPanel(@Nonnull LayoutEditor layoutEditor) {
021        super(layoutEditor);
022    }   //constructor
023
024    /**
025     * {@inheritDoc}
026     */
027    @Override
028    protected void layoutComponents() {
029        setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
030
031        JPanel outerBorderPanel = this;
032        JPanel innerBorderPanel = this;
033
034        //Row 1
035        JPanel hTop1Panel = new JPanel();
036        hTop1Panel.setLayout(new BoxLayout(hTop1Panel, BoxLayout.LINE_AXIS));
037
038        //Row 1 : Left Components
039        JPanel hTop1Left = new JPanel(leftRowLayout);
040        turnoutLabel = new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("BeanNameTurnout")));
041        hTop1Left.add(turnoutLabel);
042        hTop1Left.add(turnoutRHButton);
043        hTop1Left.add(turnoutLHButton);
044        hTop1Left.add(turnoutWYEButton);
045        hTop1Left.add(doubleXoverButton);
046        hTop1Left.add(rhXoverButton);
047        hTop1Left.add(lhXoverButton);
048        hTop1Left.add(layoutSingleSlipButton);
049        hTop1Left.add(layoutDoubleSlipButton);
050        hTop1Panel.add(hTop1Left);
051
052        if (toolBarIsWide) {
053            hTop1Panel.add(Box.createHorizontalGlue());
054
055            JPanel hTop1Right = new JPanel(rightRowLayout);
056            hTop1Right.add(turnoutNamePanel);
057            hTop1Right.add(extraTurnoutPanel);
058            hTop1Right.add(rotationPanel);
059            hTop1Panel.add(hTop1Right);
060        }
061        innerBorderPanel.add(hTop1Panel);
062
063        //row 2
064        if (!toolBarIsWide) {
065            JPanel hTop2Panel = new JPanel();
066            hTop2Panel.setLayout(new BoxLayout(hTop2Panel, BoxLayout.LINE_AXIS));
067
068            //Row 2 : Left Components
069            JPanel hTop2Center = new JPanel(centerRowLayout);
070            hTop2Center.add(turnoutNamePanel);
071            hTop2Center.add(extraTurnoutPanel);
072            hTop2Center.add(rotationPanel);
073            hTop2Panel.add(hTop2Center);
074
075            innerBorderPanel.add(hTop2Panel);
076        }
077
078        //Row 3 (2 wide)
079        JPanel hTop3Panel = new JPanel();
080        hTop3Panel.setLayout(new BoxLayout(hTop3Panel, BoxLayout.LINE_AXIS));
081
082        //Row 3 : Left Components
083        JPanel hTop3Left = new JPanel(leftRowLayout);
084        trackLabel = new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("Track")));
085
086        hTop3Left.add(trackLabel);
087        hTop3Left.add(levelXingButton);
088        hTop3Left.add(trackButton);
089        hTop3Left.add(trackSegmentPropertiesPanel);
090
091        hTop3Panel.add(hTop3Left);
092        hTop3Panel.add(Box.createHorizontalGlue());
093
094        //Row 3 : Center Components
095        JPanel hTop3Center = new JPanel(centerRowLayout);
096        hTop3Center.add(blockLabel);
097        hTop3Center.add(blockIDComboBox);
098        hTop3Center.add(highlightBlockCheckBox);
099
100        JPanel hTop3CenterA = new JPanel(centerRowLayout);
101        hTop3CenterA.add(blockSensorLabel);
102        hTop3CenterA.add(blockSensorComboBox);
103        hTop3CenterA.setBorder(new EmptyBorder(0, 20, 0, 0));
104        hTop3Center.add(hTop3CenterA);
105
106        hTop3Panel.add(hTop3Center);
107        hTop3Panel.add(Box.createHorizontalGlue());
108
109        if (toolBarIsWide) {
110            //row 3 : Right Components
111            JPanel hTop3Right = new JPanel(rightRowLayout);
112            hTop3Right.add(zoomPanel);
113            hTop3Right.add(locationPanel);
114            hTop3Panel.add(hTop3Right);
115        }
116        outerBorderPanel.add(hTop3Panel);
117
118        //Row 4
119        JPanel hTop4Panel = new JPanel();
120        hTop4Panel.setLayout(new BoxLayout(hTop4Panel, BoxLayout.LINE_AXIS));
121
122        //Row 4 : Left Components
123        JPanel hTop4Left = new JPanel(leftRowLayout);
124        hTop4Left.add(new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("Nodes"))));
125        hTop4Left.add(endBumperButton);
126        hTop4Left.add(anchorButton);
127        hTop4Left.add(edgeButton);
128        hTop4Panel.add(hTop4Left);
129        hTop4Panel.add(Box.createHorizontalGlue());
130
131        if (!toolBarIsWide) {
132            //Row 4 : Right Components
133            JPanel hTop4Right = new JPanel(rightRowLayout);
134            hTop4Right.add(zoomPanel);
135            hTop4Right.add(locationPanel);
136            hTop4Panel.add(hTop4Right);
137        }
138        add(hTop4Panel);
139
140        //Row 5 Components (wide 4-center)
141        labelsLabel = new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("Labels")));
142        if (toolBarIsWide) {
143            JPanel hTop4Center = new JPanel(centerRowLayout);
144            hTop4Center.add(labelsLabel);
145            hTop4Center.add(textLabelButton);
146            hTop4Center.add(textLabelTextField);
147            hTop4Center.add(memoryButton);
148            hTop4Center.add(textMemoryComboBox);
149            hTop4Center.add(globalVariableButton);
150            hTop4Center.add(textGlobalVariableComboBox);
151            hTop4Center.add(blockContentsButton);
152            hTop4Center.add(blockContentsComboBox);
153            hTop4Panel.add(hTop4Center);
154            hTop4Panel.add(Box.createHorizontalGlue());
155            add(hTop4Panel);
156        } else {
157            add(hTop4Panel);
158
159            JPanel hTop5Left = new JPanel(leftRowLayout);
160            hTop5Left.add(labelsLabel);
161            hTop5Left.add(textLabelButton);
162            hTop5Left.add(textLabelTextField);
163            hTop5Left.add(memoryButton);
164            hTop5Left.add(textMemoryComboBox);
165            hTop5Left.add(globalVariableButton);
166            hTop5Left.add(textGlobalVariableComboBox);
167            hTop5Left.add(blockContentsButton);
168            hTop5Left.add(blockContentsComboBox);
169            hTop5Left.add(Box.createHorizontalGlue());
170            add(hTop5Left);
171        }
172
173        //Row 6
174        JPanel hTop6Panel = new JPanel();
175        hTop6Panel.setLayout(new BoxLayout(hTop6Panel, BoxLayout.LINE_AXIS));
176
177        //Row 6 : Left Components
178        //JPanel hTop6Left = new JPanel(centerRowLayout);
179        JPanel hTop6Left = new JPanel(leftRowLayout);
180        hTop6Left.add(multiSensorButton);
181        hTop6Left.add(changeIconsButton);
182        hTop6Left.add(sensorButton);
183        hTop6Left.add(sensorComboBox);
184        hTop6Left.add(signalMastButton);
185        hTop6Left.add(signalMastComboBox);
186        hTop6Left.add(signalButton);
187        hTop6Left.add(signalHeadComboBox);
188        hTop6Left.add(new JLabel(" "));
189        hTop6Left.add(iconLabelButton);
190        hTop6Left.add(shapeButton);
191
192        hTop6Panel.add(hTop6Left);
193        add(hTop6Panel);
194    }   //layoutComponents
195
196    //initialize logging
197    //private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LayoutEditorHorizontalToolBarPanel.class);
198}