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 protected final 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 trackGroup2.add(turntableButton); 133 trackGroup2.add(traverserButton); 134 floatEditTrack.add(trackGroup2); 135 136 JPanel trackGroup3 = new JPanel(floatContentLayout); 137 trackGroup3.add(trackSegmentPropertiesPanel); 138 floatEditTrack.add(trackGroup3); 139 140 floatEditTabsPane.addTab(Bundle.getMessage("TabTrack"), null, floatEditTrack, null); 141 142 // Tab 2 - Labels 143 JPanel floatEditLabel = new JPanel(); 144 floatEditLabel.setLayout(new BoxLayout(floatEditLabel, BoxLayout.Y_AXIS)); 145 146 JPanel labelGroup1 = new JPanel(floatContentLayout); 147 labelGroup1.add(textLabelButton); 148 labelGroup1.add(textLabelTextField); 149 floatEditLabel.add(labelGroup1); 150 151 JPanel labelGroup2 = new JPanel(floatContentLayout); 152 labelGroup2.add(memoryButton); 153 labelGroup2.add(textMemoryComboBox); 154 floatEditLabel.add(labelGroup2); 155 156 JPanel labelGroup4 = new JPanel(floatContentLayout); 157 labelGroup4.add(globalVariableButton); 158 labelGroup4.add(textGlobalVariableComboBox); 159 floatEditLabel.add(labelGroup4); 160 161 JPanel labelGroup3 = new JPanel(floatContentLayout); 162 labelGroup3.add(blockContentsButton); 163 labelGroup3.add(blockContentsComboBox); 164 floatEditLabel.add(labelGroup3); 165 166 floatEditTabsPane.addTab(Bundle.getMessage("TabLabel"), null, floatEditLabel, null); 167 168 // Tab 3 - Icons 169 JPanel floatEditIcon = new JPanel(); 170 floatEditIcon.setLayout(new BoxLayout(floatEditIcon, BoxLayout.Y_AXIS)); 171 172 JPanel iconGroup1 = new JPanel(floatContentLayout); 173 iconGroup1.add(multiSensorButton); 174 iconGroup1.add(changeIconsButton); 175 floatEditIcon.add(iconGroup1); 176 177 JPanel iconGroup2 = new JPanel(floatContentLayout); 178 iconGroup2.add(sensorButton); 179 iconGroup2.add(sensorComboBox); 180 floatEditIcon.add(iconGroup2); 181 182 JPanel iconGroup2t = new JPanel(floatContentLayout); 183 iconGroup2t.add(turnoutButton); 184 iconGroup2t.add(turnoutComboBox); 185 floatEditIcon.add(iconGroup2t); 186 187 JPanel iconGroup3 = new JPanel(floatContentLayout); 188 iconGroup3.add(signalMastButton); 189 iconGroup3.add(signalMastComboBox); 190 floatEditIcon.add(iconGroup3); 191 192 JPanel iconGroup4 = new JPanel(floatContentLayout); 193 iconGroup4.add(signalButton); 194 iconGroup4.add(signalHeadComboBox); 195 floatEditIcon.add(iconGroup4); 196 197 JPanel iconGroup5 = new JPanel(floatContentLayout); 198 iconGroup5.add(iconLabelButton); 199 iconGroup5.add(logixngButton); 200 iconGroup5.add(shapeButton); 201 floatEditIcon.add(iconGroup5); 202 203 JPanel iconGroup6 = new JPanel(floatContentLayout); 204 iconGroup6.add(audioButton); 205 iconGroup6.add(textAudioComboBox); 206 floatEditIcon.add(iconGroup6); 207 208 floatEditTabsPane.addTab(Bundle.getMessage("TabIcon"), null, floatEditIcon, null); 209 floatEditTabsPanel.add(floatEditTabsPane); 210 add(floatEditTabsPanel); 211 212 // End the tabs structure 213 // The next 3 groups reside under the tab secton 214 JPanel floatEditLocationPanel = new JPanel(); 215 floatEditLocationPanel.add(zoomPanel); 216 floatEditLocationPanel.add(locationPanel); 217 add(floatEditLocationPanel); 218 219 floatEditTabsPane.addChangeListener((e) -> { 220 //Move the block group between the turnouts and track tabs 221 int selIndex = floatEditTabsPane.getSelectedIndex(); 222 223 if (selIndex == 0) { 224 floatEditTurnout.add(blockPropertiesPanel); 225 } else if (selIndex == 1) { 226 floatEditTrack.add(blockPropertiesPanel); 227 } 228 }); 229 floatEditTabsPane.setSelectedIndex(0); 230 floatEditTurnout.add(blockPropertiesPanel); 231 } 232 233 public JTabbedPane getfloatEditTabsPane() { 234 return floatEditTabsPane; 235 } 236 237 // initialize logging 238 // private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LayoutEditorFloatingToolBarPanel.class); 239}