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