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