001package jmri.jmrit.operations.setup;
002
003import java.awt.GridBagLayout;
004import java.awt.event.ActionEvent;
005import java.io.File;
006import java.util.ArrayList;
007import java.util.Arrays;
008import java.util.List;
009
010import javax.swing.*;
011import javax.swing.colorchooser.AbstractColorChooserPanel;
012
013import org.slf4j.Logger;
014import org.slf4j.LoggerFactory;
015
016import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
017import jmri.InstanceManager;
018import jmri.jmrit.operations.trains.TrainManager;
019import jmri.util.FileUtil;
020import jmri.util.swing.FontComboUtil;
021import jmri.util.swing.SplitButtonColorChooserPanel;
022
023/**
024 * Frame for user edit of manifest and switch list print options
025 *
026 * @author Dan Boudreau Copyright (C) 2008, 2010, 2011, 2012, 2013
027 */
028public class PrintOptionPanel extends OperationsPreferencesPanel {
029
030    private static final Logger log = LoggerFactory.getLogger(PrintOptionPanel.class);
031    
032    private String ADD = "+";
033    private String DELETE = "-";
034
035    // labels
036    JLabel logoURL = new JLabel("");
037
038    // major buttons
039    JButton saveButton = new JButton(Bundle.getMessage("ButtonSave"));
040    JButton addLogoButton = new JButton(Bundle.getMessage("AddLogo"));
041    JButton removeLogoButton = new JButton(Bundle.getMessage("RemoveLogo"));
042
043    JButton addEngPickupComboboxButton = new JButton(ADD);
044    JButton deleteEngPickupComboboxButton = new JButton(DELETE);
045    JButton addEngDropComboboxButton = new JButton(ADD);
046    JButton deleteEngDropComboboxButton = new JButton(DELETE);
047    JButton addCarPickupComboboxButton = new JButton(ADD);
048    JButton deleteCarPickupComboboxButton = new JButton(DELETE);
049    JButton addCarDropComboboxButton = new JButton(ADD);
050    JButton deleteCarDropComboboxButton = new JButton(DELETE);
051    JButton addLocalComboboxButton = new JButton(ADD);
052    JButton deleteLocalComboboxButton = new JButton(DELETE);
053    JButton addSwitchListPickupComboboxButton = new JButton(ADD);
054    JButton deleteSwitchListPickupComboboxButton = new JButton(DELETE);
055    JButton addSwitchListDropComboboxButton = new JButton(ADD);
056    JButton deleteSwitchListDropComboboxButton = new JButton(DELETE);
057    JButton addSwitchListLocalComboboxButton = new JButton(ADD);
058    JButton deleteSwitchListLocalComboboxButton = new JButton(DELETE);
059
060    // check boxes
061    JCheckBox tabFormatCheckBox = new JCheckBox(Bundle.getMessage("TabFormat"));
062    JCheckBox formatSwitchListCheckBox = new JCheckBox(Bundle.getMessage("SameAsManifest"));
063    JCheckBox editManifestCheckBox = new JCheckBox(Bundle.getMessage("UseTextEditor"));
064    JCheckBox printLocCommentsCheckBox = new JCheckBox(Bundle.getMessage("PrintLocationComments"));
065    JCheckBox printRouteCommentsCheckBox = new JCheckBox(Bundle.getMessage("PrintRouteComments"));
066    JCheckBox printLoadsEmptiesCheckBox = new JCheckBox(Bundle.getMessage("PrintLoadsEmpties"));
067    JCheckBox printCabooseLoadCheckBox = new JCheckBox(Bundle.getMessage("PrintCabooseLoad"));
068    JCheckBox printPassengerLoadCheckBox = new JCheckBox(Bundle.getMessage("PrintPassengerLoad"));
069    JCheckBox printTrainScheduleNameCheckBox = new JCheckBox(Bundle.getMessage("PrintTrainScheduleName"));
070    JCheckBox use12hrFormatCheckBox = new JCheckBox(Bundle.getMessage("12hrFormat"));
071    JCheckBox printValidCheckBox = new JCheckBox(Bundle.getMessage("PrintValid"));
072    JCheckBox sortByTrackCheckBox = new JCheckBox(Bundle.getMessage("SortByTrack"));
073    JCheckBox printHeadersCheckBox = new JCheckBox(Bundle.getMessage("PrintHeaders"));
074    JCheckBox truncateCheckBox = new JCheckBox(Bundle.getMessage("Truncate"));
075    JCheckBox departureTimeCheckBox = new JCheckBox(Bundle.getMessage("DepartureTime"));
076    JCheckBox trackSummaryCheckBox = new JCheckBox(Bundle.getMessage("TrackSummary"));
077    JCheckBox routeLocationCheckBox = new JCheckBox(Bundle.getMessage("RouteLocation"));
078
079    // text field
080    JTextField pickupEngPrefix = new JTextField(10);
081    JTextField dropEngPrefix = new JTextField(10);
082    JTextField pickupCarPrefix = new JTextField(10);
083    JTextField dropCarPrefix = new JTextField(10);
084    JTextField localPrefix = new JTextField(10);
085    JTextField switchListPickupCarPrefix = new JTextField(10);
086    JTextField switchListDropCarPrefix = new JTextField(10);
087    JTextField switchListLocalPrefix = new JTextField(10);
088    JTextField hazardousTextField = new JTextField(20);
089
090    // text area
091    JTextArea commentTextArea = new JTextArea(2, 90);
092
093    JScrollPane commentScroller = new JScrollPane(commentTextArea,
094            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
095
096    // combo boxes
097    JComboBox<String> fontComboBox = new JComboBox<>();
098    JComboBox<String> manifestFormatComboBox = Setup.getManifestFormatComboBox();
099    JComboBox<String> manifestOrientationComboBox = Setup.getOrientationComboBox();
100    JComboBox<Integer> fontSizeComboBox = new JComboBox<>();
101    private JColorChooser pickupColorChooser = null;
102    private JColorChooser dropColorChooser = null;
103    private JColorChooser localColorChooser = null;
104    JComboBox<String> switchListOrientationComboBox = Setup.getOrientationComboBox();
105
106    // message formats
107    List<JComboBox<String>> enginePickupMessageList = new ArrayList<>();
108    List<JComboBox<String>> engineDropMessageList = new ArrayList<>();
109    List<JComboBox<String>> carPickupMessageList = new ArrayList<>();
110    List<JComboBox<String>> carDropMessageList = new ArrayList<>();
111    List<JComboBox<String>> localMessageList = new ArrayList<>();
112    List<JComboBox<String>> switchListCarPickupMessageList = new ArrayList<>();
113    List<JComboBox<String>> switchListCarDropMessageList = new ArrayList<>();
114    List<JComboBox<String>> switchListLocalMessageList = new ArrayList<>();
115
116    // manifest panels
117    JPanel pManifest = new JPanel();
118    JPanel pEngPickup = new JPanel();
119    JPanel pEngDrop = new JPanel();
120    JPanel pPickup = new JPanel();
121    JPanel pDrop = new JPanel();
122    JPanel pLocal = new JPanel();
123
124    // switch list panels
125    JPanel pSwitchListOrientation = new JPanel();
126    JPanel pSwPickup = new JPanel();
127    JPanel pSwDrop = new JPanel();
128    JPanel pSwLocal = new JPanel();
129
130    public PrintOptionPanel() {
131
132        // the following code sets the frame's initial state
133        // add tool tips
134        saveButton.setToolTipText(Bundle.getMessage("SaveToolTip"));
135        addLogoButton.setToolTipText(Bundle.getMessage("AddLogoToolTip"));
136        removeLogoButton.setToolTipText(Bundle.getMessage("RemoveLogoToolTip"));
137        tabFormatCheckBox.setToolTipText(Bundle.getMessage("TabComment"));
138        printLocCommentsCheckBox.setToolTipText(Bundle.getMessage("AddLocationComments"));
139        printRouteCommentsCheckBox.setToolTipText(Bundle.getMessage("AddRouteComments"));
140        printLoadsEmptiesCheckBox.setToolTipText(Bundle.getMessage("LoadsEmptiesComment"));
141        printCabooseLoadCheckBox.setToolTipText(Bundle.getMessage("CabooseLoadTip"));
142        printPassengerLoadCheckBox.setToolTipText(Bundle.getMessage("PassengerLoadTip"));
143        printTrainScheduleNameCheckBox.setToolTipText(Bundle.getMessage("ShowTrainScheduleTip"));
144        use12hrFormatCheckBox.setToolTipText(Bundle.getMessage("Use12hrFormatTip"));
145        printValidCheckBox.setToolTipText(Bundle.getMessage("PrintValidTip"));
146        sortByTrackCheckBox.setToolTipText(Bundle.getMessage("SortByTrackTip"));
147        printHeadersCheckBox.setToolTipText(Bundle.getMessage("PrintHeadersTip"));
148        truncateCheckBox.setToolTipText(Bundle.getMessage("TruncateTip"));
149        departureTimeCheckBox.setToolTipText(Bundle.getMessage("DepartureTimeTip"));
150        routeLocationCheckBox.setToolTipText(Bundle.getMessage("RouteLocationTip"));
151        editManifestCheckBox.setToolTipText(Bundle.getMessage("UseTextEditorTip"));
152        trackSummaryCheckBox.setToolTipText(Bundle.getMessage("TrackSummaryTip"));
153
154        addEngPickupComboboxButton.setToolTipText(Bundle.getMessage("AddMessageComboboxTip"));
155        deleteEngPickupComboboxButton.setToolTipText(Bundle.getMessage("DeleteMessageComboboxTip"));
156        addEngDropComboboxButton.setToolTipText(Bundle.getMessage("AddMessageComboboxTip"));
157        deleteEngDropComboboxButton.setToolTipText(Bundle.getMessage("DeleteMessageComboboxTip"));
158
159        addCarPickupComboboxButton.setToolTipText(Bundle.getMessage("AddMessageComboboxTip"));
160        deleteCarPickupComboboxButton.setToolTipText(Bundle.getMessage("DeleteMessageComboboxTip"));
161        addCarDropComboboxButton.setToolTipText(Bundle.getMessage("AddMessageComboboxTip"));
162        deleteCarDropComboboxButton.setToolTipText(Bundle.getMessage("DeleteMessageComboboxTip"));
163        addLocalComboboxButton.setToolTipText(Bundle.getMessage("AddMessageComboboxTip"));
164        deleteLocalComboboxButton.setToolTipText(Bundle.getMessage("DeleteMessageComboboxTip"));
165
166        addSwitchListPickupComboboxButton.setToolTipText(Bundle.getMessage("AddMessageComboboxTip"));
167        deleteSwitchListPickupComboboxButton.setToolTipText(Bundle
168                .getMessage("DeleteMessageComboboxTip"));
169        addSwitchListDropComboboxButton.setToolTipText(Bundle.getMessage("AddMessageComboboxTip"));
170        deleteSwitchListDropComboboxButton.setToolTipText(Bundle.getMessage("DeleteMessageComboboxTip"));
171        addSwitchListLocalComboboxButton.setToolTipText(Bundle.getMessage("AddMessageComboboxTip"));
172        deleteSwitchListLocalComboboxButton
173                .setToolTipText(Bundle.getMessage("DeleteMessageComboboxTip"));
174
175        // Manifest panel
176        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
177        pManifest.setLayout(new BoxLayout(pManifest, BoxLayout.Y_AXIS));
178        JScrollPane pManifestPane = new JScrollPane(pManifest);
179        pManifestPane.setBorder(BorderFactory.createTitledBorder(""));
180
181        // row 1 font type and size
182        JPanel p1 = new JPanel();
183        p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
184
185        JPanel pFont = new JPanel();
186        pFont.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutFont")));
187        pFont.add(fontComboBox);
188
189        JPanel pFontSize = new JPanel();
190        pFontSize.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutFontSize")));
191        pFontSize.add(fontSizeComboBox);
192
193        JPanel pFormat = new JPanel();
194        pFormat.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutFormat")));
195        pFormat.add(tabFormatCheckBox);
196        pFormat.add(manifestFormatComboBox);
197
198        manifestFormatComboBox.setSelectedItem(Setup.getManifestFormat());
199
200        JPanel pOrientation = new JPanel();
201        pOrientation.setBorder(BorderFactory.createTitledBorder(Bundle
202                .getMessage("BorderLayoutOrientation")));
203        pOrientation.add(manifestOrientationComboBox);
204
205        JPanel pPickupColor = new JPanel();
206        pPickupColor.setBorder(BorderFactory.createTitledBorder(Bundle
207                .getMessage("BorderLayoutPickupColor")));
208        pickupColorChooser = new JColorChooser(Setup.getPickupColor());
209        AbstractColorChooserPanel pickupColorPanels[] = {new SplitButtonColorChooserPanel()};
210        pickupColorChooser.setChooserPanels(pickupColorPanels);
211        pickupColorChooser.setPreviewPanel(new JPanel());
212        pPickupColor.add(pickupColorChooser);
213
214        JPanel pDropColor = new JPanel();
215        pDropColor.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutDropColor")));
216        dropColorChooser = new JColorChooser(Setup.getDropColor());
217        AbstractColorChooserPanel dropColorPanels[] = {new SplitButtonColorChooserPanel()};
218        dropColorChooser.setChooserPanels(dropColorPanels);
219        dropColorChooser.setPreviewPanel(new JPanel());
220        pDropColor.add(dropColorChooser);
221
222        JPanel pLocalColor = new JPanel();
223        pLocalColor.setBorder(BorderFactory.createTitledBorder(Bundle
224                .getMessage("BorderLayoutLocalColor")));
225        localColorChooser = new JColorChooser(Setup.getLocalColor());
226        AbstractColorChooserPanel localColorPanels[] = {new SplitButtonColorChooserPanel()};
227        localColorChooser.setChooserPanels(localColorPanels);
228        localColorChooser.setPreviewPanel(new JPanel());
229        pLocalColor.add(localColorChooser);
230
231        p1.add(pFont);
232        p1.add(pFontSize);
233        p1.add(pFormat);
234        p1.add(pOrientation);
235        p1.add(pPickupColor);
236        p1.add(pDropColor);
237        p1.add(pLocalColor);
238
239        // load all of the message combo boxes
240        loadFormatComboBox();
241
242        // Optional Switch List Panel
243        JPanel pSl = new JPanel();
244        pSl.setLayout(new BoxLayout(pSl, BoxLayout.X_AXIS));
245
246        JPanel pSwitchFormat = new JPanel();
247        pSwitchFormat.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutSwitchListFormat")));
248        pSwitchFormat.add(formatSwitchListCheckBox);
249
250        pSwitchListOrientation.setBorder(BorderFactory.createTitledBorder(Bundle
251                .getMessage("BorderLayoutSwitchListOrientation")));
252        pSwitchListOrientation.add(switchListOrientationComboBox);
253        
254
255        pSl.add(pSwitchFormat);
256        pSl.add(pSwitchListOrientation);
257
258        JPanel pM = new JPanel();
259        pM.setLayout(new BoxLayout(pM, BoxLayout.X_AXIS));
260        
261        // Switch List options
262        JPanel pSwitchOptions = new JPanel();
263        pSwitchOptions.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutSwitchListOptions")));
264        pSwitchOptions.add(trackSummaryCheckBox);
265        pSwitchOptions.add(routeLocationCheckBox);
266
267        // Manifest options
268        JPanel pManifestOptions = new JPanel();
269        pManifestOptions.setBorder(BorderFactory.createTitledBorder(Bundle
270                .getMessage("BorderLayoutManifestOptions")));
271        pManifestOptions.add(printLocCommentsCheckBox);
272        pManifestOptions.add(printRouteCommentsCheckBox);
273        pManifestOptions.add(departureTimeCheckBox);
274        pManifestOptions.add(truncateCheckBox);
275        
276        pM.add(pSwitchOptions);
277        pM.add(pManifestOptions);
278
279        // Manifest and Switch List options
280        JPanel pManifestSwtichListOptions = new JPanel();
281        pManifestSwtichListOptions.setBorder(BorderFactory.createTitledBorder(Bundle
282                .getMessage("BorderLayoutManifestSwitchListOptions")));
283        pManifestSwtichListOptions.add(printValidCheckBox);
284        pManifestSwtichListOptions.add(printLoadsEmptiesCheckBox);
285        pManifestSwtichListOptions.add(printCabooseLoadCheckBox);
286        pManifestSwtichListOptions.add(printPassengerLoadCheckBox);
287        pManifestSwtichListOptions.add(use12hrFormatCheckBox);
288        pManifestSwtichListOptions.add(printTrainScheduleNameCheckBox);
289        pManifestSwtichListOptions.add(sortByTrackCheckBox);
290        pManifestSwtichListOptions.add(printHeadersCheckBox);
291
292        JPanel p2 = new JPanel();
293        p2.setLayout(new BoxLayout(p2, BoxLayout.X_AXIS));
294
295        // Use text editor for manifest
296        JPanel pEdit = new JPanel();
297        pEdit.setBorder(BorderFactory.createTitledBorder(Bundle
298                .getMessage("BorderLayoutManifestPreview")));
299        pEdit.add(editManifestCheckBox);
300
301        // manifest logo
302        JPanel pLogo = new JPanel();
303        pLogo.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutLogo")));
304        pLogo.add(removeLogoButton);
305        pLogo.add(addLogoButton);
306        pLogo.add(logoURL);
307
308        p2.add(pEdit);
309        p2.add(pLogo);
310
311        // comments
312        JPanel pComments = new JPanel();
313        pComments.setLayout(new BoxLayout(pComments, BoxLayout.X_AXIS));
314
315        // missing cars comment
316        JPanel pComment = new JPanel();
317        pComment.setLayout(new GridBagLayout());
318        pComment.setBorder(BorderFactory.createTitledBorder(Bundle
319                .getMessage("BorderLayoutCommentOptions")));
320        addItem(pComment, commentScroller, 0, 0);
321
322        // Hazardous comment
323        JPanel pHazardous = new JPanel();
324        pHazardous
325                .setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutHazardous")));
326        pHazardous.add(hazardousTextField);
327
328        pComments.add(pComment);
329        pComments.add(pHazardous);
330
331        pManifest.add(p1);
332        pManifest.add(pEngPickup);
333        pManifest.add(pEngDrop);
334        pManifest.add(pPickup);
335        pManifest.add(pDrop);
336        pManifest.add(pLocal);
337        pManifest.add(pSl);
338        pManifest.add(pSwPickup);
339        pManifest.add(pSwDrop);
340        pManifest.add(pSwLocal);
341        pManifest.add(pM);
342        pManifest.add(pManifestSwtichListOptions);
343        pManifest.add(p2);
344        pManifest.add(pComments);
345
346        // row 11
347        JPanel pControl = new JPanel();
348        pControl.setBorder(BorderFactory.createTitledBorder(""));
349        pControl.setLayout(new GridBagLayout());
350        addItem(pControl, saveButton, 0, 0);
351
352        add(pManifestPane);
353        add(pControl);
354
355        manifestOrientationComboBox.setSelectedItem(Setup.getManifestOrientation());
356        switchListOrientationComboBox.setSelectedItem(Setup.getSwitchListOrientation());
357
358        tabFormatCheckBox.setSelected(Setup.isTabEnabled());
359        formatSwitchListCheckBox.setSelected(Setup.isSwitchListFormatSameAsManifest());
360        printLocCommentsCheckBox.setSelected(Setup.isPrintLocationCommentsEnabled());
361        printRouteCommentsCheckBox.setSelected(Setup.isPrintRouteCommentsEnabled());
362        printLoadsEmptiesCheckBox.setSelected(Setup.isPrintLoadsAndEmptiesEnabled());
363        printCabooseLoadCheckBox.setSelected(Setup.isPrintCabooseLoadEnabled());
364        printPassengerLoadCheckBox.setSelected(Setup.isPrintPassengerLoadEnabled());
365        printTrainScheduleNameCheckBox.setSelected(Setup.isPrintTrainScheduleNameEnabled());
366        use12hrFormatCheckBox.setSelected(Setup.is12hrFormatEnabled());
367        printValidCheckBox.setSelected(Setup.isPrintValidEnabled());
368        sortByTrackCheckBox.setSelected(Setup.isSortByTrackNameEnabled());
369        printHeadersCheckBox.setSelected(Setup.isPrintHeadersEnabled());
370        truncateCheckBox.setSelected(Setup.isTruncateManifestEnabled());
371        departureTimeCheckBox.setSelected(Setup.isUseDepartureTimeEnabled());
372        trackSummaryCheckBox.setSelected(Setup.isTrackSummaryEnabled());
373        trackSummaryCheckBox.setEnabled(Setup.isSwitchListRealTime());
374        routeLocationCheckBox.setSelected(Setup.isSwitchListRouteLocationCommentEnabled());
375        editManifestCheckBox.setSelected(Setup.isManifestEditorEnabled());
376
377        hazardousTextField.setText(Setup.getHazardousMsg());
378
379        setSwitchListVisible(!formatSwitchListCheckBox.isSelected());
380
381        updateLogoButtons();
382        dropColorChooser.setColor(Setup.getDropColor());
383        pickupColorChooser.setColor(Setup.getPickupColor());
384        localColorChooser.setColor(Setup.getLocalColor());
385
386        commentTextArea.setText(Setup.getMiaComment());
387
388        // load font sizes 7 through 18
389        for (int i = 7; i < 19; i++) {
390            fontSizeComboBox.addItem(i);
391        }
392        fontSizeComboBox.setSelectedItem(Setup.getManifestFontSize());
393        loadFontComboBox();
394
395        // setup buttons
396        addButtonAction(addLogoButton);
397        addButtonAction(removeLogoButton);
398        addButtonAction(saveButton);
399
400        addButtonAction(addEngPickupComboboxButton);
401        addButtonAction(deleteEngPickupComboboxButton);
402        addButtonAction(addEngDropComboboxButton);
403        addButtonAction(deleteEngDropComboboxButton);
404
405        addButtonAction(addCarPickupComboboxButton);
406        addButtonAction(deleteCarPickupComboboxButton);
407        addButtonAction(addCarDropComboboxButton);
408        addButtonAction(deleteCarDropComboboxButton);
409        addButtonAction(addLocalComboboxButton);
410        addButtonAction(deleteLocalComboboxButton);
411
412        addButtonAction(addSwitchListPickupComboboxButton);
413        addButtonAction(deleteSwitchListPickupComboboxButton);
414        addButtonAction(addSwitchListDropComboboxButton);
415        addButtonAction(deleteSwitchListDropComboboxButton);
416        addButtonAction(addSwitchListLocalComboboxButton);
417        addButtonAction(deleteSwitchListLocalComboboxButton);
418
419        addCheckBoxAction(tabFormatCheckBox);
420        addCheckBoxAction(formatSwitchListCheckBox);
421        addCheckBoxAction(truncateCheckBox);
422
423        addComboBoxAction(manifestFormatComboBox);
424
425        initMinimumSize();
426    }
427
428    // Add Remove Logo and Save buttons
429    @Override
430    public void buttonActionPerformed(java.awt.event.ActionEvent ae) {
431        if (ae.getSource() == addLogoButton) {
432            log.debug("add logo button pressed");
433            File f = selectFile();
434            if (f != null) {
435                Setup.setManifestLogoURL(FileUtil.getPortableFilename(f));
436            }
437            updateLogoButtons();
438        }
439        if (ae.getSource() == removeLogoButton) {
440            log.debug("remove logo button pressed");
441            Setup.setManifestLogoURL("");
442            updateLogoButtons();
443        }
444        // add or delete message comboBox
445        if (ae.getSource() == addEngPickupComboboxButton) {
446            addComboBox(pEngPickup, enginePickupMessageList, Setup.getEngineMessageComboBox());
447        }
448        if (ae.getSource() == deleteEngPickupComboboxButton) {
449            removeComboBox(pEngPickup, enginePickupMessageList);
450        }
451        if (ae.getSource() == addEngDropComboboxButton) {
452            addComboBox(pEngDrop, engineDropMessageList, Setup.getEngineMessageComboBox());
453        }
454        if (ae.getSource() == deleteEngDropComboboxButton) {
455            removeComboBox(pEngDrop, engineDropMessageList);
456        }
457
458        if (ae.getSource() == addCarPickupComboboxButton) {
459            addComboBox(pPickup, carPickupMessageList, Setup.getCarMessageComboBox());
460        }
461        if (ae.getSource() == deleteCarPickupComboboxButton) {
462            removeComboBox(pPickup, carPickupMessageList);
463        }
464        if (ae.getSource() == addCarDropComboboxButton) {
465            addComboBox(pDrop, carDropMessageList, Setup.getCarMessageComboBox());
466        }
467        if (ae.getSource() == deleteCarDropComboboxButton) {
468            removeComboBox(pDrop, carDropMessageList);
469        }
470
471        if (ae.getSource() == addLocalComboboxButton) {
472            addComboBox(pLocal, localMessageList, Setup.getCarMessageComboBox());
473        }
474        if (ae.getSource() == deleteLocalComboboxButton) {
475            removeComboBox(pLocal, localMessageList);
476        }
477
478        if (ae.getSource() == addSwitchListPickupComboboxButton) {
479            addComboBox(pSwPickup, switchListCarPickupMessageList, Setup.getCarMessageComboBox());
480        }
481        if (ae.getSource() == deleteSwitchListPickupComboboxButton) {
482            removeComboBox(pSwPickup, switchListCarPickupMessageList);
483        }
484        if (ae.getSource() == addSwitchListDropComboboxButton) {
485            addComboBox(pSwDrop, switchListCarDropMessageList, Setup.getCarMessageComboBox());
486        }
487        if (ae.getSource() == deleteSwitchListDropComboboxButton) {
488            removeComboBox(pSwDrop, switchListCarDropMessageList);
489        }
490
491        if (ae.getSource() == addSwitchListLocalComboboxButton) {
492            addComboBox(pSwLocal, switchListLocalMessageList, Setup.getCarMessageComboBox());
493        }
494        if (ae.getSource() == deleteSwitchListLocalComboboxButton) {
495            removeComboBox(pSwLocal, switchListLocalMessageList);
496        }
497
498        if (ae.getSource() == saveButton) {
499            this.savePreferences();
500            if (Setup.isCloseWindowOnSaveEnabled()) {
501                dispose();
502            }
503        }
504    }
505
506    @Override
507    @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE",
508            justification = "checks for instance of PrintOptionFrame") // NOI18N
509    public void checkBoxActionPerformed(ActionEvent ae) {
510        if (ae.getSource() == tabFormatCheckBox) {
511            loadFontComboBox();
512        }
513        if (ae.getSource() == formatSwitchListCheckBox) {
514            log.debug("Switch list check box activated");
515            setSwitchListVisible(!formatSwitchListCheckBox.isSelected());
516            setPreferredSize(null);
517            if (this.getTopLevelAncestor() instanceof PrintOptionFrame) {
518                ((PrintOptionFrame) this.getTopLevelAncestor()).pack();
519            }
520        }
521        if (ae.getSource() == truncateCheckBox && truncateCheckBox.isSelected()) {
522            if (JOptionPane.showConfirmDialog(this, Bundle.getMessage("EnableTruncateWarning"),
523                    Bundle.getMessage("TruncateManifests?"),
524                    JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
525                truncateCheckBox.setSelected(false);
526            }
527        }
528    }
529
530    @Override
531    public void comboBoxActionPerformed(ActionEvent ae) {
532        if (ae.getSource() == manifestFormatComboBox) {
533            loadFontComboBox();
534        }
535    }
536
537    private void setSwitchListVisible(boolean b) {
538        pSwitchListOrientation.setVisible(b);
539        pSwPickup.setVisible(b);
540        pSwDrop.setVisible(b);
541        pSwLocal.setVisible(b);
542    }
543
544    /**
545     * We always use the same file chooser in this class, so that the user's
546     * last-accessed directory remains available.
547     */
548    JFileChooser fc = jmri.jmrit.XmlFile.userFileChooser(Bundle.getMessage("Images"));
549
550    private File selectFile() {
551        if (fc == null) {
552            log.error("Could not find user directory");
553        } else {
554            fc.setDialogTitle(Bundle.getMessage("FindDesiredImage"));
555            // when reusing the chooser, make sure new files are included
556            fc.rescanCurrentDirectory();
557            int retVal = fc.showOpenDialog(null);
558            // handle selection or cancel
559            if (retVal == JFileChooser.APPROVE_OPTION) {
560                return fc.getSelectedFile();
561            }
562        }
563        return null;
564    }
565
566    @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE",
567            justification = "checks for instance of PrintOptionFrame") // NOI18N
568    private void updateLogoButtons() {
569        boolean flag = Setup.getManifestLogoURL().equals(Setup.NONE);
570        addLogoButton.setVisible(flag);
571        removeLogoButton.setVisible(!flag);
572        logoURL.setText(Setup.getManifestLogoURL());
573        if (this.getTopLevelAncestor() instanceof PrintOptionFrame) {
574            ((PrintOptionFrame) this.getTopLevelAncestor()).pack();
575        }
576    }
577
578    private void addComboBox(JPanel panel, List<JComboBox<String>> list, JComboBox<String> box) {
579        list.add(box);
580        panel.add(box, list.size());
581        panel.revalidate();
582        pManifest.revalidate();
583    }
584
585    private void removeComboBox(JPanel panel, List<JComboBox<String>> list) {
586        for (int i = 0; i < list.size(); i++) {
587            JComboBox<String> cb = list.get(i);
588            if (cb.getSelectedItem().equals(Setup.BLANK)) {
589                list.remove(i);
590                panel.remove(cb);
591                panel.revalidate();
592                pManifest.revalidate();
593                return;
594            }
595        }
596    }
597
598    private void loadFormatComboBox() {
599        // loco pick up message format
600        pEngPickup.removeAll();
601        enginePickupMessageList.clear();
602        pEngPickup.setBorder(BorderFactory.createTitledBorder(Bundle
603                .getMessage("BorderLayoutPickupEngine")));
604        pEngPickup.add(pickupEngPrefix);
605        pickupEngPrefix.setText(Setup.getPickupEnginePrefix());
606        String[] format = Setup.getPickupEngineMessageFormat();
607        for (String f : format) {
608            JComboBox<String> cb = Setup.getEngineMessageComboBox();
609            cb.setSelectedItem(f);
610            pEngPickup.add(cb);
611            enginePickupMessageList.add(cb);
612        }
613        pEngPickup.add(addEngPickupComboboxButton);
614        pEngPickup.add(deleteEngPickupComboboxButton);
615        pEngPickup.revalidate();
616
617        // loco set out message format
618        pEngDrop.removeAll();
619        engineDropMessageList.clear();
620        pEngDrop.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutDropEngine")));
621        pEngDrop.add(dropEngPrefix);
622        dropEngPrefix.setText(Setup.getDropEnginePrefix());
623        format = Setup.getDropEngineMessageFormat();
624        for (String f : format) {
625            JComboBox<String> cb = Setup.getEngineMessageComboBox();
626            cb.setSelectedItem(f);
627            pEngDrop.add(cb);
628            engineDropMessageList.add(cb);
629        }
630        pEngDrop.add(addEngDropComboboxButton);
631        pEngDrop.add(deleteEngDropComboboxButton);
632        pEngDrop.revalidate();
633
634        // car pickup message format
635        pPickup.removeAll();
636        carPickupMessageList.clear();
637        pPickup.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutPickupCar")));
638        pPickup.add(pickupCarPrefix);
639        pickupCarPrefix.setText(Setup.getPickupCarPrefix());
640        String[] pickFormat = Setup.getPickupManifestMessageFormat();
641        for (String pf : pickFormat) {
642            JComboBox<String> cb = Setup.getCarMessageComboBox();
643            cb.setSelectedItem(pf);
644            pPickup.add(cb);
645            carPickupMessageList.add(cb);
646        }
647        pPickup.add(addCarPickupComboboxButton);
648        pPickup.add(deleteCarPickupComboboxButton);
649        pPickup.revalidate();
650
651        // car drop message format
652        pDrop.removeAll();
653        carDropMessageList.clear();
654        pDrop.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutDropCar")));
655        pDrop.add(dropCarPrefix);
656        dropCarPrefix.setText(Setup.getDropCarPrefix());
657        String[] dropFormat = Setup.getDropManifestMessageFormat();
658        for (String lf : dropFormat) {
659            JComboBox<String> cb = Setup.getCarMessageComboBox();
660            cb.setSelectedItem(lf);
661            pDrop.add(cb);
662            carDropMessageList.add(cb);
663        }
664        pDrop.add(addCarDropComboboxButton);
665        pDrop.add(deleteCarDropComboboxButton);
666        pDrop.revalidate();
667
668        // local car move message format
669        pLocal.removeAll();
670        localMessageList.clear();
671        pLocal.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BorderLayoutLocal")));
672        pLocal.add(localPrefix);
673        localPrefix.setText(Setup.getLocalPrefix());
674        String[] localFormat = Setup.getLocalManifestMessageFormat();
675        for (String lf : localFormat) {
676            JComboBox<String> cb = Setup.getCarMessageComboBox();
677            cb.setSelectedItem(lf);
678            pLocal.add(cb);
679            localMessageList.add(cb);
680        }
681        pLocal.add(addLocalComboboxButton);
682        pLocal.add(deleteLocalComboboxButton);
683        pLocal.revalidate();
684
685        // switch list car pickup message format
686        pSwPickup.removeAll();
687        switchListCarPickupMessageList.clear();
688        pSwPickup.setBorder(BorderFactory.createTitledBorder(Bundle
689                .getMessage("BorderLayoutSwitchListPickupCar")));
690        pSwPickup.add(switchListPickupCarPrefix);
691        switchListPickupCarPrefix.setText(Setup.getSwitchListPickupCarPrefix());
692        pickFormat = Setup.getPickupSwitchListMessageFormat();
693        for (String pf : pickFormat) {
694            JComboBox<String> cb = Setup.getCarMessageComboBox();
695            cb.setSelectedItem(pf);
696            pSwPickup.add(cb);
697            switchListCarPickupMessageList.add(cb);
698        }
699        pSwPickup.add(addSwitchListPickupComboboxButton);
700        pSwPickup.add(deleteSwitchListPickupComboboxButton);
701
702        // switch list car drop message format
703        pSwDrop.removeAll();
704        switchListCarDropMessageList.clear();
705        pSwDrop.setBorder(BorderFactory.createTitledBorder(Bundle
706                .getMessage("BorderLayoutSwitchListDropCar")));
707        pSwDrop.add(switchListDropCarPrefix);
708        switchListDropCarPrefix.setText(Setup.getSwitchListDropCarPrefix());
709        dropFormat = Setup.getDropSwitchListMessageFormat();
710        for (String df : dropFormat) {
711            JComboBox<String> cb = Setup.getCarMessageComboBox();
712            cb.setSelectedItem(df);
713            pSwDrop.add(cb);
714            switchListCarDropMessageList.add(cb);
715        }
716        pSwDrop.add(addSwitchListDropComboboxButton);
717        pSwDrop.add(deleteSwitchListDropComboboxButton);
718
719        // switch list local car move message format
720        pSwLocal.removeAll();
721        switchListLocalMessageList.clear();
722        pSwLocal.setBorder(BorderFactory.createTitledBorder(Bundle
723                .getMessage("BorderLayoutSwitchListLocal")));
724        pSwLocal.add(switchListLocalPrefix);
725        switchListLocalPrefix.setText(Setup.getSwitchListLocalPrefix());
726        localFormat = Setup.getLocalSwitchListMessageFormat();
727        for (String lf : localFormat) {
728            JComboBox<String> cb = Setup.getCarMessageComboBox();
729            cb.setSelectedItem(lf);
730            pSwLocal.add(cb);
731            switchListLocalMessageList.add(cb);
732        }
733        pSwLocal.add(addSwitchListLocalComboboxButton);
734        pSwLocal.add(deleteSwitchListLocalComboboxButton);
735    }
736
737    private void loadFontComboBox() {
738        fontComboBox.removeAllItems();
739        List<String> fonts = FontComboUtil.getFonts(FontComboUtil.ALL);
740        if (tabFormatCheckBox.isSelected() || !manifestFormatComboBox.getSelectedItem().equals(Setup.STANDARD_FORMAT)) {
741            fonts = FontComboUtil.getFonts(FontComboUtil.MONOSPACED);
742        }
743        for (String font : fonts) {
744            fontComboBox.addItem(font);
745        }
746        fontComboBox.setSelectedItem(Setup.getFontName());
747    }
748
749    @Override
750    public String getTabbedPreferencesTitle() {
751        return Bundle.getMessage("TitlePrintOptions");
752    }
753
754    @Override
755    public String getPreferencesTooltip() {
756        return null;
757    }
758
759    @Override
760    public void savePreferences() {
761        // font name
762        Setup.setFontName((String) fontComboBox.getSelectedItem());
763        // font size
764        Setup.setManifestFontSize((Integer) fontSizeComboBox.getSelectedItem());
765        // page orientation
766        Setup.setManifestOrientation((String) manifestOrientationComboBox.getSelectedItem());
767        Setup.setSwitchListOrientation((String) switchListOrientationComboBox.getSelectedItem());
768        // format
769        Setup.setManifestFormat((String) manifestFormatComboBox.getSelectedItem());
770        // drop and pick up color option
771        Setup.setDropColor(dropColorChooser.getColor());
772        Setup.setPickupColor(pickupColorChooser.getColor());
773        Setup.setLocalColor(localColorChooser.getColor());
774        // save engine pick up message format
775        Setup.setPickupEnginePrefix(pickupEngPrefix.getText());
776        String[] format = new String[enginePickupMessageList.size()];
777        for (int i = 0; i < enginePickupMessageList.size(); i++) {
778            JComboBox<?> cb = enginePickupMessageList.get(i);
779            format[i] = (String) cb.getSelectedItem();
780        }
781        Setup.setPickupEngineMessageFormat(format);
782        // save engine drop message format
783        Setup.setDropEnginePrefix(dropEngPrefix.getText());
784        format = new String[engineDropMessageList.size()];
785        for (int i = 0; i < engineDropMessageList.size(); i++) {
786            JComboBox<?> cb = engineDropMessageList.get(i);
787            format[i] = (String) cb.getSelectedItem();
788        }
789        Setup.setDropEngineMessageFormat(format);
790        // save car pick up message format
791        Setup.setPickupCarPrefix(pickupCarPrefix.getText());
792        format = new String[carPickupMessageList.size()];
793        for (int i = 0; i < carPickupMessageList.size(); i++) {
794            JComboBox<?> cb = carPickupMessageList.get(i);
795            format[i] = (String) cb.getSelectedItem();
796        }
797        Setup.setPickupManifestMessageFormat(format);
798        // save car drop message format
799        Setup.setDropCarPrefix(dropCarPrefix.getText());
800        format = new String[carDropMessageList.size()];
801        for (int i = 0; i < carDropMessageList.size(); i++) {
802            JComboBox<?> cb = carDropMessageList.get(i);
803            format[i] = (String) cb.getSelectedItem();
804        }
805        Setup.setDropManifestMessageFormat(format);
806        // save local message format
807        Setup.setLocalPrefix(localPrefix.getText());
808        format = new String[localMessageList.size()];
809        for (int i = 0; i < localMessageList.size(); i++) {
810            JComboBox<?> cb = localMessageList.get(i);
811            format[i] = (String) cb.getSelectedItem();
812        }
813        Setup.setLocalManifestMessageFormat(format);
814        // save switch list car pick up message format
815        Setup.setSwitchListPickupCarPrefix(switchListPickupCarPrefix.getText());
816        format = new String[switchListCarPickupMessageList.size()];
817        for (int i = 0; i < switchListCarPickupMessageList.size(); i++) {
818            JComboBox<?> cb = switchListCarPickupMessageList.get(i);
819            format[i] = (String) cb.getSelectedItem();
820        }
821        Setup.setPickupSwitchListMessageFormat(format);
822        // save switch list car drop message format
823        Setup.setSwitchListDropCarPrefix(switchListDropCarPrefix.getText());
824        format = new String[switchListCarDropMessageList.size()];
825        for (int i = 0; i < switchListCarDropMessageList.size(); i++) {
826            JComboBox<?> cb = switchListCarDropMessageList.get(i);
827            format[i] = (String) cb.getSelectedItem();
828        }
829        Setup.setDropSwitchListMessageFormat(format);
830        // save switch list local message format
831        Setup.setSwitchListLocalPrefix(switchListLocalPrefix.getText());
832        format = new String[switchListLocalMessageList.size()];
833        for (int i = 0; i < switchListLocalMessageList.size(); i++) {
834            JComboBox<?> cb = switchListLocalMessageList.get(i);
835            format[i] = (String) cb.getSelectedItem();
836        }
837        Setup.setLocalSwitchListMessageFormat(format);
838        // hazardous comment
839        Setup.setHazardousMsg(hazardousTextField.getText());
840        // misplaced car comment
841        Setup.setMiaComment(commentTextArea.getText());
842        Setup.setSwitchListFormatSameAsManifest(formatSwitchListCheckBox.isSelected());
843        Setup.setPrintLocationCommentsEnabled(printLocCommentsCheckBox.isSelected());
844        Setup.setPrintRouteCommentsEnabled(printRouteCommentsCheckBox.isSelected());
845        Setup.setPrintLoadsAndEmptiesEnabled(printLoadsEmptiesCheckBox.isSelected());
846        Setup.setPrintCabooseLoadEnabled(printCabooseLoadCheckBox.isSelected());
847        Setup.setPrintPassengerLoadEnabled(printPassengerLoadCheckBox.isSelected());
848        Setup.set12hrFormatEnabled(use12hrFormatCheckBox.isSelected());
849        Setup.setPrintValidEnabled(printValidCheckBox.isSelected());
850        Setup.setSortByTrackNameEnabled(sortByTrackCheckBox.isSelected());
851        Setup.setPrintHeadersEnabled(printHeadersCheckBox.isSelected());
852        Setup.setPrintTrainScheduleNameEnabled(printTrainScheduleNameCheckBox.isSelected());
853        Setup.setTruncateManifestEnabled(truncateCheckBox.isSelected());
854        Setup.setUseDepartureTimeEnabled(departureTimeCheckBox.isSelected());
855        Setup.setManifestEditorEnabled(editManifestCheckBox.isSelected());
856        Setup.setTrackSummaryEnabled(trackSummaryCheckBox.isSelected());
857        Setup.setSwitchListRouteLocationCommentEnabled(routeLocationCheckBox.isSelected());
858
859        // reload combo boxes if tab changed
860        boolean oldTabEnabled = Setup.isTabEnabled();
861        Setup.setTabEnabled(tabFormatCheckBox.isSelected());
862        if (oldTabEnabled ^ Setup.isTabEnabled()) {
863            loadFormatComboBox();
864        }
865
866        // recreate all train manifests
867        InstanceManager.getDefault(TrainManager.class).setTrainsModified();
868
869        InstanceManager.getDefault(OperationsSetupXml.class).writeOperationsFile();
870    }
871
872    @Override
873    public boolean isDirty() {
874        if ( // font name
875        !Setup.getFontName().equals(fontComboBox.getSelectedItem())
876        // font size
877                ||
878                Setup.getManifestFontSize() != (Integer) fontSizeComboBox.getSelectedItem()
879                // page orientation
880                ||
881                !Setup.getManifestOrientation().equals(manifestOrientationComboBox.getSelectedItem()) ||
882                !Setup.getSwitchListOrientation().equals(switchListOrientationComboBox.getSelectedItem())
883                // format
884                ||
885                !Setup.getManifestFormat().equals(manifestFormatComboBox.getSelectedItem())
886                // drop and pick up color option
887                ||
888                !Setup.getDropColor().equals(dropColorChooser.getColor()) ||
889                !Setup.getPickupColor().equals(pickupColorChooser.getColor()) ||
890                !Setup.getLocalColor().equals(localColorChooser.getColor())
891                // hazardous comment
892                ||
893                !Setup.getHazardousMsg().equals(hazardousTextField.getText())
894                // misplaced car comment
895                ||
896                !Setup.getMiaComment().equals(commentTextArea.getText()) ||
897                Setup.isSwitchListFormatSameAsManifest() != formatSwitchListCheckBox.isSelected() ||
898                Setup.isPrintLocationCommentsEnabled() != printLocCommentsCheckBox.isSelected() ||
899                Setup.isPrintRouteCommentsEnabled() != printRouteCommentsCheckBox.isSelected() ||
900                Setup.isPrintLoadsAndEmptiesEnabled() != printLoadsEmptiesCheckBox.isSelected() ||
901                Setup.isPrintCabooseLoadEnabled() != printCabooseLoadCheckBox.isSelected() ||
902                Setup.isPrintPassengerLoadEnabled() != printPassengerLoadCheckBox.isSelected() ||
903                Setup.is12hrFormatEnabled() != use12hrFormatCheckBox.isSelected() ||
904                Setup.isPrintValidEnabled() != printValidCheckBox.isSelected() ||
905                Setup.isSortByTrackNameEnabled() != sortByTrackCheckBox.isSelected() ||
906                Setup.isPrintHeadersEnabled() != printHeadersCheckBox.isSelected() ||
907                Setup.isPrintTrainScheduleNameEnabled() != printTrainScheduleNameCheckBox.isSelected() ||
908                Setup.isTruncateManifestEnabled() != truncateCheckBox.isSelected() ||
909                Setup.isUseDepartureTimeEnabled() != departureTimeCheckBox.isSelected() ||
910                Setup.isManifestEditorEnabled() != editManifestCheckBox.isSelected() ||
911                Setup.isSwitchListRouteLocationCommentEnabled() != routeLocationCheckBox.isSelected() ||
912                Setup.isTrackSummaryEnabled() != trackSummaryCheckBox.isSelected() ||
913                Setup.isTabEnabled() != this.tabFormatCheckBox.isSelected()) {
914            return true;
915        }
916        // save engine pick up message format
917        String[] format = new String[enginePickupMessageList.size()];
918        for (int i = 0; i < enginePickupMessageList.size(); i++) {
919            JComboBox<?> cb = enginePickupMessageList.get(i);
920            format[i] = (String) cb.getSelectedItem();
921        }
922        if (!Setup.getPickupEnginePrefix().equals(pickupEngPrefix.getText()) ||
923                !Arrays.equals(Setup.getPickupEngineMessageFormat(), format)) {
924            return true;
925        }
926        // save engine drop message format
927        format = new String[engineDropMessageList.size()];
928        for (int i = 0; i < engineDropMessageList.size(); i++) {
929            JComboBox<?> cb = engineDropMessageList.get(i);
930            format[i] = (String) cb.getSelectedItem();
931        }
932        if (!Setup.getDropEnginePrefix().equals(dropEngPrefix.getText()) ||
933                !Arrays.equals(Setup.getDropEngineMessageFormat(), format)) {
934            return true;
935        }
936        // save car pick up message format
937        format = new String[carPickupMessageList.size()];
938        for (int i = 0; i < carPickupMessageList.size(); i++) {
939            JComboBox<?> cb = carPickupMessageList.get(i);
940            format[i] = (String) cb.getSelectedItem();
941        }
942        if (!Setup.getPickupCarPrefix().equals(this.pickupCarPrefix.getText()) ||
943                !Arrays.equals(Setup.getPickupManifestMessageFormat(), format)) {
944            return true;
945        }
946        // save car drop message format
947        format = new String[carDropMessageList.size()];
948        for (int i = 0; i < carDropMessageList.size(); i++) {
949            JComboBox<?> cb = carDropMessageList.get(i);
950            format[i] = (String) cb.getSelectedItem();
951        }
952        if (!Setup.getDropCarPrefix().equals(this.dropCarPrefix.getText()) ||
953                !Arrays.equals(Setup.getDropManifestMessageFormat(), format)) {
954            return true;
955        }
956        // save local message format
957        format = new String[localMessageList.size()];
958        for (int i = 0; i < localMessageList.size(); i++) {
959            JComboBox<?> cb = localMessageList.get(i);
960            format[i] = (String) cb.getSelectedItem();
961        }
962        if (!Setup.getLocalPrefix().equals(this.localPrefix.getText()) ||
963                !Arrays.equals(Setup.getLocalManifestMessageFormat(), format)) {
964            return true;
965        }
966        // save switch list car pick up message format
967        format = new String[switchListCarPickupMessageList.size()];
968        for (int i = 0; i < switchListCarPickupMessageList.size(); i++) {
969            JComboBox<?> cb = switchListCarPickupMessageList.get(i);
970            format[i] = (String) cb.getSelectedItem();
971        }
972        if (!Setup.getSwitchListPickupCarPrefix().equals(this.switchListPickupCarPrefix.getText()) ||
973                !Arrays.equals(Setup.getPickupSwitchListMessageFormat(), format)) {
974            return true;
975        }
976        // save switch list car drop message format
977        format = new String[switchListCarDropMessageList.size()];
978        for (int i = 0; i < switchListCarDropMessageList.size(); i++) {
979            JComboBox<?> cb = switchListCarDropMessageList.get(i);
980            format[i] = (String) cb.getSelectedItem();
981        }
982        if (!Setup.getSwitchListDropCarPrefix().equals(this.switchListDropCarPrefix.getText()) ||
983                !Arrays.equals(Setup.getDropSwitchListMessageFormat(), format)) {
984            return true;
985        }
986        // save switch list local message format
987        format = new String[switchListLocalMessageList.size()];
988        for (int i = 0; i < switchListLocalMessageList.size(); i++) {
989            JComboBox<?> cb = switchListLocalMessageList.get(i);
990            format[i] = (String) cb.getSelectedItem();
991        }
992        return !Setup.getSwitchListLocalPrefix().equals(this.switchListLocalPrefix.getText()) ||
993                !Arrays.equals(Setup.getLocalSwitchListMessageFormat(), format);
994    }
995}