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