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