001package jmri.jmrit.display.layoutEditor; 002 003import java.awt.FlowLayout; 004import javax.annotation.Nonnull; 005import javax.swing.*; 006import javax.swing.border.*; 007 008/** 009 * This is the floating toolbar panel 010 * 011 * @author George Warner Copyright: (c) 2017-2019 012 */ 013public class LayoutEditorFloatingToolBarPanel extends LayoutEditorToolBarPanel { 014 015 private JPanel floatEditTabsPanel = new JPanel(); 016 private JTabbedPane floatEditTabsPane = new JTabbedPane(); 017 018 /** 019 * constructor for LayoutEditorFloatingToolBarPanel 020 * 021 * @param layoutEditor the layout editor that this is for 022 */ 023 public LayoutEditorFloatingToolBarPanel(@Nonnull LayoutEditor layoutEditor) { 024 super(layoutEditor); 025 localLayoutComponents(); 026 } 027 028 // super.setupComponents() used as-is. super.layoutComponents() is 029 // suppressed, as it doesn't need to run. localLayoutComponents() 030 // is then invoked by this class's constructor after the initializers 031 // are complete. (Putting this into an override of layoutComponents would 032 // not be correct, as that is invoked from the superclass constructor before 033 // this classes initializers are run; local reference members will be 034 // overwritten when that happens.) 035 036 /** 037 * Deliberately not running the superclass 038 * {@link LayoutEditorToolBarPanel#layoutComponents()} 039 * method. 040 */ 041 @Override 042 final protected void layoutComponents() { 043 } 044 045 /** 046 * Local configuration of Swing components run as 047 * last phase of construction. 048 */ 049 private void localLayoutComponents() { 050 /* 051 * JPanel - floatEditTabsPanel 052 * JTabbedPane - floatEditTabsPane 053 * ... 054 * JPanel - floatEditLocationPanel 055 * ... 056 * JPanel - floatEditActionPanel (currently disabled) 057 * ... 058 * JPanel - floatEditHelpPanel 059 * ... 060 */ 061 062 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); 063 064 FlowLayout floatContentLayout = new FlowLayout(FlowLayout.CENTER, 5, 2); //5 pixel gap between items, 2 vertical gap 065 066 // Contains the block and sensor combo boxes. 067 // It is moved to the appropriate detail pane when the tab changes. 068 blockPropertiesPanel = new JPanel(); 069 blockPropertiesPanel.setLayout(new BoxLayout(blockPropertiesPanel, BoxLayout.Y_AXIS)); 070 071 JPanel blockPanel = new JPanel(floatContentLayout); 072 blockPanel.add(blockLabel); 073 blockPanel.add(blockIDComboBox); 074 blockPanel.add(highlightBlockCheckBox); 075 blockPropertiesPanel.add(blockPanel); 076 077 JPanel blockSensorPanel = new JPanel(floatContentLayout); 078 blockSensorPanel.add(blockSensorLabel); 079 blockSensorPanel.add(blockSensorComboBox); 080 blockSensorPanel.setBorder(new EmptyBorder(0, 20, 0, 0)); 081 blockPropertiesPanel.add(blockSensorPanel); 082 083 // Begin the tabs structure 084 // 085 // Tab 0 - Turnouts 086 JPanel floatEditTurnout = new JPanel(); 087 floatEditTurnout.setLayout(new BoxLayout(floatEditTurnout, BoxLayout.Y_AXIS)); 088 089 JPanel turnoutGroup1 = new JPanel(floatContentLayout); 090 turnoutGroup1.add(turnoutRHButton); 091 turnoutGroup1.add(turnoutLHButton); 092 turnoutGroup1.add(turnoutWYEButton); 093 turnoutGroup1.add(layoutSingleSlipButton); 094 turnoutGroup1.add(layoutDoubleSlipButton); 095 floatEditTurnout.add(turnoutGroup1); 096 097 JPanel turnoutGroup2 = new JPanel(floatContentLayout); 098 turnoutGroup2.add(doubleXoverButton); 099 turnoutGroup2.add(rhXoverButton); 100 turnoutGroup2.add(lhXoverButton); 101 floatEditTurnout.add(turnoutGroup2); 102 103 JPanel turnoutGroup3 = new JPanel(floatContentLayout); 104 turnoutGroup3.add(turnoutNamePanel); 105 floatEditTurnout.add(turnoutGroup3); 106 107 JPanel turnoutGroup3a = new JPanel(floatContentLayout); 108 turnoutGroup3a.add(extraTurnoutPanel); 109 floatEditTurnout.add(turnoutGroup3a); 110 111 JPanel turnoutGroup4 = new JPanel(floatContentLayout); 112 turnoutGroup4.add(rotationPanel); 113 floatEditTurnout.add(turnoutGroup4); 114 115 floatEditTurnout.add(blockPropertiesPanel); 116 117 floatEditTabsPane.addTab(Bundle.getMessage("Turnouts"), null, floatEditTurnout, null); 118 119 // Tab 1 - Track 120 JPanel floatEditTrack = new JPanel(); 121 floatEditTrack.setLayout(new BoxLayout(floatEditTrack, BoxLayout.Y_AXIS)); 122 123 JPanel trackGroup1 = new JPanel(floatContentLayout); 124 trackGroup1.add(endBumperButton); 125 trackGroup1.add(anchorButton); 126 trackGroup1.add(edgeButton); 127 floatEditTrack.add(trackGroup1); 128 129 JPanel trackGroup2 = new JPanel(floatContentLayout); 130 trackGroup2.add(trackButton); 131 trackGroup2.add(levelXingButton); 132 floatEditTrack.add(trackGroup2); 133 134 JPanel trackGroup3 = new JPanel(floatContentLayout); 135 trackGroup3.add(trackSegmentPropertiesPanel); 136 floatEditTrack.add(trackGroup3); 137 138 floatEditTabsPane.addTab(Bundle.getMessage("TabTrack"), null, floatEditTrack, null); 139 140 // Tab 2 - Labels 141 JPanel floatEditLabel = new JPanel(); 142 floatEditLabel.setLayout(new BoxLayout(floatEditLabel, BoxLayout.Y_AXIS)); 143 144 JPanel labelGroup1 = new JPanel(floatContentLayout); 145 labelGroup1.add(textLabelButton); 146 labelGroup1.add(textLabelTextField); 147 floatEditLabel.add(labelGroup1); 148 149 JPanel labelGroup2 = new JPanel(floatContentLayout); 150 labelGroup2.add(memoryButton); 151 labelGroup2.add(textMemoryComboBox); 152 floatEditLabel.add(labelGroup2); 153 154 JPanel labelGroup4 = new JPanel(floatContentLayout); 155 labelGroup4.add(globalVariableButton); 156 labelGroup4.add(textGlobalVariableComboBox); 157 floatEditLabel.add(labelGroup4); 158 159 JPanel labelGroup3 = new JPanel(floatContentLayout); 160 labelGroup3.add(blockContentsButton); 161 labelGroup3.add(blockContentsComboBox); 162 floatEditLabel.add(labelGroup3); 163 164 floatEditTabsPane.addTab(Bundle.getMessage("TabLabel"), null, floatEditLabel, null); 165 166 // Tab 3 - Icons 167 JPanel floatEditIcon = new JPanel(); 168 floatEditIcon.setLayout(new BoxLayout(floatEditIcon, BoxLayout.Y_AXIS)); 169 170 JPanel iconGroup1 = new JPanel(floatContentLayout); 171 iconGroup1.add(multiSensorButton); 172 iconGroup1.add(changeIconsButton); 173 floatEditIcon.add(iconGroup1); 174 175 JPanel iconGroup2 = new JPanel(floatContentLayout); 176 iconGroup2.add(sensorButton); 177 iconGroup2.add(sensorComboBox); 178 floatEditIcon.add(iconGroup2); 179 180 JPanel iconGroup3 = new JPanel(floatContentLayout); 181 iconGroup3.add(signalMastButton); 182 iconGroup3.add(signalMastComboBox); 183 floatEditIcon.add(iconGroup3); 184 185 JPanel iconGroup4 = new JPanel(floatContentLayout); 186 iconGroup4.add(signalButton); 187 iconGroup4.add(signalHeadComboBox); 188 floatEditIcon.add(iconGroup4); 189 190 JPanel iconGroup5 = new JPanel(floatContentLayout); 191 iconGroup5.add(iconLabelButton); 192 iconGroup5.add(logixngButton); 193 iconGroup5.add(shapeButton); 194 floatEditIcon.add(iconGroup5); 195 196 JPanel iconGroup6 = new JPanel(floatContentLayout); 197 iconGroup6.add(audioButton); 198 iconGroup6.add(textAudioComboBox); 199 floatEditIcon.add(iconGroup6); 200 201 floatEditTabsPane.addTab(Bundle.getMessage("TabIcon"), null, floatEditIcon, null); 202 floatEditTabsPanel.add(floatEditTabsPane); 203 add(floatEditTabsPanel); 204 205 // End the tabs structure 206 // The next 3 groups reside under the tab secton 207 JPanel floatEditLocationPanel = new JPanel(); 208 floatEditLocationPanel.add(zoomPanel); 209 floatEditLocationPanel.add(locationPanel); 210 add(floatEditLocationPanel); 211 212 floatEditTabsPane.addChangeListener((e) -> { 213 //Move the block group between the turnouts and track tabs 214 int selIndex = floatEditTabsPane.getSelectedIndex(); 215 216 if (selIndex == 0) { 217 floatEditTurnout.add(blockPropertiesPanel); 218 } else if (selIndex == 1) { 219 floatEditTrack.add(blockPropertiesPanel); 220 } 221 }); 222 floatEditTabsPane.setSelectedIndex(0); 223 floatEditTurnout.add(blockPropertiesPanel); 224 } 225 226 public JTabbedPane getfloatEditTabsPane() { 227 return floatEditTabsPane; 228 } 229 230 // initialize logging 231 // private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LayoutEditorFloatingToolBarPanel.class); 232}