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