001package jmri.jmrit.dispatcher;
002
003import java.awt.Container;
004import java.awt.FlowLayout;
005import java.awt.event.ActionEvent;
006import java.awt.event.ActionListener;
007import java.util.ArrayList;
008import java.util.Enumeration;
009
010import javax.swing.BorderFactory;
011import javax.swing.BoxLayout;
012import javax.swing.ButtonGroup;
013import javax.swing.JButton;
014import javax.swing.JCheckBox;
015import javax.swing.JCheckBoxMenuItem;
016import javax.swing.JComboBox;
017import javax.swing.JLabel;
018import javax.swing.JMenu;
019import javax.swing.JMenuItem;
020import javax.swing.JPanel;
021import javax.swing.JRadioButton;
022import javax.swing.JSeparator;
023import javax.swing.JSpinner;
024import javax.swing.SpinnerNumberModel;
025
026import jmri.InstanceManager;
027import jmri.Scale;
028import jmri.ScaleManager;
029import jmri.implementation.SignalSpeedMap;
030import jmri.jmrit.dispatcher.DispatcherFrame.TrainsFrom;
031import jmri.jmrit.display.EditorManager;
032import jmri.jmrit.display.layoutEditor.LayoutEditor;
033import jmri.util.JmriJFrame;
034import jmri.util.swing.JmriJOptionPane;
035
036/**
037 * Set up and processes items in the Dispatcher Options menu.
038 *
039 * @author Dave Duchamp Copyright (C) 2008
040 */
041public class OptionsMenu extends JMenu {
042
043    // Empty constructor for class based preferences when "Skip message in future?" is enabled.
044    public OptionsMenu() {
045    }
046
047    public OptionsMenu(DispatcherFrame f) {
048        dispatcher = f;
049        this.setText(Bundle.getMessage("MenuOptions"));
050        autoDispatchItem = new JCheckBoxMenuItem(Bundle.getMessage("AutoDispatchItem"));
051        this.add(autoDispatchItem);
052        autoDispatchItem.addActionListener(new ActionListener() {
053            @Override
054            public void actionPerformed(ActionEvent event) {
055                handleAutoDispatch(event);
056            }
057        });
058        autoTurnoutsItem = new JCheckBoxMenuItem(Bundle.getMessage("AutoTurnoutsItem"));
059        this.add(autoTurnoutsItem);
060        autoTurnoutsItem.addActionListener(new ActionListener() {
061            @Override
062            public void actionPerformed(ActionEvent event) {
063                handleAutoTurnouts(event);
064            }
065        });
066        JMenuItem optionWindowItem = new JMenuItem(Bundle.getMessage("OptionWindowItem") + "...");
067        this.add(optionWindowItem);
068        optionWindowItem.addActionListener(new ActionListener() {
069            @Override
070            public void actionPerformed(ActionEvent event) {
071                optionWindowRequested(event);
072            }
073        });
074        JMenuItem saveOptionsItem = new JMenuItem(Bundle.getMessage("SaveOptionsItem"));
075        this.add(saveOptionsItem);
076        saveOptionsItem.addActionListener(new ActionListener() {
077            @Override
078            public void actionPerformed(ActionEvent event) {
079                saveRequested(event);
080            }
081        });
082        initializeMenu();
083    }
084
085    protected DispatcherFrame dispatcher = null;
086
087    // Option menu items
088    private JCheckBoxMenuItem autoDispatchItem = null;
089    private JCheckBoxMenuItem autoTurnoutsItem = null;
090
091    // Initialize check box items in menu from Dispatcher
092    public void initializeMenu() {
093        autoDispatchItem.setSelected(dispatcher.getAutoAllocate());
094        autoTurnoutsItem.setSelected(dispatcher.getAutoTurnouts());
095    }
096
097    private void handleAutoDispatch(ActionEvent e) {
098        boolean set = autoDispatchItem.isSelected();
099        dispatcher.setAutoAllocate(set);
100    }
101
102    private void handleAutoTurnouts(ActionEvent e) {
103        boolean set = autoTurnoutsItem.isSelected();
104        dispatcher.setAutoTurnouts(set);
105    }
106
107    // options window items
108    JmriJFrame optionsFrame = null;
109    Container optionsPane = null;
110    JCheckBox useConnectivityCheckBox = new JCheckBox(Bundle.getMessage("UseConnectivity"));
111    ArrayList<LayoutEditor> layoutEditorList = new ArrayList<>();
112
113    JCheckBox autoAllocateCheckBox = new JCheckBox(Bundle.getMessage("AutoAllocateBox"));
114    JCheckBox autoTurnoutsCheckBox = new JCheckBox(Bundle.getMessage("AutoTurnoutsBox"));
115    JRadioButton trainsFromRoster = new JRadioButton(Bundle.getMessage("TrainsFromRoster"));
116    JRadioButton trainsFromTrains = new JRadioButton(Bundle.getMessage("TrainsFromTrains"));
117    JRadioButton trainsFromUser = new JRadioButton(Bundle.getMessage("TrainsFromUser"));
118    JComboBox<String> signalTypeBox;
119    JCheckBox detectionCheckBox = new JCheckBox(Bundle.getMessage("DetectionBox"));
120    JCheckBox setSSLDirectionalSensorsCheckBox = new JCheckBox(Bundle.getMessage("SetSSLDirectionSensorsBox"));
121    JCheckBox shortNameCheckBox = new JCheckBox(Bundle.getMessage("ShortNameBox"));
122    JCheckBox nameInBlockCheckBox = new JCheckBox(Bundle.getMessage("NameInBlockBox"));
123    JCheckBox rosterInBlockCheckBox = new JCheckBox(Bundle.getMessage("RosterInBlockBox"));
124    JCheckBox extraColorForAllocatedCheckBox = new JCheckBox(Bundle.getMessage("ExtraColorForAllocatedBox"));
125    JCheckBox nameInAllocatedBlockCheckBox = new JCheckBox(Bundle.getMessage("NameInAllocatedBlockBox"));
126    JCheckBox supportVSDecoderCheckBox = new JCheckBox(Bundle.getMessage("SupportVSDecoder"));
127    JComboBox<Scale> layoutScaleBox = new JComboBox<>();
128    JRadioButton scaleFeet = new JRadioButton(Bundle.getMessage("ScaleFeet"));
129    JRadioButton scaleMeters = new JRadioButton(Bundle.getMessage("ScaleMeters"));
130    JCheckBox openDispatcherWithPanel = new JCheckBox(Bundle.getMessage("OpenDispatcherWithPanelBox"));
131    JSpinner minThrottleIntervalSpinner = new JSpinner(new SpinnerNumberModel(100, 20, 1000, 1));
132    JSpinner fullRampTimeSpinner = new JSpinner(new SpinnerNumberModel(5000, 1000, 20000, 1));
133    JCheckBox trustKnownTurnoutsCheckBox = new JCheckBox(Bundle.getMessage("trustKnownTurnouts"));
134    JCheckBox useTurnoutConnectionDelayCheckBox = new JCheckBox(Bundle.getMessage("useTurnoutConnectionDelay"));
135    JComboBox<String> stoppingSpeedBox = new JComboBox<>();
136
137    String[] signalTypes = {Bundle.getMessage("SignalType1"), Bundle.getMessage("SignalType2"), Bundle.getMessage("SignalType3")};
138
139    private void optionWindowRequested(ActionEvent e) {
140        if (optionsFrame == null) {
141            optionsFrame = new JmriJFrame(Bundle.getMessage("OptionWindowItem"), false, true);
142            optionsFrame.addHelpMenu("package.jmri.jmrit.dispatcher.Options", true);
143            optionsPane = optionsFrame.getContentPane();
144            optionsPane.setLayout(new BoxLayout(optionsFrame.getContentPane(), BoxLayout.Y_AXIS));
145            JPanel p1 = new JPanel();
146            p1.setLayout(new FlowLayout());
147            p1.add(useConnectivityCheckBox);
148            useConnectivityCheckBox.setToolTipText(Bundle.getMessage("UseConnectivityHint"));
149            signalTypeBox = new JComboBox<>(signalTypes);
150            p1.add(signalTypeBox);
151            signalTypeBox.setToolTipText(Bundle.getMessage("SignalTypeHint"));
152            optionsPane.add(p1);
153            JPanel p2 = new JPanel();
154            p2.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("TrainsFrom")));
155            p2.setLayout(new FlowLayout());
156            ButtonGroup trainsGroup = new ButtonGroup();
157            p2.add(trainsFromRoster);
158            trainsFromRoster.setToolTipText(Bundle.getMessage("TrainsFromRosterHint"));
159            trainsGroup.add(trainsFromRoster);
160
161            ActionListener useRosterEntryListener = new ActionListener() {
162                @Override
163                public void actionPerformed(ActionEvent e) {
164                    if (trainsFromRoster.isSelected()) {
165                        rosterInBlockCheckBox.setEnabled(true);
166                        if (nameInBlockCheckBox.isSelected() && e.getSource() == nameInBlockCheckBox) {
167                            rosterInBlockCheckBox.setSelected(false);
168                        } else if (rosterInBlockCheckBox.isSelected() && e.getSource() == rosterInBlockCheckBox) {
169                            nameInBlockCheckBox.setSelected(false);
170                        }
171                    } else {
172                        rosterInBlockCheckBox.setEnabled(false);
173                    }
174                }
175            };
176            trainsFromRoster.addActionListener(useRosterEntryListener);
177            p2.add(new JLabel("     "));
178            p2.add(trainsFromTrains);
179            trainsFromTrains.setToolTipText(Bundle.getMessage("TrainsFromTrainsHint"));
180            trainsFromTrains.addActionListener(useRosterEntryListener);
181            trainsGroup.add(trainsFromTrains);
182            p2.add(new JLabel("     "));
183            p2.add(trainsFromUser);
184            trainsFromUser.setToolTipText(Bundle.getMessage("TrainsFromUserHint"));
185            trainsFromUser.addActionListener(useRosterEntryListener);
186            trainsGroup.add(trainsFromUser);
187            optionsPane.add(p2);
188            JPanel p3 = new JPanel();
189            p3.setLayout(new FlowLayout());
190            p3.add(detectionCheckBox);
191            detectionCheckBox.setToolTipText(Bundle.getMessage("DetectionBoxHint"));
192            optionsPane.add(p3);
193            JPanel p3A = new JPanel();
194            p3A.setLayout(new FlowLayout());
195            p3A.add(setSSLDirectionalSensorsCheckBox);
196            setSSLDirectionalSensorsCheckBox.setToolTipText(Bundle.getMessage("SetSSLDirectionSensorsBoxHint"));
197            optionsPane.add(p3A);
198            JPanel p4 = new JPanel();
199            p4.setLayout(new FlowLayout());
200            p4.add(autoAllocateCheckBox);
201            autoAllocateCheckBox.setToolTipText(Bundle.getMessage("AutoAllocateBoxHint"));
202            optionsPane.add(p4);
203            JPanel p5 = new JPanel();
204            p5.setLayout(new FlowLayout());
205            p5.add(autoTurnoutsCheckBox);
206            autoTurnoutsCheckBox.setToolTipText(Bundle.getMessage("AutoTurnoutsBoxHint"));
207            optionsPane.add(p5);  
208            JPanel p16 = new JPanel();
209            p16.setLayout(new FlowLayout());
210            p16.add(trustKnownTurnoutsCheckBox);
211            trustKnownTurnoutsCheckBox.setToolTipText(Bundle.getMessage("trustKnownTurnoutsHint"));
212            optionsPane.add(p16);
213            JPanel p16a = new JPanel();
214            p16a.setLayout(new FlowLayout());
215            p16a.add(useTurnoutConnectionDelayCheckBox);
216            useTurnoutConnectionDelayCheckBox.setToolTipText(Bundle.getMessage("trustKnownTurnoutsHint"));
217            optionsPane.add(p16a);
218            JPanel p6 = new JPanel();
219            p6.setLayout(new FlowLayout());
220            p6.add(shortNameCheckBox);
221            shortNameCheckBox.setToolTipText(Bundle.getMessage("ShortNameBoxHint"));
222            optionsPane.add(p6);
223            JPanel p7 = new JPanel();
224            p7.setLayout(new FlowLayout());
225            p7.add(nameInBlockCheckBox);
226            nameInBlockCheckBox.setToolTipText(Bundle.getMessage("NameInBlockBoxHint"));
227            nameInBlockCheckBox.addActionListener(useRosterEntryListener);
228            optionsPane.add(p7);
229            JPanel p7b = new JPanel();
230            p7b.setLayout(new FlowLayout());
231            p7b.add(rosterInBlockCheckBox);
232            rosterInBlockCheckBox.setToolTipText(Bundle.getMessage("RosterInBlockBoxHint"));
233            rosterInBlockCheckBox.addActionListener(useRosterEntryListener);
234            optionsPane.add(p7b);
235
236            JPanel p10 = new JPanel();
237            p10.setLayout(new FlowLayout());
238            p10.add(extraColorForAllocatedCheckBox);
239            extraColorForAllocatedCheckBox.setToolTipText(Bundle.getMessage("ExtraColorForAllocatedBoxHint"));
240            optionsPane.add(p10);
241            JPanel p11 = new JPanel();
242            p11.setLayout(new FlowLayout());
243            p11.add(nameInAllocatedBlockCheckBox);
244            nameInAllocatedBlockCheckBox.setToolTipText(Bundle.getMessage("NameInAllocatedBlockBoxHint"));
245            optionsPane.add(p11);
246            JPanel p13 = new JPanel();
247            p13.setLayout(new FlowLayout());
248            p13.add(supportVSDecoderCheckBox);
249            supportVSDecoderCheckBox.setToolTipText(Bundle.getMessage("SupportVSDecoderBoxHint"));
250            optionsPane.add(p13);
251            JPanel p8 = new JPanel();
252            initializeScaleCombo();
253            p8.add(new JLabel(Bundle.getMessage("LabelLayoutScale")));
254            p8.add(layoutScaleBox);
255            layoutScaleBox.setToolTipText(Bundle.getMessage("ScaleBoxHint"));
256            optionsPane.add(p8);
257            JPanel p12 = new JPanel();
258            p12.setLayout(new FlowLayout());
259            p12.add(new JLabel(Bundle.getMessage("Units") + "  "));
260            ButtonGroup scaleGroup = new ButtonGroup();
261            p12.add(scaleFeet);
262            scaleFeet.setToolTipText(Bundle.getMessage("ScaleFeetHint"));
263            scaleGroup.add(scaleFeet);
264            p12.add(new JLabel("  "));
265            p12.add(scaleMeters);
266            scaleMeters.setToolTipText(Bundle.getMessage("ScaleMetersHint"));
267            scaleGroup.add(scaleMeters);
268            optionsPane.add(p12);
269
270            JPanel p14 = new JPanel();
271            initializeStoppingSpeedCombo();
272            p14.add(new JLabel(Bundle.getMessage("LabelStoppingSpeed")));
273            p14.add(stoppingSpeedBox);
274            stoppingSpeedBox.setToolTipText(Bundle.getMessage("StoppingSpeedHint"));
275            optionsPane.add(p14);
276
277            JPanel p15 = new JPanel();
278            p15.setLayout(new FlowLayout());
279            p15.add(new JLabel(Bundle.getMessage("minThrottleInterval") + ":"));
280            minThrottleIntervalSpinner.setToolTipText(Bundle.getMessage("minThrottleIntervalHint"));
281            p15.add(minThrottleIntervalSpinner);
282            p15.add(new JLabel(Bundle.getMessage("LabelMilliseconds")));
283            optionsPane.add(p15);
284
285            JPanel p17 = new JPanel();
286            p17.setLayout(new FlowLayout());
287            p17.add(new JLabel(Bundle.getMessage("fullRampTime") + " :"));
288            fullRampTimeSpinner.setToolTipText(Bundle.getMessage("fullRampTimeHint", Bundle.getMessage("RAMP_FAST")));
289            p17.add(fullRampTimeSpinner);
290            p17.add(new JLabel(Bundle.getMessage("LabelMilliseconds")));
291            optionsPane.add(p17);
292
293            JPanel p18 = new JPanel();
294            p18.setLayout(new FlowLayout());
295            p18.add(openDispatcherWithPanel);
296            openDispatcherWithPanel.setToolTipText(Bundle.getMessage("OpenDispatcherWithPanelBoxHint"));
297            optionsPane.add(p18);
298
299            optionsPane.add(new JSeparator());
300            JPanel p9 = new JPanel();
301            p9.setLayout(new FlowLayout());
302            JButton cancelButton = null;
303            p9.add(cancelButton = new JButton(Bundle.getMessage("ButtonCancel")));
304            cancelButton.addActionListener(new ActionListener() {
305                @Override
306                public void actionPerformed(ActionEvent e) {
307                    cancelOptions(e);
308                }
309            });
310            cancelButton.setToolTipText(Bundle.getMessage("CancelButtonHint2"));
311            p9.add(new JLabel("     "));
312            JButton applyButton = null;
313            p9.add(applyButton = new JButton(Bundle.getMessage("ButtonApply")));
314            applyButton.addActionListener(new ActionListener() {
315                @Override
316                public void actionPerformed(ActionEvent e) {
317                    applyOptions(e);
318                }
319            });
320            applyButton.setToolTipText(Bundle.getMessage("ApplyButtonHint"));
321            optionsPane.add(p9);
322        }
323
324        initializeLayoutEditorList();
325        useConnectivityCheckBox.setEnabled(!layoutEditorList.isEmpty());
326        useConnectivityCheckBox.setSelected(dispatcher.getUseConnectivity());
327
328        signalTypeBox.setSelectedIndex(dispatcher.getSignalType());
329        switch (dispatcher.getTrainsFrom()) {
330            case TRAINSFROMROSTER:
331                trainsFromRoster.setSelected(true);
332                break;
333            case TRAINSFROMOPS:
334                trainsFromTrains.setSelected(true);
335                break;
336            case TRAINSFROMUSER:
337            default:
338                trainsFromUser.setSelected(true);
339        }
340        detectionCheckBox.setSelected(dispatcher.getHasOccupancyDetection());
341        setSSLDirectionalSensorsCheckBox.setSelected(dispatcher.getSetSSLDirectionalSensors());
342        autoAllocateCheckBox.setSelected(dispatcher.getAutoAllocate());
343        autoTurnoutsCheckBox.setSelected(dispatcher.getAutoTurnouts());
344        trustKnownTurnoutsCheckBox.setSelected(dispatcher.getTrustKnownTurnouts());
345        useTurnoutConnectionDelayCheckBox.setSelected(dispatcher.getUseTurnoutConnectionDelay());
346        shortNameCheckBox.setSelected(dispatcher.getShortActiveTrainNames());
347        nameInBlockCheckBox.setSelected(dispatcher.getShortNameInBlock());
348        rosterInBlockCheckBox.setSelected(dispatcher.getRosterEntryInBlock());
349        extraColorForAllocatedCheckBox.setSelected(dispatcher.getExtraColorForAllocated());
350        nameInAllocatedBlockCheckBox.setSelected(dispatcher.getNameInAllocatedBlock());
351        supportVSDecoderCheckBox.setSelected(dispatcher.getSupportVSDecoder());
352        scaleMeters.setSelected(dispatcher.getUseScaleMeters());
353        scaleFeet.setSelected(!dispatcher.getUseScaleMeters());
354        minThrottleIntervalSpinner.setValue(dispatcher.getMinThrottleInterval());
355        fullRampTimeSpinner.setValue(dispatcher.getFullRampTime());
356
357        boolean openDispatcher = false;
358        for (LayoutEditor panel : layoutEditorList) {
359            if (panel.getOpenDispatcherOnLoad()) {
360                openDispatcher = true;
361            }
362        }
363        openDispatcherWithPanel.setSelected(openDispatcher);
364        openDispatcherWithPanel.setEnabled(!layoutEditorList.isEmpty());
365
366        optionsFrame.pack();
367        optionsFrame.setVisible(true);
368    }
369
370    private void applyOptions(ActionEvent e) {
371        dispatcher.setUseConnectivity(useConnectivityCheckBox.isSelected());
372        dispatcher.setSetSSLDirectionalSensors(setSSLDirectionalSensorsCheckBox.isSelected());
373        if (trainsFromRoster.isSelected()) {
374            dispatcher.setTrainsFrom(TrainsFrom.TRAINSFROMROSTER);
375        } else if (trainsFromTrains.isSelected()) {
376            dispatcher.setTrainsFrom(TrainsFrom.TRAINSFROMOPS);
377        } else {
378            dispatcher.setTrainsFrom(TrainsFrom.TRAINSFROMUSER);
379        }
380        dispatcher.setHasOccupancyDetection(detectionCheckBox.isSelected());
381        dispatcher.setAutoAllocate(autoAllocateCheckBox.isSelected());
382        autoDispatchItem.setSelected(autoAllocateCheckBox.isSelected());
383        dispatcher.setAutoTurnouts(autoTurnoutsCheckBox.isSelected());
384        autoTurnoutsItem.setSelected(autoTurnoutsCheckBox.isSelected());
385        dispatcher.setTrustKnownTurnouts(trustKnownTurnoutsCheckBox.isSelected());
386        dispatcher.setUseTurnoutConnectionDelay(useTurnoutConnectionDelayCheckBox.isSelected());
387        dispatcher.setSignalType(signalTypeBox.getSelectedIndex());
388        if (autoTurnoutsCheckBox.isSelected() && ((layoutEditorList.size() == 0)
389                || (!useConnectivityCheckBox.isSelected()))) {
390            JmriJOptionPane.showMessageDialog(optionsFrame, Bundle.getMessage(
391                    "AutoTurnoutsWarn"), Bundle.getMessage("WarningTitle"), JmriJOptionPane.WARNING_MESSAGE);
392        }
393        dispatcher.setShortActiveTrainNames(shortNameCheckBox.isSelected());
394        dispatcher.setShortNameInBlock(nameInBlockCheckBox.isSelected());
395        dispatcher.setExtraColorForAllocated(extraColorForAllocatedCheckBox.isSelected());
396        dispatcher.setNameInAllocatedBlock(nameInAllocatedBlockCheckBox.isSelected());
397        dispatcher.setRosterEntryInBlock(rosterInBlockCheckBox.isSelected());
398        dispatcher.setSupportVSDecoder(supportVSDecoderCheckBox.isSelected());
399        dispatcher.setScale((Scale) layoutScaleBox.getSelectedItem());
400        dispatcher.setUseScaleMeters(scaleMeters.isSelected());
401        dispatcher.setMinThrottleInterval((int) minThrottleIntervalSpinner.getValue());
402        dispatcher.setFullRampTime((int) fullRampTimeSpinner.getValue());
403
404        for (LayoutEditor panel : layoutEditorList) {
405            panel.setOpenDispatcherOnLoad(openDispatcherWithPanel.isSelected());
406        }
407
408        dispatcher.setStoppingSpeedName( (String) stoppingSpeedBox.getSelectedItem());
409        optionsFrame.setVisible(false);
410        optionsFrame.dispose(); // prevent this window from being listed in the Window menu.
411        optionsFrame = null;
412        // display save options reminder
413        InstanceManager.getDefault(jmri.UserPreferencesManager.class).
414                showInfoMessage(Bundle.getMessage("ReminderTitle"), Bundle.getMessage("ReminderSaveOptions"),
415                        OptionsMenu.class.getName(),
416                        "remindSaveDispatcherOptions"); // NOI18N
417        initializeMenu();
418    }
419
420    /**
421     * Get the class description for the UserMessagePreferencesPane.
422     * @return The class description
423     */
424    public String getClassDescription() {
425        return Bundle.getMessage("OptionWindowItem");
426    }
427
428    /**
429     * Set the item details for the UserMessagePreferencesPane.
430     */
431    public void setMessagePreferencesDetails() {
432        InstanceManager.getDefault(jmri.UserPreferencesManager.class).
433                setPreferenceItemDetails(OptionsMenu.class.getName(), "remindSaveDispatcherOptions", Bundle.getMessage("HideSaveReminder"));  // NOI18N
434    }
435
436    private void cancelOptions(ActionEvent e) {
437        optionsFrame.setVisible(false);
438        optionsFrame.dispose(); // prevent this window from being listed in the Window menu.
439        optionsFrame = null;
440    }
441
442    /**
443     * Save Dispatcher Option settings from pane to xml file.
444     *
445     * @param e the calling actionevent
446     */
447    private void saveRequested(ActionEvent e) {
448        try {
449            InstanceManager.getDefault(OptionsFile.class).writeDispatcherOptions(dispatcher);
450        } catch (java.io.IOException ioe) {
451            log.error("Exception writing Dispatcher options", ioe);
452        }
453    }
454
455    private void initializeLayoutEditorList() {
456        // get list of Layout Editor panels
457        layoutEditorList = new ArrayList<>(InstanceManager.getDefault(EditorManager.class).getAll(LayoutEditor.class));
458    }
459
460    private void initializeScaleCombo() {
461        layoutScaleBox.removeAllItems();
462        for (Scale scale : ScaleManager.getScales()) {
463            if (scale.getScaleName().equals("CUSTOM")) {  // No custom support yet, don't show.
464                continue;
465            }
466            layoutScaleBox.addItem(scale);
467        }
468        jmri.util.swing.JComboBoxUtil.setupComboBoxMaxRows(layoutScaleBox);
469        layoutScaleBox.setSelectedItem(dispatcher.getScale());
470    }
471
472    private void initializeStoppingSpeedCombo() {
473        stoppingSpeedBox.removeAllItems();
474        Enumeration<String> speedNamesList = jmri.InstanceManager.getDefault(SignalSpeedMap.class).getSpeedIterator();
475        while (speedNamesList.hasMoreElements()) {
476            stoppingSpeedBox.addItem(speedNamesList.nextElement());
477        }
478        stoppingSpeedBox.setSelectedItem(dispatcher.getStoppingSpeedName());
479    }
480
481    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(OptionsMenu.class);
482
483}