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