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