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