001package jmri.jmrit.operations.setup; 002 003import java.awt.Color; 004import java.awt.JobAttributes.SidesType; 005import java.io.IOException; 006import java.util.*; 007 008import javax.print.attribute.standard.Sides; 009import javax.swing.JComboBox; 010 011import org.jdom2.Element; 012import org.slf4j.Logger; 013import org.slf4j.LoggerFactory; 014 015import jmri.*; 016import jmri.beans.PropertyChangeSupport; 017import jmri.jmris.AbstractOperationsServer; 018import jmri.jmrit.operations.OperationsPanel; 019import jmri.jmrit.operations.rollingstock.RollingStockLogger; 020import jmri.jmrit.operations.setup.backup.AutoBackup; 021import jmri.jmrit.operations.setup.backup.AutoSave; 022import jmri.jmrit.operations.trains.TrainLogger; 023import jmri.jmrit.operations.trains.TrainManagerXml; 024import jmri.util.ColorUtil; 025import jmri.util.swing.JmriColorChooser; 026import jmri.web.server.WebServerPreferences; 027 028/** 029 * Operations settings. 030 * 031 * @author Daniel Boudreau Copyright (C) 2008, 2010, 2012, 2014, 2025 032 */ 033public class Setup extends PropertyChangeSupport implements InstanceManagerAutoDefault, Disposable { 034 035 public static final String NONE = ""; 036 037 // scale ratios from NMRA 038 public static final int Z_RATIO = 220; 039 public static final int N_RATIO = 160; 040 public static final int TT_RATIO = 120; 041 public static final int OO_RATIO = 76; // actual ratio 76.2 042 public static final int HO_RATIO = 87; 043 public static final int S_RATIO = 64; 044 public static final int O_RATIO = 48; 045 public static final int Gauge1_RATIO = 32; // NMRA #1 046 public static final int G_24_RATIO = 24; 047 048 // initial weight in milli ounces from NMRA 049 private static final int Z_INITIAL_WEIGHT = 364; // not specified by NMRA 050 private static final int N_INITIAL_WEIGHT = 500; 051 private static final int TT_INITIAL_WEIGHT = 750; 052 private static final int HOn3_INITIAL_WEIGHT = 750; 053 private static final int OO_INITIAL_WEIGHT = 750; // not specified by NMRA 054 private static final int HO_INITIAL_WEIGHT = 1000; 055 private static final int Sn3_INITIAL_WEIGHT = 1000; 056 private static final int S_INITIAL_WEIGHT = 2000; 057 private static final int On3_INITIAL_WEIGHT = 1500; 058 private static final int O_INITIAL_WEIGHT = 5000; 059 private static final int G_INITIAL_WEIGHT = 10000; // not specified by NMRA 060 061 // additional weight in milli ounces from NMRA 062 private static final int Z_ADD_WEIGHT = 100; // not specified by NMRA 063 private static final int N_ADD_WEIGHT = 150; 064 private static final int TT_ADD_WEIGHT = 375; 065 private static final int HOn3_ADD_WEIGHT = 375; 066 private static final int OO_ADD_WEIGHT = 500; // not specified by NMRA 067 private static final int HO_ADD_WEIGHT = 500; 068 private static final int Sn3_ADD_WEIGHT = 500; 069 private static final int S_ADD_WEIGHT = 500; 070 private static final int On3_ADD_WEIGHT = 750; 071 private static final int O_ADD_WEIGHT = 1000; 072 private static final int G_ADD_WEIGHT = 2000; // not specified by NMRA 073 074 // actual weight to tons conversion ratios (based on 40' boxcar at ~80 tons) 075 private static final int Z_RATIO_TONS = 130; 076 private static final int N_RATIO_TONS = 80; 077 private static final int TT_RATIO_TONS = 36; 078 private static final int HOn3_RATIO_TONS = 20; 079 private static final int OO_RATIO_TONS = 20; 080 private static final int HO_RATIO_TONS = 20; // 20 tons per ounce 081 private static final int Sn3_RATIO_TONS = 16; 082 private static final int S_RATIO_TONS = 14; 083 private static final int On3_RATIO_TONS = 8; 084 private static final int O_RATIO_TONS = 5; 085 private static final int G_RATIO_TONS = 2; 086 087 public static final int Z_SCALE = 1; 088 public static final int N_SCALE = 2; 089 public static final int TT_SCALE = 3; 090 public static final int HOn3_SCALE = 4; 091 public static final int OO_SCALE = 5; 092 public static final int HO_SCALE = 6; 093 public static final int Sn3_SCALE = 7; 094 public static final int S_SCALE = 8; 095 public static final int On3_SCALE = 9; 096 public static final int O_SCALE = 10; 097 public static final int Gauge1_SCALE = 11; // NMRA #1 098 public static final int G_24_SCALE = 12; 099 100 public static final int EAST = 1; // train direction serviced by this location 101 public static final int WEST = 2; 102 public static final int NORTH = 4; 103 public static final int SOUTH = 8; 104 105 public static final String EAST_DIR = Bundle.getMessage("East"); 106 public static final String WEST_DIR = Bundle.getMessage("West"); 107 public static final String NORTH_DIR = Bundle.getMessage("North"); 108 public static final String SOUTH_DIR = Bundle.getMessage("South"); 109 110 public static final String DESCRIPTIVE = Bundle.getMessage("Descriptive"); // Car types 111 public static final String AAR = Bundle.getMessage("ArrCodes"); // Car types 112 113 public static final String MONOSPACED = Bundle.getMessage("Monospaced"); // default printer font 114 115 public static final String STANDARD_FORMAT = Bundle.getMessage("StandardFormat"); 116 public static final String TWO_COLUMN_FORMAT = Bundle.getMessage("TwoColumnFormat"); 117 public static final String TWO_COLUMN_TRACK_FORMAT = Bundle.getMessage("TwoColumnTrackFormat"); 118 119 public static final String PORTRAIT = Bundle.getMessage("Portrait"); 120 public static final String LANDSCAPE = Bundle.getMessage("Landscape"); 121 public static final String HALFPAGE = Bundle.getMessage("HalfPage"); 122 public static final String HANDHELD = Bundle.getMessage("HandHeld"); 123 public static final String RECEIPT = Bundle.getMessage("Receipt"); 124 125 public static final String PAGE_NORMAL = Bundle.getMessage("PageNormal"); 126 public static final String PAGE_PER_TRAIN = Bundle.getMessage("PagePerTrain"); 127 public static final String PAGE_PER_VISIT = Bundle.getMessage("PagePerVisit"); 128 129 public static final String BUILD_REPORT_MINIMAL = "1"; 130 public static final String BUILD_REPORT_NORMAL = "3"; 131 public static final String BUILD_REPORT_DETAILED = "5"; 132 public static final String BUILD_REPORT_VERY_DETAILED = "7"; 133 134 // the following are converted to English spelling when storing to file, see KEYS below 135 public static final String ROAD = Bundle.getMessage("Road"); // the supported message format options 136 public static final String NUMBER = Bundle.getMessage("Number"); 137 public static final String TYPE = Bundle.getMessage("Type"); 138 public static final String MODEL = Bundle.getMessage("Model"); 139 public static final String LENGTH = Bundle.getMessage("Length"); 140 public static final String WEIGHT = Bundle.getMessage("Weight"); 141 public static final String HP = Bundle.getMessage("HP"); 142 public static final String LOAD = Bundle.getMessage("Load"); 143 public static final String LOAD_TYPE = Bundle.getMessage("Load_Type"); 144 public static final String COLOR = Bundle.getMessage("Color"); 145 public static final String TRACK = Bundle.getMessage("Track"); 146 public static final String DESTINATION = Bundle.getMessage("Destination"); 147 public static final String DEST_TRACK = Bundle.getMessage("Dest&Track"); 148 public static final String FINAL_DEST = Bundle.getMessage("Final_Dest"); 149 public static final String FINAL_DEST_TRACK = Bundle.getMessage("FD&Track"); 150 public static final String LOCATION = Bundle.getMessage("Location"); 151 public static final String CONSIST = Bundle.getMessage("Consist"); 152 public static final String DCC_ADDRESS = Bundle.getMessage("DCC_Address"); 153 public static final String KERNEL = Bundle.getMessage("Kernel"); 154 public static final String KERNEL_SIZE = Bundle.getMessage("Kernel_Size"); 155 public static final String OWNER = Bundle.getMessage("Owner"); 156 public static final String DIVISION = Bundle.getMessage("Division"); 157 public static final String BLOCKING_ORDER = Bundle.getMessage("Blocking_Order"); 158 public static final String RWE = Bundle.getMessage("RWE"); 159 public static final String COMMENT = Bundle.getMessage("Comment"); 160 public static final String DROP_COMMENT = Bundle.getMessage("SetOut_Msg"); 161 public static final String PICKUP_COMMENT = Bundle.getMessage("PickUp_Msg"); 162 public static final String HAZARDOUS = Bundle.getMessage("Hazardous"); 163 public static final String LAST_TRAIN = Bundle.getMessage("LastTrain"); 164 public static final String LAST_MOVED = Bundle.getMessage("LastMoved"); 165 public static final String LAST_LOCATION = Bundle.getMessage("LastLocation"); 166 public static final String BLANK = " "; // blank has be a character or a space 167 public static final String TAB = Bundle.getMessage("Tab"); // used to tab out in tabular mode 168 public static final String TAB2 = Bundle.getMessage("Tab2"); 169 public static final String TAB3 = Bundle.getMessage("Tab3"); 170 171 public static final String BOX = " [ ] "; // NOI18N 172 173 // these are for the utility printing when using tabs 174 public static final String NO_ROAD = "NO_ROAD"; // NOI18N 175 public static final String NO_NUMBER = "NO_NUMBER"; // NOI18N 176 public static final String NO_COLOR = "NO_COLOR"; // NOI18N 177 178 // truncated manifests 179 public static final String NO_DESTINATION = "NO_DESTINATION"; // NOI18N 180 public static final String NO_DEST_TRACK = "NO_DEST_TRACK"; // NOI18N 181 public static final String NO_LOCATION = "NO_LOCATION"; // NOI18N 182 public static final String NO_TRACK = "NO_TRACK"; // NOI18N 183 184 // Unit of Length 185 public static final String FEET = Bundle.getMessage("Feet"); 186 public static final String METER = Bundle.getMessage("Meter"); 187 public static final String FEET_ABV = Bundle.getMessage("FeetAbbreviation"); 188 public static final String METER_ABV = Bundle.getMessage("MeterAbbreviation"); 189 190 private static final String[] CAR_ATTRIBUTES = { ROAD, NUMBER, TYPE, LENGTH, WEIGHT, LOAD, LOAD_TYPE, HAZARDOUS, 191 COLOR, KERNEL, KERNEL_SIZE, OWNER, DIVISION, TRACK, LOCATION, DESTINATION, DEST_TRACK, FINAL_DEST, FINAL_DEST_TRACK, 192 BLOCKING_ORDER, COMMENT, DROP_COMMENT, PICKUP_COMMENT, RWE, LAST_TRAIN, LAST_MOVED, LAST_LOCATION}; 193 194 private static final String[] ENGINE_ATTRIBUTES = {ROAD, NUMBER, TYPE, MODEL, LENGTH, WEIGHT, HP, CONSIST, OWNER, 195 TRACK, LOCATION, DESTINATION, COMMENT, DCC_ADDRESS, LAST_TRAIN, LAST_MOVED, LAST_LOCATION}; 196 /* 197 * The print Manifest and switch list user selectable options are stored in the 198 * xml file using the English translations. 199 */ 200 private static final String[] KEYS = {"Road", "Number", "Type", "Model", "Length", "Weight", "Load", "Load_Type", 201 "HP", "Color", "Track", "Destination", "Dest&Track", "Final_Dest", "FD&Track", "Location", "Consist", 202 "DCC_Address", "Kernel", "Kernel_Size", "Owner", "Division", "Blocking_Order", "RWE", "Comment", 203 "SetOut_Msg", "PickUp_Msg", "Hazardous", "LastTrain", "LastMoved", "LastLocation", "Tab", "Tab2", "Tab3"}; 204 205 private int scale = HO_SCALE; // Default scale 206 private int ratio = HO_RATIO; 207 private int ratioTons = HO_RATIO_TONS; 208 private int initWeight = HO_INITIAL_WEIGHT; 209 private int addWeight = HO_ADD_WEIGHT; 210 private String railroadName = NONE; 211 private int traindir = EAST + WEST + NORTH + SOUTH; 212 private int maxTrainLength = 1000; // maximum train length 213 private int maxEngineSize = 6; // maximum number of engines that can be assigned to a train 214 private double horsePowerPerTon = 1; // Horsepower per ton 215 private int carMoves = 5; // default number of moves when creating a route 216 private String carTypes = DESCRIPTIVE; 217 private String ownerName = NONE; 218 private String fontName = MONOSPACED; 219 private int manifestFontSize = 10; 220 private int buildReportFontSize = 10; 221 private String manifestOrientation = PORTRAIT; 222 private String switchListOrientation = PORTRAIT; 223 private Sides sides = Sides.ONE_SIDED; 224 private boolean printHeader = true; 225 private Color pickupEngineColor = Color.black; 226 private Color dropEngineColor = Color.black; 227 private Color pickupColor = Color.black; 228 private Color dropColor = Color.black; 229 private Color localColor = Color.black; 230 private String[] pickupEngineMessageFormat = { ROAD, NUMBER, BLANK, MODEL, BLANK, BLANK, LOCATION, COMMENT }; 231 private String[] dropEngineMessageFormat = { ROAD, NUMBER, BLANK, MODEL, BLANK, BLANK, DESTINATION, COMMENT }; 232 private String[] pickupManifestMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, LOAD, HAZARDOUS, LOCATION, 233 COMMENT, PICKUP_COMMENT }; 234 private String[] dropManifestMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, LOAD, HAZARDOUS, DESTINATION, 235 COMMENT, DROP_COMMENT }; 236 private String[] localManifestMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, LOAD, HAZARDOUS, LOCATION, 237 DESTINATION, COMMENT }; 238 private String[] pickupSwitchListMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, LOAD, HAZARDOUS, LOCATION, 239 COMMENT, PICKUP_COMMENT }; 240 private String[] dropSwitchListMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, LOAD, HAZARDOUS, DESTINATION, 241 COMMENT, DROP_COMMENT }; 242 private String[] localSwitchListMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, LOAD, HAZARDOUS, LOCATION, 243 DESTINATION, COMMENT }; 244 private String[] missingCarMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, COMMENT }; 245 private String pickupEnginePrefix = BOX + Bundle.getMessage("PickUpPrefix"); 246 private String dropEnginePrefix = BOX + Bundle.getMessage("SetOutPrefix"); 247 private String pickupCarPrefix = BOX + Bundle.getMessage("PickUpPrefix"); 248 private String dropCarPrefix = BOX + Bundle.getMessage("SetOutPrefix"); 249 private String localPrefix = BOX + Bundle.getMessage("LocalCarPrefix"); 250 private String switchListPickupCarPrefix = BOX + Bundle.getMessage("PickUpPrefix"); 251 private String switchListDropCarPrefix = BOX + Bundle.getMessage("SetOutPrefix"); 252 private String switchListLocalPrefix = BOX + Bundle.getMessage("LocalCarPrefix"); 253 private String miaComment = Bundle.getMessage("misplacedCars"); 254 private String hazardousMsg = "(" + Bundle.getMessage("Hazardous") + ")"; 255 private String logoURL = NONE; 256 private String panelName = "Panel"; // NOI18N 257 private String buildReportLevel = BUILD_REPORT_VERY_DETAILED; 258 private String routerBuildReportLevel = BUILD_REPORT_NORMAL; 259 private int carSwitchTime = 3; // how long it takes to move a car in minutes 260 private int travelTime = 4; // how long it takes a train to move from one location to another in minutes 261 private String yearModeled = NONE; // year being modeled 262 private String lengthUnit = FEET; 263 private String lengthUnitAbv = FEET_ABV; 264 private String iconNorthColor = NONE; 265 private String iconSouthColor = NONE; 266 private String iconEastColor = NONE; 267 private String iconWestColor = NONE; 268 private String iconLocalColor = NONE; 269 private String iconTerminateColor = NONE; 270 271 private boolean tab = false; // when true, tab out manifest and switch lists 272 private int tab1CharLength = Control.max_len_string_attibute; 273 private int tab2CharLength = 6; // arbitrary lengths 274 private int tab3CharLength = 8; 275 private int manifestTabLength = 4; // plus one space 276 277 private String manifestFormat = STANDARD_FORMAT; 278 private boolean manifestEditorEnabled = false; // when true use text editor to view build report 279 private boolean switchListSameManifest = true; // when true switch list format is the same as the manifest 280 private boolean manifestTruncated = false; // when true, manifest is truncated if switch list is available 281 private boolean manifestDepartureTime = false; // when true, manifest shows train's departure time 282 private boolean switchListDepartureTime = false; // when true, switch list shows train's departure time 283 private boolean switchListRouteComment = true; // when true, switch list have route location comments 284 private boolean trackSummary = true; // when true, print switch list track summary 285 private boolean groupCarMoves = false; // when true, car moves are grouped together 286 private boolean locoLast = false; // when true, loco set outs printed last 287 288 private boolean switchListRealTime = true; // when true switch list only show work for built trains 289 private boolean switchListAllTrains = true; // when true show all trains that visit the location 290 private String switchListPageFormat = PAGE_NORMAL; // how switch lists pages are printed 291 292 private boolean buildReportEditorEnabled = false; // when true use text editor to view build report 293 private boolean buildReportIndentEnabled = true; // when true use text editor to view build report 294 private boolean buildReportAlwaysPreviewEnabled = false; // when true use text editor to view build report 295 296 private boolean enableTrainIconXY = true; 297 private boolean appendTrainIcon = false; // when true, append engine number to train name 298 private String setupComment = NONE; 299 300 private boolean mainMenuEnabled = false; // when true add operations menu to main menu bar 301 private boolean closeWindowOnSave = false; // when true, close window when save button is activated 302 private boolean autoSave = true; // when true, automatically save files if modified 303 private boolean autoBackup = true; // when true, automatically backup files 304 private boolean enableValue = false; // when true show value fields for rolling stock 305 private String labelValue = Bundle.getMessage("Value"); 306 private boolean enableRfid = false; // when true show RFID fields for rolling stock 307 private String labelRfid = Bundle.getMessage("RFID"); 308 309 private boolean carRoutingEnabled = true; // when true enable car routing 310 private boolean carRoutingYards = false; // when true enable car routing via yard tracks 311 private boolean carRoutingStaging = false; // when true staging tracks can be used for car routing 312 private boolean forwardToYardEnabled = true; // when true forward car to yard if track is full 313 private boolean onlyActiveTrains = false; // when true only active trains are used for routing 314 private boolean checkCarDestination = false; // when true check car's track for valid destination 315 316 private boolean carLogger = false; // when true car logger is enabled 317 private boolean engineLogger = false; // when true engine logger is enabled 318 private boolean trainLogger = false; // when true train logger is enabled 319 private boolean saveTrainManifests = false; // when true save previous train manifest 320 321 private boolean aggressiveBuild = false; // when true subtract car length from track reserve length 322 private int numberPasses = 2; // the number of passes in train builder 323 private boolean onTimeBuild = false; // when true on time mode 324 private int dwellTime = 60; // time in minutes before allowing track reuse 325 private boolean allowLocalInterchangeMoves = false; // when true local C/I to C/I moves are allowed 326 private boolean allowLocalYardMoves = false; // when true local yard to yard moves are allowed 327 private boolean allowLocalSpurMoves = false; // when true local spur to spur moves are allowed 328 329 private boolean trainIntoStagingCheck = true; // staging track must accept train's rolling stock types and roads 330 private boolean trackImmediatelyAvail = false; // when true staging track is available for other trains 331 private boolean allowCarsReturnStaging = false; // allow cars on a turn to return to staging if necessary (prevent 332 // build failure) 333 private boolean promptFromStaging = false; // prompt user to specify which departure staging track to use 334 private boolean promptToStaging = false; // prompt user to specify which arrival staging track to use 335 private boolean tryNormalModeStaging = true; // try normal build if route length failure using aggressive 336 337 private boolean generateCsvManifest = false; // when true generate csv manifest 338 private boolean generateCsvSwitchList = false; // when true generate csv switch list 339 private boolean enableVsdPhysicalLocations = false; 340 341 private boolean printLocationComments = false; // when true print location comments on the manifest 342 private boolean printRouteComments = false; // when true print route comments on the manifest 343 private boolean printLoadsAndEmpties = false; // when true print Loads and Empties on the manifest 344 private boolean printTrainScheduleName = false; // when true print train schedule name on manifests and switch lists 345 private boolean use12hrFormat = false; // when true use 12hr rather than 24hr format 346 private boolean printValid = true; // when true print out the valid time and date 347 private boolean sortByTrack = false; // when true manifest work is sorted by track names 348 private boolean printHeaders = false; // when true add headers to manifest and switch lists 349 private boolean printNoPageBreaks = true; // when true no page breaks for a location's work 350 private boolean printHeaderLine1 = true; // when true add header line 1 to manifest and switch lists 351 private boolean printHeaderLine2 = true; // when true add header line 2 to manifest and switch lists 352 private boolean printHeaderLine3 = true; // when true add header line 3 to manifest and switch lists 353 private int horizontalLineAdjustment = 0; 354 355 private boolean printCabooseLoad = false; // when true print caboose load 356 private boolean printPassengerLoad = false; // when true print passenger car load 357 private boolean showTrackMoves = false; // when true show track moves in table 358 359 private Hashtable<String, String> hashTableDayToName = new Hashtable<>(); 360 361 // property changes 362 public static final String SWITCH_LIST_CSV_PROPERTY_CHANGE = "setupSwitchListCSVChange"; // NOI18N 363 public static final String MANIFEST_CSV_PROPERTY_CHANGE = "setupManifestCSVChange"; // NOI18N 364 public static final String REAL_TIME_PROPERTY_CHANGE = "setupSwitchListRealTime"; // NOI18N 365 public static final String SHOW_TRACK_MOVES_PROPERTY_CHANGE = "setupShowTrackMoves"; // NOI18N 366 public static final String SAVE_TRAIN_MANIFEST_PROPERTY_CHANGE = "saveTrainManifestChange"; // NOI18N 367 public static final String ALLOW_CARS_TO_RETURN_PROPERTY_CHANGE = "allowCarsToReturnChange"; // NOI18N 368 public static final String TRAIN_DIRECTION_PROPERTY_CHANGE = "setupTrainDirectionChange"; // NOI18N 369 public static final String ROUTING_STAGING_PROPERTY_CHANGE = "setupRoutingStagingChange"; // NOI18N 370 public static final String TRAVEL_TIME_PROPERTY_CHANGE = "setupTravelTimeChange"; // NOI18N 371 372 public static boolean isMainMenuEnabled() { 373 InstanceManager.getDefault(OperationsSetupXml.class); // load file 374 return getDefault().mainMenuEnabled; 375 } 376 377 public static void setMainMenuEnabled(boolean enabled) { 378 getDefault().mainMenuEnabled = enabled; 379 } 380 381 public static boolean isCloseWindowOnSaveEnabled() { 382 return getDefault().closeWindowOnSave; 383 } 384 385 public static void setCloseWindowOnSaveEnabled(boolean enabled) { 386 getDefault().closeWindowOnSave = enabled; 387 } 388 389 public static boolean isAutoSaveEnabled() { 390 return getDefault().autoSave; 391 } 392 393 public static void setAutoSaveEnabled(boolean enabled) { 394 getDefault().autoSave = enabled; 395 if (enabled) { 396 AutoSave.start(); 397 } else { 398 AutoSave.stop(); 399 } 400 } 401 402 public static boolean isAutoBackupEnabled() { 403 return getDefault().autoBackup; 404 } 405 406 public static void setAutoBackupEnabled(boolean enabled) { 407 // Do an autoBackup only if we are changing the setting from false to 408 // true. 409 if (enabled && !getDefault().autoBackup) { 410 try { 411 InstanceManager.getDefault(AutoBackup.class).autoBackup(); 412 } catch (IOException ex) { 413 log.debug("Autobackup after setting AutoBackup flag true", ex); 414 } 415 } 416 417 getDefault().autoBackup = enabled; 418 } 419 420 public static boolean isValueEnabled() { 421 return getDefault().enableValue; 422 } 423 424 public static void setValueEnabled(boolean enabled) { 425 getDefault().enableValue = enabled; 426 } 427 428 public static String getValueLabel() { 429 return getDefault().labelValue; 430 } 431 432 public static void setValueLabel(String label) { 433 getDefault().labelValue = label; 434 } 435 436 public static boolean isRfidEnabled() { 437 return getDefault().enableRfid; 438 } 439 440 public static void setRfidEnabled(boolean enabled) { 441 getDefault().enableRfid = enabled; 442 } 443 444 public static String getRfidLabel() { 445 return getDefault().labelRfid; 446 } 447 448 public static void setRfidLabel(String label) { 449 getDefault().labelRfid = label; 450 } 451 452 public static boolean isCarRoutingEnabled() { 453 return getDefault().carRoutingEnabled; 454 } 455 456 public static void setCarRoutingEnabled(boolean enabled) { 457 getDefault().carRoutingEnabled = enabled; 458 } 459 460 public static boolean isCarRoutingViaYardsEnabled() { 461 return getDefault().carRoutingYards; 462 } 463 464 public static void setCarRoutingViaYardsEnabled(boolean enabled) { 465 getDefault().carRoutingYards = enabled; 466 } 467 468 public static boolean isCarRoutingViaStagingEnabled() { 469 return getDefault().carRoutingStaging; 470 } 471 472 public static void setCarRoutingViaStagingEnabled(boolean enabled) { 473 boolean old = isCarRoutingViaStagingEnabled(); 474 getDefault().carRoutingStaging = enabled; 475 setDirtyAndFirePropertyChange(ROUTING_STAGING_PROPERTY_CHANGE, old, enabled); 476 } 477 478 public static boolean isForwardToYardEnabled() { 479 return getDefault().forwardToYardEnabled; 480 } 481 482 public static void setForwardToYardEnabled(boolean enabled) { 483 getDefault().forwardToYardEnabled = enabled; 484 } 485 486 public static boolean isOnlyActiveTrainsEnabled() { 487 return getDefault().onlyActiveTrains; 488 } 489 490 public static void setOnlyActiveTrainsEnabled(boolean enabled) { 491 getDefault().onlyActiveTrains = enabled; 492 } 493 494 /** 495 * When true, router checks that the car's destination is serviced by departure 496 * track. Very restrictive, not recommended. 497 * 498 * @return true if enabled. 499 */ 500 public static boolean isCheckCarDestinationEnabled() { 501 return getDefault().checkCarDestination; 502 } 503 504 public static void setCheckCarDestinationEnabled(boolean enabled) { 505 getDefault().checkCarDestination = enabled; 506 } 507 508 public static boolean isBuildAggressive() { 509 return getDefault().aggressiveBuild; 510 } 511 512 public static void setBuildAggressive(boolean enabled) { 513 getDefault().aggressiveBuild = enabled; 514 } 515 516 public static int getNumberPasses() { 517 return getDefault().numberPasses; 518 } 519 520 public static void setNumberPasses(int number) { 521 getDefault().numberPasses = number; 522 } 523 524 public static boolean isBuildOnTime() { 525 return getDefault().onTimeBuild; 526 } 527 528 public static void setBuildOnTime(boolean enabled) { 529 getDefault().onTimeBuild = enabled; 530 } 531 532 public static int getDwellTime() { 533 return getDefault().dwellTime; 534 } 535 536 public static void setDwellTime(int minutes) { 537 getDefault().dwellTime = minutes; 538 } 539 540 public static boolean isLocalInterchangeMovesEnabled() { 541 return getDefault().allowLocalInterchangeMoves; 542 } 543 544 public static void setLocalInterchangeMovesEnabled(boolean enabled) { 545 getDefault().allowLocalInterchangeMoves = enabled; 546 } 547 548 public static boolean isLocalYardMovesEnabled() { 549 return getDefault().allowLocalYardMoves; 550 } 551 552 public static void setLocalYardMovesEnabled(boolean enabled) { 553 getDefault().allowLocalYardMoves = enabled; 554 } 555 556 public static boolean isLocalSpurMovesEnabled() { 557 return getDefault().allowLocalSpurMoves; 558 } 559 560 public static void setLocalSpurMovesEnabled(boolean enabled) { 561 getDefault().allowLocalSpurMoves = enabled; 562 } 563 564 public static boolean isStagingTrainCheckEnabled() { 565 return getDefault().trainIntoStagingCheck; 566 } 567 568 /** 569 * Controls staging track selection, when true, the terminus staging track has 570 * to have the same characteristics as the train. 571 * 572 * @param enabled when true, the terminal staging track must service the same 573 * car types, loads, etc. as the train 574 */ 575 public static void setStagingTrainCheckEnabled(boolean enabled) { 576 getDefault().trainIntoStagingCheck = enabled; 577 } 578 579 public static boolean isStagingTrackImmediatelyAvail() { 580 return getDefault().trackImmediatelyAvail; 581 } 582 583 public static void setStagingTrackImmediatelyAvail(boolean enabled) { 584 getDefault().trackImmediatelyAvail = enabled; 585 } 586 587 /** 588 * allow cars to return to the same staging location if no other options 589 * (tracks) are available. Also available on a per train basis. 590 * 591 * @return true if cars are allowed to depart and return to same staging 592 * location 593 */ 594 public static boolean isStagingAllowReturnEnabled() { 595 return getDefault().allowCarsReturnStaging; 596 } 597 598 public static void setStagingAllowReturnEnabled(boolean enabled) { 599 boolean old = getDefault().allowCarsReturnStaging; 600 getDefault().allowCarsReturnStaging = enabled; 601 setDirtyAndFirePropertyChange(ALLOW_CARS_TO_RETURN_PROPERTY_CHANGE, old, enabled); 602 } 603 604 public static boolean isStagingPromptFromEnabled() { 605 return getDefault().promptFromStaging; 606 } 607 608 public static void setStagingPromptFromEnabled(boolean enabled) { 609 getDefault().promptFromStaging = enabled; 610 } 611 612 public static boolean isStagingPromptToEnabled() { 613 return getDefault().promptToStaging; 614 } 615 616 public static void setStagingPromptToEnabled(boolean enabled) { 617 getDefault().promptToStaging = enabled; 618 } 619 620 public static boolean isStagingTryNormalBuildEnabled() { 621 return getDefault().tryNormalModeStaging; 622 } 623 624 public static void setStagingTryNormalBuildEnabled(boolean enabled) { 625 getDefault().tryNormalModeStaging = enabled; 626 } 627 628 public static boolean isGenerateCsvManifestEnabled() { 629 return getDefault().generateCsvManifest; 630 } 631 632 public static void setGenerateCsvManifestEnabled(boolean enabled) { 633 boolean old = getDefault().generateCsvManifest; 634 getDefault().generateCsvManifest = enabled; 635 if (enabled && !old) { 636 InstanceManager.getDefault(TrainManagerXml.class).createDefaultCsvManifestDirectory(); 637 } 638 setDirtyAndFirePropertyChange(MANIFEST_CSV_PROPERTY_CHANGE, old, enabled); 639 } 640 641 public static boolean isGenerateCsvSwitchListEnabled() { 642 return getDefault().generateCsvSwitchList; 643 } 644 645 public static void setGenerateCsvSwitchListEnabled(boolean enabled) { 646 boolean old = getDefault().generateCsvSwitchList; 647 getDefault().generateCsvSwitchList = enabled; 648 if (enabled && !old) { 649 InstanceManager.getDefault(TrainManagerXml.class).createDefaultCsvSwitchListDirectory(); 650 } 651 setDirtyAndFirePropertyChange(SWITCH_LIST_CSV_PROPERTY_CHANGE, old, enabled); 652 } 653 654 public static boolean isVsdPhysicalLocationEnabled() { 655 return getDefault().enableVsdPhysicalLocations; 656 } 657 658 public static void setVsdPhysicalLocationEnabled(boolean enabled) { 659 getDefault().enableVsdPhysicalLocations = enabled; 660 } 661 662 public static String getRailroadName() { 663 if (getDefault().railroadName.isEmpty()) { 664 return InstanceManager.getDefault(WebServerPreferences.class).getRailroadName(); 665 } 666 return getDefault().railroadName; 667 } 668 669 public static void setRailroadName(String name) { 670 String old = getDefault().railroadName; 671 getDefault().railroadName = name; 672 if (old == null || !old.equals(name)) { 673 setDirtyAndFirePropertyChange("Railroad Name Change", old, name); // NOI18N 674 } 675 } 676 677 public static String getHazardousMsg() { 678 return getDefault().hazardousMsg; 679 } 680 681 public static void setHazardousMsg(String message) { 682 getDefault().hazardousMsg = message; 683 } 684 685 public static String getMiaComment() { 686 return getDefault().miaComment; 687 } 688 689 public static void setMiaComment(String comment) { 690 getDefault().miaComment = comment; 691 } 692 693 public static void setTrainDirection(int direction) { 694 int old = getDefault().traindir; 695 getDefault().traindir = direction; 696 if (old != direction) { 697 setDirtyAndFirePropertyChange(TRAIN_DIRECTION_PROPERTY_CHANGE, old, direction); 698 } 699 } 700 701 public static int getTrainDirection() { 702 return getDefault().traindir; 703 } 704 705 public static void setMaxTrainLength(int length) { 706 getDefault().maxTrainLength = length; 707 } 708 709 public static int getMaxTrainLength() { 710 return getDefault().maxTrainLength; 711 } 712 713 public static void setMaxNumberEngines(int value) { 714 getDefault().maxEngineSize = value; 715 } 716 717 public static int getMaxNumberEngines() { 718 return getDefault().maxEngineSize; 719 } 720 721 public static void setHorsePowerPerTon(double value) { 722 getDefault().horsePowerPerTon = value; 723 } 724 725 public static double getHorsePowerPerTon() { 726 return getDefault().horsePowerPerTon; 727 } 728 729 public static void setCarMoves(int moves) { 730 getDefault().carMoves = moves; 731 } 732 733 public static int getCarMoves() { 734 return getDefault().carMoves; 735 } 736 737 public static String getPanelName() { 738 return getDefault().panelName; 739 } 740 741 public static void setPanelName(String name) { 742 getDefault().panelName = name; 743 } 744 745 public static String getLengthUnit() { 746 return getDefault().lengthUnit; 747 } 748 749 /** 750 * Abbreviation unit of length 751 * 752 * @return symbol for feet or meter 753 */ 754 public static String getLengthUnitAbv() { 755 return getDefault().lengthUnitAbv; 756 } 757 758 public static void setLengthUnit(String unit) { 759 getDefault().lengthUnit = unit; 760 if (unit.equals(FEET)) { 761 getDefault().lengthUnitAbv = FEET_ABV; 762 } else { 763 getDefault().lengthUnitAbv = METER_ABV; 764 } 765 } 766 767 public static String getYearModeled() { 768 return getDefault().yearModeled; 769 } 770 771 public static void setYearModeled(String year) { 772 getDefault().yearModeled = year; 773 } 774 775 public static String getCarTypes() { 776 return getDefault().carTypes; 777 } 778 779 public static void setCarTypes(String types) { 780 getDefault().carTypes = types; 781 } 782 783 public static void setTrainIconCordEnabled(boolean enable) { 784 getDefault().enableTrainIconXY = enable; 785 } 786 787 public static boolean isTrainIconCordEnabled() { 788 return getDefault().enableTrainIconXY; 789 } 790 791 public static void setTrainIconAppendEnabled(boolean enable) { 792 getDefault().appendTrainIcon = enable; 793 } 794 795 public static boolean isTrainIconAppendEnabled() { 796 return getDefault().appendTrainIcon; 797 } 798 799 public static void setComment(String comment) { 800 getDefault().setupComment = comment; 801 } 802 803 public static String getComment() { 804 return getDefault().setupComment; 805 } 806 807 public static void setBuildReportLevel(String level) { 808 getDefault().buildReportLevel = level; 809 } 810 811 public static String getBuildReportLevel() { 812 return getDefault().buildReportLevel; 813 } 814 815 /** 816 * Sets the report level for the car router. 817 * 818 * @param level BUILD_REPORT_NORMAL, BUILD_REPORT_DETAILED, 819 * BUILD_REPORT_VERY_DETAILED 820 */ 821 public static void setRouterBuildReportLevel(String level) { 822 getDefault().routerBuildReportLevel = level; 823 } 824 825 public static String getRouterBuildReportLevel() { 826 return getDefault().routerBuildReportLevel; 827 } 828 829 public static void setManifestEditorEnabled(boolean enable) { 830 getDefault().manifestEditorEnabled = enable; 831 } 832 833 public static boolean isManifestEditorEnabled() { 834 return getDefault().manifestEditorEnabled; 835 } 836 837 public static void setBuildReportEditorEnabled(boolean enable) { 838 getDefault().buildReportEditorEnabled = enable; 839 } 840 841 public static boolean isBuildReportEditorEnabled() { 842 return getDefault().buildReportEditorEnabled; 843 } 844 845 public static void setBuildReportIndentEnabled(boolean enable) { 846 getDefault().buildReportIndentEnabled = enable; 847 } 848 849 public static boolean isBuildReportIndentEnabled() { 850 return getDefault().buildReportIndentEnabled; 851 } 852 853 public static void setBuildReportAlwaysPreviewEnabled(boolean enable) { 854 getDefault().buildReportAlwaysPreviewEnabled = enable; 855 } 856 857 public static boolean isBuildReportAlwaysPreviewEnabled() { 858 return getDefault().buildReportAlwaysPreviewEnabled; 859 } 860 861 public static void setSwitchListFormatSameAsManifest(boolean b) { 862 getDefault().switchListSameManifest = b; 863 } 864 865 public static boolean isSwitchListFormatSameAsManifest() { 866 return getDefault().switchListSameManifest; 867 } 868 869 public static void setPrintTrackSummaryEnabled(boolean b) { 870 getDefault().trackSummary = b; 871 } 872 873 public static boolean isPrintTrackSummaryEnabled() { 874 return getDefault().trackSummary; 875 } 876 877 public static void setSwitchListRouteLocationCommentEnabled(boolean b) { 878 getDefault().switchListRouteComment = b; 879 } 880 881 public static boolean isSwitchListRouteLocationCommentEnabled() { 882 return getDefault().switchListRouteComment; 883 } 884 885 public static void setGroupCarMoves(boolean b) { 886 getDefault().groupCarMoves = b; 887 } 888 889 public static boolean isGroupCarMovesEnabled() { 890 return getDefault().groupCarMoves; 891 } 892 893 public static void setPrintLocoLast(boolean b) { 894 getDefault().locoLast = b; 895 } 896 897 public static boolean isPrintLocoLastEnabled() { 898 return getDefault().locoLast; 899 } 900 901 public static void setSwitchListRealTime(boolean b) { 902 boolean old = getDefault().switchListRealTime; 903 getDefault().switchListRealTime = b; 904 setDirtyAndFirePropertyChange(REAL_TIME_PROPERTY_CHANGE, old, b); 905 } 906 907 public static boolean isSwitchListRealTime() { 908 return getDefault().switchListRealTime; 909 } 910 911 public static void setSwitchListAllTrainsEnabled(boolean b) { 912 boolean old = getDefault().switchListAllTrains; 913 getDefault().switchListAllTrains = b; 914 setDirtyAndFirePropertyChange("Switch List All Trains", old, b); // NOI18N 915 } 916 917 /** 918 * When true switch list shows all trains visiting a location, even if the train 919 * doesn't have any work at that location. When false, switch lists only report 920 * a train if it has work at the location. 921 * 922 * @return When true show all trains visiting a location. 923 */ 924 public static boolean isSwitchListAllTrainsEnabled() { 925 return getDefault().switchListAllTrains; 926 } 927 928 /** 929 * Used to determine if there's spaces or form feed between trains and locations 930 * when printing switch lists. see getSwitchListPageFormatComboBox() 931 * 932 * @param format PAGE_NORMAL, PAGE_PER_TRAIN, or PAGE_PER_VISIT 933 */ 934 public static void setSwitchListPageFormat(String format) { 935 getDefault().switchListPageFormat = format; 936 } 937 938 public static String getSwitchListPageFormat() { 939 return getDefault().switchListPageFormat; 940 } 941 942 public static void setPrintTruncateManifestEnabled(boolean b) { 943 getDefault().manifestTruncated = b; 944 } 945 946 public static boolean isPrintTruncateManifestEnabled() { 947 return getDefault().manifestTruncated; 948 } 949 950 public static void setUseDepartureTimeEnabled(boolean b) { 951 getDefault().manifestDepartureTime = b; 952 } 953 954 public static boolean isUseDepartureTimeEnabled() { 955 return getDefault().manifestDepartureTime; 956 } 957 958 public static void setUseSwitchListDepartureTimeEnabled(boolean b) { 959 getDefault().switchListDepartureTime = b; 960 } 961 962 public static boolean isUseSwitchListDepartureTimeEnabled() { 963 return getDefault().switchListDepartureTime; 964 } 965 966 public static void setPrintLocationCommentsEnabled(boolean enable) { 967 getDefault().printLocationComments = enable; 968 } 969 970 public static boolean isPrintLocationCommentsEnabled() { 971 return getDefault().printLocationComments; 972 } 973 974 public static void setPrintRouteCommentsEnabled(boolean enable) { 975 getDefault().printRouteComments = enable; 976 } 977 978 public static boolean isPrintRouteCommentsEnabled() { 979 return getDefault().printRouteComments; 980 } 981 982 public static void setPrintLoadsAndEmptiesEnabled(boolean enable) { 983 getDefault().printLoadsAndEmpties = enable; 984 } 985 986 public static boolean isPrintLoadsAndEmptiesEnabled() { 987 return getDefault().printLoadsAndEmpties; 988 } 989 990 public static void setPrintTrainScheduleNameEnabled(boolean enable) { 991 getDefault().printTrainScheduleName = enable; 992 } 993 994 public static boolean isPrintTrainScheduleNameEnabled() { 995 return getDefault().printTrainScheduleName; 996 } 997 998 public static void set12hrFormatEnabled(boolean enable) { 999 getDefault().use12hrFormat = enable; 1000 } 1001 1002 public static boolean is12hrFormatEnabled() { 1003 return getDefault().use12hrFormat; 1004 } 1005 1006 public static void setPrintValidEnabled(boolean enable) { 1007 getDefault().printValid = enable; 1008 } 1009 1010 public static boolean isPrintValidEnabled() { 1011 return getDefault().printValid; 1012 } 1013 1014 public static void setSortByTrackNameEnabled(boolean enable) { 1015 getDefault().sortByTrack = enable; 1016 } 1017 1018 /** 1019 * when true manifest work is sorted by track names. 1020 * 1021 * @return true if work at a location is to be sorted by track names. 1022 */ 1023 public static boolean isSortByTrackNameEnabled() { 1024 return getDefault().sortByTrack; 1025 } 1026 1027 public static void setPrintHeadersEnabled(boolean enable) { 1028 getDefault().printHeaders = enable; 1029 } 1030 1031 public static boolean isPrintHeadersEnabled() { 1032 return getDefault().printHeaders; 1033 } 1034 1035 public static void setPrintNoPageBreaksEnabled(boolean enable) { 1036 getDefault().printNoPageBreaks = enable; 1037 } 1038 1039 public static boolean isPrintNoPageBreaksEnabled() { 1040 return getDefault().printNoPageBreaks; 1041 } 1042 1043 public static void setPrintHeaderLine1Enabled(boolean enable) { 1044 getDefault().printHeaderLine1 = enable; 1045 } 1046 1047 public static boolean isPrintHeaderLine1Enabled() { 1048 return getDefault().printHeaderLine1; 1049 } 1050 1051 public static void setPrintHeaderLine2Enabled(boolean enable) { 1052 getDefault().printHeaderLine2 = enable; 1053 } 1054 1055 public static boolean isPrintHeaderLine2Enabled() { 1056 return getDefault().printHeaderLine2; 1057 } 1058 1059 public static void setPrintHeaderLine3Enabled(boolean enable) { 1060 getDefault().printHeaderLine3 = enable; 1061 } 1062 1063 public static boolean isPrintHeaderLine3Enabled() { 1064 return getDefault().printHeaderLine3; 1065 } 1066 1067 public static void setHorizontalLineAdjustment(int value) { 1068 getDefault().horizontalLineAdjustment = value; 1069 } 1070 1071 public static int getHorizontalLineAdjustment() { 1072 return getDefault().horizontalLineAdjustment; 1073 } 1074 1075 public static void setPrintCabooseLoadEnabled(boolean enable) { 1076 getDefault().printCabooseLoad = enable; 1077 } 1078 1079 public static boolean isPrintCabooseLoadEnabled() { 1080 return getDefault().printCabooseLoad; 1081 } 1082 1083 public static void setPrintPassengerLoadEnabled(boolean enable) { 1084 getDefault().printPassengerLoad = enable; 1085 } 1086 1087 public static boolean isPrintPassengerLoadEnabled() { 1088 return getDefault().printPassengerLoad; 1089 } 1090 1091 public static void setShowTrackMovesEnabled(boolean enable) { 1092 boolean old = getDefault().showTrackMoves; 1093 getDefault().showTrackMoves = enable; 1094 setDirtyAndFirePropertyChange(SHOW_TRACK_MOVES_PROPERTY_CHANGE, old, enable); 1095 } 1096 1097 public static boolean isShowTrackMovesEnabled() { 1098 return getDefault().showTrackMoves; 1099 } 1100 1101 public static void setSwitchTime(int minutes) { 1102 getDefault().carSwitchTime = minutes; 1103 } 1104 1105 public static int getSwitchTime() { 1106 return getDefault().carSwitchTime; 1107 } 1108 1109 public static void setTravelTime(int minutes) { 1110 int old = getTravelTime(); 1111 getDefault().travelTime = minutes; 1112 setDirtyAndFirePropertyChange(TRAVEL_TIME_PROPERTY_CHANGE, old, minutes); 1113 } 1114 1115 public static int getTravelTime() { 1116 return getDefault().travelTime; 1117 } 1118 1119 public static void setTrainIconColorNorth(String color) { 1120 getDefault().iconNorthColor = color; 1121 } 1122 1123 public static String getTrainIconColorNorth() { 1124 return getDefault().iconNorthColor; 1125 } 1126 1127 public static void setTrainIconColorSouth(String color) { 1128 getDefault().iconSouthColor = color; 1129 } 1130 1131 public static String getTrainIconColorSouth() { 1132 return getDefault().iconSouthColor; 1133 } 1134 1135 public static void setTrainIconColorEast(String color) { 1136 getDefault().iconEastColor = color; 1137 } 1138 1139 public static String getTrainIconColorEast() { 1140 return getDefault().iconEastColor; 1141 } 1142 1143 public static void setTrainIconColorWest(String color) { 1144 getDefault().iconWestColor = color; 1145 } 1146 1147 public static String getTrainIconColorWest() { 1148 return getDefault().iconWestColor; 1149 } 1150 1151 public static void setTrainIconColorLocal(String color) { 1152 getDefault().iconLocalColor = color; 1153 } 1154 1155 public static String getTrainIconColorLocal() { 1156 return getDefault().iconLocalColor; 1157 } 1158 1159 public static void setTrainIconColorTerminate(String color) { 1160 getDefault().iconTerminateColor = color; 1161 } 1162 1163 public static String getTrainIconColorTerminate() { 1164 return getDefault().iconTerminateColor; 1165 } 1166 1167 public static String getFontName() { 1168 return getDefault().fontName; 1169 } 1170 1171 public static void setFontName(String name) { 1172 getDefault().fontName = name; 1173 } 1174 1175 public static int getManifestFontSize() { 1176 return getDefault().manifestFontSize; 1177 } 1178 1179 public static void setManifestFontSize(int size) { 1180 getDefault().manifestFontSize = size; 1181 } 1182 1183 public static Sides getPrintDuplexSides() { 1184 return getDefault().sides; 1185 } 1186 1187 public static void setPrintDuplexSides(Sides sides) { 1188 getDefault().sides = sides; 1189 } 1190 1191 public static boolean isPrintPageHeaderEnabled() { 1192 return getDefault().printHeader; 1193 } 1194 1195 public static void setPrintPageHeaderEnabled(boolean enable) { 1196 getDefault().printHeader = enable; 1197 } 1198 1199 public static int getBuildReportFontSize() { 1200 return getDefault().buildReportFontSize; 1201 } 1202 1203 public static void setBuildReportFontSize(int size) { 1204 getDefault().buildReportFontSize = size; 1205 } 1206 1207 public static String getManifestOrientation() { 1208 return getDefault().manifestOrientation; 1209 } 1210 1211 public static void setManifestOrientation(String orientation) { 1212 getDefault().manifestOrientation = orientation; 1213 } 1214 1215 public static String getSwitchListOrientation() { 1216 if (isSwitchListFormatSameAsManifest()) { 1217 return getDefault().manifestOrientation; 1218 } else { 1219 return getDefault().switchListOrientation; 1220 } 1221 } 1222 1223 public static void setSwitchListOrientation(String orientation) { 1224 getDefault().switchListOrientation = orientation; 1225 } 1226 1227 public static boolean isTabEnabled() { 1228 return getDefault().tab; 1229 } 1230 1231 public static void setTabEnabled(boolean enable) { 1232 getDefault().tab = enable; 1233 } 1234 1235 public static int getTab1Length() { 1236 return getDefault().tab1CharLength; 1237 } 1238 1239 public static void setTab1length(int length) { 1240 getDefault().tab1CharLength = length; 1241 } 1242 1243 public static int getTab2Length() { 1244 return getDefault().tab2CharLength; 1245 } 1246 1247 public static void setTab2length(int length) { 1248 getDefault().tab2CharLength = length; 1249 } 1250 1251 public static int getTab3Length() { 1252 return getDefault().tab3CharLength; 1253 } 1254 1255 public static void setTab3length(int length) { 1256 getDefault().tab3CharLength = length; 1257 } 1258 1259 public static int getManifestTabLength() { 1260 return getDefault().manifestTabLength; 1261 } 1262 1263 public static void setManifestTablength(int length) { 1264 getDefault().manifestTabLength = length; 1265 } 1266 1267 public static String getManifestFormat() { 1268 return getDefault().manifestFormat; 1269 } 1270 1271 /** 1272 * Sets the format for manifests 1273 * 1274 * @param format STANDARD_FORMAT, TWO_COLUMN_FORMAT, or TWO_COLUMN_TRACK_FORMAT 1275 */ 1276 public static void setManifestFormat(String format) { 1277 getDefault().manifestFormat = format; 1278 } 1279 1280 public static boolean isCarLoggerEnabled() { 1281 return getDefault().carLogger; 1282 } 1283 1284 public static void setCarLoggerEnabled(boolean enable) { 1285 getDefault().carLogger = enable; 1286 InstanceManager.getDefault(RollingStockLogger.class).enableCarLogging(enable); 1287 } 1288 1289 public static boolean isEngineLoggerEnabled() { 1290 return getDefault().engineLogger; 1291 } 1292 1293 public static void setEngineLoggerEnabled(boolean enable) { 1294 getDefault().engineLogger = enable; 1295 InstanceManager.getDefault(RollingStockLogger.class).enableEngineLogging(enable); 1296 } 1297 1298 public static boolean isTrainLoggerEnabled() { 1299 return getDefault().trainLogger; 1300 } 1301 1302 public static void setTrainLoggerEnabled(boolean enable) { 1303 getDefault().trainLogger = enable; 1304 InstanceManager.getDefault(TrainLogger.class).enableTrainLogging(enable); 1305 } 1306 1307 public static boolean isSaveTrainManifestsEnabled() { 1308 return getDefault().saveTrainManifests; 1309 } 1310 1311 public static void setSaveTrainManifestsEnabled(boolean enable) { 1312 boolean old = getDefault().saveTrainManifests; 1313 getDefault().saveTrainManifests = enable; 1314 setDirtyAndFirePropertyChange(SAVE_TRAIN_MANIFEST_PROPERTY_CHANGE, old, enable); 1315 } 1316 1317 public static String getPickupEnginePrefix() { 1318 return getDefault().pickupEnginePrefix; 1319 } 1320 1321 public static void setPickupEnginePrefix(String prefix) { 1322 getDefault().pickupEnginePrefix = prefix; 1323 } 1324 1325 public static String getDropEnginePrefix() { 1326 return getDefault().dropEnginePrefix; 1327 } 1328 1329 public static void setDropEnginePrefix(String prefix) { 1330 getDefault().dropEnginePrefix = prefix; 1331 } 1332 1333 public static String getPickupCarPrefix() { 1334 return getDefault().pickupCarPrefix; 1335 } 1336 1337 public static void setPickupCarPrefix(String prefix) { 1338 getDefault().pickupCarPrefix = prefix; 1339 } 1340 1341 public static String getDropCarPrefix() { 1342 return getDefault().dropCarPrefix; 1343 } 1344 1345 public static void setDropCarPrefix(String prefix) { 1346 getDefault().dropCarPrefix = prefix; 1347 } 1348 1349 public static String getLocalPrefix() { 1350 return getDefault().localPrefix; 1351 } 1352 1353 public static void setLocalPrefix(String prefix) { 1354 getDefault().localPrefix = prefix; 1355 } 1356 1357 public static int getManifestPrefixLength() { 1358 int maxLength = getPickupEnginePrefix().length(); 1359 if (getDropEnginePrefix().length() > maxLength) { 1360 maxLength = getDropEnginePrefix().length(); 1361 } 1362 if (getPickupCarPrefix().length() > maxLength) { 1363 maxLength = getPickupCarPrefix().length(); 1364 } 1365 if (getDropCarPrefix().length() > maxLength) { 1366 maxLength = getDropCarPrefix().length(); 1367 } 1368 if (getLocalPrefix().length() > maxLength) { 1369 maxLength = getLocalPrefix().length(); 1370 } 1371 return maxLength; 1372 } 1373 1374 public static String getSwitchListPickupCarPrefix() { 1375 if (isSwitchListFormatSameAsManifest()) { 1376 return getDefault().pickupCarPrefix; 1377 } else { 1378 return getDefault().switchListPickupCarPrefix; 1379 } 1380 } 1381 1382 public static void setSwitchListPickupCarPrefix(String prefix) { 1383 getDefault().switchListPickupCarPrefix = prefix; 1384 } 1385 1386 public static String getSwitchListDropCarPrefix() { 1387 if (isSwitchListFormatSameAsManifest()) { 1388 return getDefault().dropCarPrefix; 1389 } else { 1390 return getDefault().switchListDropCarPrefix; 1391 } 1392 } 1393 1394 public static void setSwitchListDropCarPrefix(String prefix) { 1395 getDefault().switchListDropCarPrefix = prefix; 1396 } 1397 1398 public static String getSwitchListLocalPrefix() { 1399 if (isSwitchListFormatSameAsManifest()) { 1400 return getDefault().localPrefix; 1401 } else { 1402 return getDefault().switchListLocalPrefix; 1403 } 1404 } 1405 1406 public static void setSwitchListLocalPrefix(String prefix) { 1407 getDefault().switchListLocalPrefix = prefix; 1408 } 1409 1410 public static int getSwitchListPrefixLength() { 1411 int maxLength = getPickupEnginePrefix().length(); 1412 if (getDropEnginePrefix().length() > maxLength) { 1413 maxLength = getDropEnginePrefix().length(); 1414 } 1415 if (getSwitchListPickupCarPrefix().length() > maxLength) { 1416 maxLength = getSwitchListPickupCarPrefix().length(); 1417 } 1418 if (getSwitchListDropCarPrefix().length() > maxLength) { 1419 maxLength = getSwitchListDropCarPrefix().length(); 1420 } 1421 if (getSwitchListLocalPrefix().length() > maxLength) { 1422 maxLength = getSwitchListLocalPrefix().length(); 1423 } 1424 return maxLength; 1425 } 1426 1427 public static String[] getEngineAttributes() { 1428 return ENGINE_ATTRIBUTES.clone(); 1429 } 1430 1431 public static String[] getPickupEngineMessageFormat() { 1432 return getDefault().pickupEngineMessageFormat.clone(); 1433 } 1434 1435 public static void setPickupEngineMessageFormat(String[] format) { 1436 getDefault().pickupEngineMessageFormat = format; 1437 } 1438 1439 public static String[] getDropEngineMessageFormat() { 1440 return getDefault().dropEngineMessageFormat.clone(); 1441 } 1442 1443 public static void setDropEngineMessageFormat(String[] format) { 1444 getDefault().dropEngineMessageFormat = format; 1445 } 1446 1447 public static String[] getCarAttributes() { 1448 return CAR_ATTRIBUTES.clone(); 1449 } 1450 1451 public static String[] getPickupManifestMessageFormat() { 1452 return getDefault().pickupManifestMessageFormat.clone(); 1453 } 1454 1455 public static void setPickupManifestMessageFormat(String[] format) { 1456 getDefault().pickupManifestMessageFormat = format; 1457 } 1458 1459 public static String[] getDropManifestMessageFormat() { 1460 return getDefault().dropManifestMessageFormat.clone(); 1461 } 1462 1463 public static void setDropManifestMessageFormat(String[] format) { 1464 getDefault().dropManifestMessageFormat = format; 1465 } 1466 1467 public static String[] getLocalManifestMessageFormat() { 1468 return getDefault().localManifestMessageFormat.clone(); 1469 } 1470 1471 public static void setLocalManifestMessageFormat(String[] format) { 1472 getDefault().localManifestMessageFormat = format; 1473 } 1474 1475 public static String[] getMissingCarMessageFormat() { 1476 return getDefault().missingCarMessageFormat.clone(); 1477 } 1478 1479 public static void setMissingCarMessageFormat(String[] format) { 1480 getDefault().missingCarMessageFormat = format; 1481 } 1482 1483 public static String[] getPickupSwitchListMessageFormat() { 1484 if (isSwitchListFormatSameAsManifest()) { 1485 return getDefault().pickupManifestMessageFormat.clone(); 1486 } else { 1487 return getDefault().pickupSwitchListMessageFormat.clone(); 1488 } 1489 } 1490 1491 public static void setPickupSwitchListMessageFormat(String[] format) { 1492 getDefault().pickupSwitchListMessageFormat = format; 1493 } 1494 1495 public static String[] getDropSwitchListMessageFormat() { 1496 if (isSwitchListFormatSameAsManifest()) { 1497 return getDefault().dropManifestMessageFormat.clone(); 1498 } else { 1499 return getDefault().dropSwitchListMessageFormat.clone(); 1500 } 1501 } 1502 1503 public static void setDropSwitchListMessageFormat(String[] format) { 1504 getDefault().dropSwitchListMessageFormat = format; 1505 } 1506 1507 public static String[] getLocalSwitchListMessageFormat() { 1508 if (isSwitchListFormatSameAsManifest()) { 1509 return getDefault().localManifestMessageFormat.clone(); 1510 } else { 1511 return getDefault().localSwitchListMessageFormat.clone(); 1512 } 1513 } 1514 1515 public static void setLocalSwitchListMessageFormat(String[] format) { 1516 getDefault().localSwitchListMessageFormat = format; 1517 } 1518 1519 /** 1520 * Gets the manifest format for utility cars. The car's road, number, and color 1521 * are not printed. 1522 * 1523 * @return Utility car format 1524 */ 1525 public static String[] getPickupUtilityManifestMessageFormat() { 1526 return createUitlityCarMessageFormat(getPickupManifestMessageFormat()); 1527 } 1528 1529 public static String[] getDropUtilityManifestMessageFormat() { 1530 return createUitlityCarMessageFormat(getDropManifestMessageFormat()); 1531 } 1532 1533 public static String[] getLocalUtilityManifestMessageFormat() { 1534 return createUitlityCarMessageFormat(getLocalManifestMessageFormat()); 1535 } 1536 1537 public static String[] getPickupUtilitySwitchListMessageFormat() { 1538 return createUitlityCarMessageFormat(getPickupSwitchListMessageFormat()); 1539 } 1540 1541 public static String[] getDropUtilitySwitchListMessageFormat() { 1542 return createUitlityCarMessageFormat(getDropSwitchListMessageFormat()); 1543 } 1544 1545 public static String[] getLocalUtilitySwitchListMessageFormat() { 1546 return createUitlityCarMessageFormat(getLocalSwitchListMessageFormat()); 1547 } 1548 1549 private static String[] createUitlityCarMessageFormat(String[] format) { 1550 // remove car's road, number, color 1551 for (int i = 0; i < format.length; i++) { 1552 if (format[i].equals(ROAD)) { 1553 format[i] = NO_ROAD; 1554 } else if (format[i].equals(NUMBER)) { 1555 format[i] = NO_NUMBER; 1556 } else if (format[i].equals(COLOR)) { 1557 format[i] = NO_COLOR; 1558 } 1559 } 1560 return format; 1561 } 1562 1563 public static String[] getPickupTruncatedManifestMessageFormat() { 1564 return createTruncatedManifestMessageFormat(getPickupManifestMessageFormat()); 1565 } 1566 1567 public static String[] getDropTruncatedManifestMessageFormat() { 1568 return createTruncatedManifestMessageFormat(getDropManifestMessageFormat()); 1569 } 1570 1571 public static String[] createTruncatedManifestMessageFormat(String[] format) { 1572 // remove car's destination and location 1573 for (int i = 0; i < format.length; i++) { 1574 if (format[i].equals(DESTINATION)) { 1575 format[i] = NO_DESTINATION; 1576 } else if (format[i].equals(DEST_TRACK)) { 1577 format[i] = NO_DEST_TRACK; 1578 } else if (format[i].equals(LOCATION)) { 1579 format[i] = NO_LOCATION; 1580 } else if (format[i].equals(TRACK)) { 1581 format[i] = NO_TRACK; 1582 } 1583 } 1584 return format; 1585 } 1586 1587 public static String[] getPickupEngineTwoColumnByTrackMessageFormat() { 1588 return createTwoColumnByTrackPickupMessageFormat(getPickupEngineMessageFormat()); 1589 } 1590 1591 public static String[] getPickupTwoColumnByTrackManifestMessageFormat() { 1592 return createTwoColumnByTrackPickupMessageFormat(getPickupManifestMessageFormat()); 1593 } 1594 1595 public static String[] getPickupTwoColumnByTrackSwitchListMessageFormat() { 1596 return createTwoColumnByTrackPickupMessageFormat(getPickupSwitchListMessageFormat()); 1597 } 1598 1599 public static String[] getPickupTwoColumnByTrackUtilityManifestMessageFormat() { 1600 return createTwoColumnByTrackPickupMessageFormat(getPickupUtilityManifestMessageFormat()); 1601 } 1602 1603 public static String[] getPickupTwoColumnByTrackUtilitySwitchListMessageFormat() { 1604 return createTwoColumnByTrackPickupMessageFormat(getPickupUtilitySwitchListMessageFormat()); 1605 } 1606 1607 private static String[] createTwoColumnByTrackPickupMessageFormat(String[] format) { 1608 for (int i = 0; i < format.length; i++) { 1609 if (format[i].equals(LOCATION)) { 1610 format[i] = BLANK; 1611 } else if (format[i].equals(TRACK)) { 1612 format[i] = BLANK; 1613 } 1614 } 1615 return format; 1616 } 1617 1618 public static String[] getDropEngineTwoColumnByTrackMessageFormat() { 1619 return createTwoColumnByTrackDropMessageFormat(getDropEngineMessageFormat()); 1620 } 1621 1622 public static String[] getDropTwoColumnByTrackManifestMessageFormat() { 1623 return createTwoColumnByTrackDropMessageFormat(getDropManifestMessageFormat()); 1624 } 1625 1626 public static String[] getDropTwoColumnByTrackSwitchListMessageFormat() { 1627 return createTwoColumnByTrackDropMessageFormat(getDropSwitchListMessageFormat()); 1628 } 1629 1630 public static String[] getDropTwoColumnByTrackUtilityManifestMessageFormat() { 1631 return createTwoColumnByTrackDropMessageFormat(getDropUtilityManifestMessageFormat()); 1632 } 1633 1634 public static String[] getDropTwoColumnByTrackUtilitySwitchListMessageFormat() { 1635 return createTwoColumnByTrackDropMessageFormat(getDropUtilitySwitchListMessageFormat()); 1636 } 1637 1638 private static String[] createTwoColumnByTrackDropMessageFormat(String[] format) { 1639 for (int i = 0; i < format.length; i++) { 1640 if (format[i].equals(DESTINATION)) { 1641 format[i] = BLANK; 1642 } else if (format[i].equals(TRACK)) { 1643 format[i] = BLANK; 1644 } 1645 } 1646 return format; 1647 } 1648 1649 public static String getDropEngineTextColor() { 1650 return ColorUtil.colorToColorName(getDefault().dropEngineColor); 1651 } 1652 1653 public static void setDropEngineTextColor(String color) { 1654 setDropEngineColor(ColorUtil.stringToColor(color)); 1655 } 1656 1657 public static void setDropEngineColor(Color c) { 1658 getDefault().dropEngineColor = c; 1659 JmriColorChooser.addRecentColor(c); 1660 } 1661 1662 public static String getPickupEngineTextColor() { 1663 return ColorUtil.colorToColorName(getDefault().pickupEngineColor); 1664 } 1665 1666 public static void setPickupEngineTextColor(String color) { 1667 setPickupEngineColor(ColorUtil.stringToColor(color)); 1668 } 1669 1670 public static void setPickupEngineColor(Color c) { 1671 getDefault().pickupEngineColor = c; 1672 JmriColorChooser.addRecentColor(c); 1673 } 1674 1675 public static String getDropTextColor() { 1676 return ColorUtil.colorToColorName(getDefault().dropColor); 1677 } 1678 1679 public static void setDropTextColor(String color) { 1680 setDropColor(ColorUtil.stringToColor(color)); 1681 } 1682 1683 public static void setDropColor(Color c) { 1684 getDefault().dropColor = c; 1685 JmriColorChooser.addRecentColor(c); 1686 } 1687 1688 public static String getPickupTextColor() { 1689 return ColorUtil.colorToColorName(getDefault().pickupColor); 1690 } 1691 1692 public static void setPickupTextColor(String color) { 1693 setPickupColor(ColorUtil.stringToColor(color)); 1694 } 1695 1696 public static void setPickupColor(Color c) { 1697 getDefault().pickupColor = c; 1698 JmriColorChooser.addRecentColor(c); 1699 } 1700 1701 public static String getLocalTextColor() { 1702 return ColorUtil.colorToColorName(getDefault().localColor); 1703 } 1704 1705 public static void setLocalTextColor(String color) { 1706 setLocalColor(ColorUtil.stringToColor(color)); 1707 } 1708 1709 public static void setLocalColor(Color c) { 1710 getDefault().localColor = c; 1711 JmriColorChooser.addRecentColor(c); 1712 } 1713 1714 public static Color getPickupEngineColor() { 1715 return getDefault().pickupEngineColor; 1716 } 1717 1718 public static Color getDropEngineColor() { 1719 return getDefault().dropEngineColor; 1720 } 1721 1722 public static Color getPickupColor() { 1723 return getDefault().pickupColor; 1724 } 1725 1726 public static Color getDropColor() { 1727 return getDefault().dropColor; 1728 } 1729 1730 public static Color getLocalColor() { 1731 return getDefault().localColor; 1732 } 1733 1734 public static Color getColor(String colorName) { 1735 return ColorUtil.stringToColor(colorName); 1736 } 1737 1738 public static String getManifestLogoURL() { 1739 return getDefault().logoURL; 1740 } 1741 1742 public static void setManifestLogoURL(String pathName) { 1743 getDefault().logoURL = pathName; 1744 } 1745 1746 public static String getOwnerName() { 1747 return getDefault().ownerName; 1748 } 1749 1750 public static void setOwnerName(String name) { 1751 getDefault().ownerName = name; 1752 } 1753 1754 public static int getScaleRatio() { 1755 if (getDefault().scale == 0) { 1756 log.error("Scale not set"); 1757 } 1758 return getDefault().ratio; 1759 } 1760 1761 public static int getScaleTonRatio() { 1762 if (getDefault().scale == 0) { 1763 log.error("Scale not set"); 1764 } 1765 return getDefault().ratioTons; 1766 } 1767 1768 public static int getInitalWeight() { 1769 if (getDefault().scale == 0) { 1770 log.error("Scale not set"); 1771 } 1772 return getDefault().initWeight; 1773 } 1774 1775 public static int getAddWeight() { 1776 if (getDefault().scale == 0) { 1777 log.error("Scale not set"); 1778 } 1779 return getDefault().addWeight; 1780 } 1781 1782 public static int getScale() { 1783 return getDefault().scale; 1784 } 1785 1786 public static void setScale(int s) { 1787 getDefault().scale = s; 1788 switch (getDefault().scale) { 1789 case Z_SCALE: 1790 getDefault().ratio = Z_RATIO; 1791 getDefault().initWeight = Z_INITIAL_WEIGHT; 1792 getDefault().addWeight = Z_ADD_WEIGHT; 1793 getDefault().ratioTons = Z_RATIO_TONS; 1794 break; 1795 case N_SCALE: 1796 getDefault().ratio = N_RATIO; 1797 getDefault().initWeight = N_INITIAL_WEIGHT; 1798 getDefault().addWeight = N_ADD_WEIGHT; 1799 getDefault().ratioTons = N_RATIO_TONS; 1800 break; 1801 case TT_SCALE: 1802 getDefault().ratio = TT_RATIO; 1803 getDefault().initWeight = TT_INITIAL_WEIGHT; 1804 getDefault().addWeight = TT_ADD_WEIGHT; 1805 getDefault().ratioTons = TT_RATIO_TONS; 1806 break; 1807 case HOn3_SCALE: 1808 getDefault().ratio = HO_RATIO; 1809 getDefault().initWeight = HOn3_INITIAL_WEIGHT; 1810 getDefault().addWeight = HOn3_ADD_WEIGHT; 1811 getDefault().ratioTons = HOn3_RATIO_TONS; 1812 break; 1813 case OO_SCALE: 1814 getDefault().ratio = OO_RATIO; 1815 getDefault().initWeight = OO_INITIAL_WEIGHT; 1816 getDefault().addWeight = OO_ADD_WEIGHT; 1817 getDefault().ratioTons = OO_RATIO_TONS; 1818 break; 1819 case HO_SCALE: 1820 getDefault().ratio = HO_RATIO; 1821 getDefault().initWeight = HO_INITIAL_WEIGHT; 1822 getDefault().addWeight = HO_ADD_WEIGHT; 1823 getDefault().ratioTons = HO_RATIO_TONS; 1824 break; 1825 case Sn3_SCALE: 1826 getDefault().ratio = S_RATIO; 1827 getDefault().initWeight = Sn3_INITIAL_WEIGHT; 1828 getDefault().addWeight = Sn3_ADD_WEIGHT; 1829 getDefault().ratioTons = Sn3_RATIO_TONS; 1830 break; 1831 case S_SCALE: 1832 getDefault().ratio = S_RATIO; 1833 getDefault().initWeight = S_INITIAL_WEIGHT; 1834 getDefault().addWeight = S_ADD_WEIGHT; 1835 getDefault().ratioTons = S_RATIO_TONS; 1836 break; 1837 case On3_SCALE: 1838 getDefault().ratio = O_RATIO; 1839 getDefault().initWeight = On3_INITIAL_WEIGHT; 1840 getDefault().addWeight = On3_ADD_WEIGHT; 1841 getDefault().ratioTons = On3_RATIO_TONS; 1842 break; 1843 case O_SCALE: 1844 getDefault().ratio = O_RATIO; 1845 getDefault().initWeight = O_INITIAL_WEIGHT; 1846 getDefault().addWeight = O_ADD_WEIGHT; 1847 getDefault().ratioTons = O_RATIO_TONS; 1848 break; 1849 1850 case Gauge1_SCALE: 1851 getDefault().ratio = Gauge1_RATIO; 1852 getDefault().initWeight = G_INITIAL_WEIGHT; 1853 getDefault().addWeight = G_ADD_WEIGHT; 1854 getDefault().ratioTons = G_RATIO_TONS; 1855 break; 1856 case G_24_SCALE: 1857 getDefault().ratio = G_24_RATIO; 1858 getDefault().initWeight = G_INITIAL_WEIGHT; 1859 getDefault().addWeight = G_ADD_WEIGHT; 1860 getDefault().ratioTons = G_RATIO_TONS; 1861 break; 1862 default: 1863 log.error("Unknown scale"); 1864 } 1865 } 1866 1867 public static JComboBox<String> getManifestFormatComboBox() { 1868 JComboBox<String> box = new JComboBox<>(); 1869 box.addItem(STANDARD_FORMAT); 1870 box.addItem(TWO_COLUMN_FORMAT); 1871 box.addItem(TWO_COLUMN_TRACK_FORMAT); 1872 OperationsPanel.padComboBox(box, TWO_COLUMN_TRACK_FORMAT.length()); 1873 return box; 1874 } 1875 1876 public static JComboBox<String> getOrientationComboBox() { 1877 JComboBox<String> box = new JComboBox<>(); 1878 box.addItem(PORTRAIT); 1879 box.addItem(LANDSCAPE); 1880 box.addItem(HALFPAGE); 1881 box.addItem(HANDHELD); 1882 box.addItem(RECEIPT); 1883 OperationsPanel.padComboBox(box, LANDSCAPE.length()); 1884 return box; 1885 } 1886 1887 public static JComboBox<String> getSwitchListPageFormatComboBox() { 1888 JComboBox<String> box = new JComboBox<>(); 1889 box.addItem(PAGE_NORMAL); 1890 box.addItem(PAGE_PER_TRAIN); 1891 box.addItem(PAGE_PER_VISIT); 1892 OperationsPanel.padComboBox(box, PAGE_PER_TRAIN.length()); 1893 return box; 1894 } 1895 1896 public static JComboBox<String> getEngineMessageComboBox() { 1897 JComboBox<String> box = new JComboBox<>(); 1898 box.addItem(BLANK); 1899 for (String attribute : getEngineAttributes()) { 1900 box.addItem(attribute); 1901 } 1902 if (isTabEnabled()) { 1903 box.addItem(TAB); 1904 box.addItem(TAB2); 1905 box.addItem(TAB3); 1906 } 1907 return box; 1908 } 1909 1910 public static JComboBox<String> getCarMessageComboBox() { 1911 JComboBox<String> box = new JComboBox<>(); 1912 box.addItem(BLANK); 1913 for (String attribute : getCarAttributes()) { 1914 box.addItem(attribute); 1915 } 1916 if (isTabEnabled()) { 1917 box.addItem(TAB); 1918 box.addItem(TAB2); 1919 box.addItem(TAB3); 1920 } 1921 return box; 1922 } 1923 1924 /** 1925 * 1926 * @return JComboBox loaded with the strings (North, South, East, West) showing 1927 * the available train directions for this railroad 1928 */ 1929 public static JComboBox<String> getTrainDirectionComboBox() { 1930 JComboBox<String> box = new JComboBox<>(); 1931 for (String direction : getTrainDirectionList()) { 1932 box.addItem(direction); 1933 } 1934 return box; 1935 } 1936 1937 /** 1938 * Get train directions String format 1939 * 1940 * @return List of valid train directions 1941 */ 1942 public static List<String> getTrainDirectionList() { 1943 List<String> directions = new ArrayList<>(); 1944 if ((getDefault().traindir & EAST) == EAST) { 1945 directions.add(EAST_DIR); 1946 } 1947 if ((getDefault().traindir & WEST) == WEST) { 1948 directions.add(WEST_DIR); 1949 } 1950 if ((getDefault().traindir & NORTH) == NORTH) { 1951 directions.add(NORTH_DIR); 1952 } 1953 if ((getDefault().traindir & SOUTH) == SOUTH) { 1954 directions.add(SOUTH_DIR); 1955 } 1956 return directions; 1957 } 1958 1959 /** 1960 * Converts binary direction to String direction 1961 * 1962 * @param direction EAST, WEST, NORTH, SOUTH 1963 * @return String representation of a direction 1964 */ 1965 public static String getDirectionString(int direction) { 1966 switch (direction) { 1967 case EAST: 1968 return EAST_DIR; 1969 case WEST: 1970 return WEST_DIR; 1971 case NORTH: 1972 return NORTH_DIR; 1973 case SOUTH: 1974 return SOUTH_DIR; 1975 default: 1976 return "unknown"; // NOI18N 1977 } 1978 } 1979 1980 /** 1981 * Converts binary direction to a set of String directions 1982 * 1983 * @param directions EAST, WEST, NORTH, SOUTH 1984 * @return String[] representation of a set of directions 1985 */ 1986 public static String[] getDirectionStrings(int directions) { 1987 String[] dir = new String[4]; 1988 int i = 0; 1989 if ((directions & EAST) == EAST) { 1990 dir[i++] = EAST_DIR; 1991 } 1992 if ((directions & WEST) == WEST) { 1993 dir[i++] = WEST_DIR; 1994 } 1995 if ((directions & NORTH) == NORTH) { 1996 dir[i++] = NORTH_DIR; 1997 } 1998 if ((directions & SOUTH) == SOUTH) { 1999 dir[i++] = SOUTH_DIR; 2000 } 2001 return dir; 2002 } 2003 2004 /** 2005 * Converts String direction to binary direction 2006 * 2007 * @param direction EAST_DIR WEST_DIR NORTH_DIR SOUTH_DIR 2008 * @return integer representation of a direction 2009 */ 2010 public static int getDirectionInt(String direction) { 2011 if (direction.equals(EAST_DIR)) { 2012 return EAST; 2013 } else if (direction.equals(WEST_DIR)) { 2014 return WEST; 2015 } else if (direction.equals(NORTH_DIR)) { 2016 return NORTH; 2017 } else if (direction.equals(SOUTH_DIR)) { 2018 return SOUTH; 2019 } else { 2020 return 0; // return unknown 2021 } 2022 } 2023 2024 public static void setDayToName(String day, String name) { 2025 if (name != null) { 2026 getDefault().hashTableDayToName.put(day, name); 2027 } 2028 } 2029 2030 public static String getDayToName(String day) { 2031 return getDefault().hashTableDayToName.get(day); 2032 } 2033 2034 // must synchronize changes with operation-config.dtd 2035 public static Element store() { 2036 Element values; 2037 Element e = new Element(Xml.OPERATIONS); 2038 2039 // only store railroad name if it doesn't match the preferences railroad name 2040 if (!InstanceManager.getDefault(WebServerPreferences.class).getRailroadName().equals(getRailroadName())) { 2041 e.addContent(values = new Element(Xml.RAIL_ROAD)); 2042 values.setAttribute(Xml.NAME, getRailroadName()); 2043 } 2044 2045 e.addContent(values = new Element(Xml.SETUP)); 2046 values.setAttribute(Xml.COMMENT, getComment()); 2047 2048 e.addContent(values = new Element(Xml.SETTINGS)); 2049 values.setAttribute(Xml.MAIN_MENU, isMainMenuEnabled() ? Xml.TRUE : Xml.FALSE); 2050 values.setAttribute(Xml.CLOSE_ON_SAVE, isCloseWindowOnSaveEnabled() ? Xml.TRUE : Xml.FALSE); 2051 values.setAttribute(Xml.AUTO_SAVE, isAutoSaveEnabled() ? Xml.TRUE : Xml.FALSE); 2052 values.setAttribute(Xml.AUTO_BACKUP, isAutoBackupEnabled() ? Xml.TRUE : Xml.FALSE); 2053 values.setAttribute(Xml.TRAIN_DIRECTION, Integer.toString(getTrainDirection())); 2054 values.setAttribute(Xml.TRAIN_LENGTH, Integer.toString(getMaxTrainLength())); 2055 values.setAttribute(Xml.MAX_ENGINES, Integer.toString(getMaxNumberEngines())); 2056 values.setAttribute(Xml.HPT, Double.toString(getHorsePowerPerTon())); 2057 values.setAttribute(Xml.SCALE, Integer.toString(getScale())); 2058 values.setAttribute(Xml.CAR_TYPES, getCarTypes()); 2059 values.setAttribute(Xml.SWITCH_TIME, Integer.toString(getSwitchTime())); 2060 values.setAttribute(Xml.TRAVEL_TIME, Integer.toString(getTravelTime())); 2061 values.setAttribute(Xml.SHOW_VALUE, isValueEnabled() ? Xml.TRUE : Xml.FALSE); 2062 values.setAttribute(Xml.VALUE_LABEL, getValueLabel()); 2063 values.setAttribute(Xml.SHOW_RFID, isRfidEnabled() ? Xml.TRUE : Xml.FALSE); 2064 values.setAttribute(Xml.RFID_LABEL, getRfidLabel()); 2065 values.setAttribute(Xml.LENGTH_UNIT, getLengthUnit()); 2066 values.setAttribute(Xml.YEAR_MODELED, getYearModeled()); 2067 2068 e.addContent(values = new Element(Xml.PICKUP_ENG_FORMAT)); 2069 storeXmlMessageFormat(values, getPickupEnginePrefix(), getPickupEngineMessageFormat()); 2070 2071 e.addContent(values = new Element(Xml.DROP_ENG_FORMAT)); 2072 storeXmlMessageFormat(values, getDropEnginePrefix(), getDropEngineMessageFormat()); 2073 2074 e.addContent(values = new Element(Xml.PICKUP_CAR_FORMAT)); 2075 storeXmlMessageFormat(values, getPickupCarPrefix(), getPickupManifestMessageFormat()); 2076 2077 e.addContent(values = new Element(Xml.DROP_CAR_FORMAT)); 2078 storeXmlMessageFormat(values, getDropCarPrefix(), getDropManifestMessageFormat()); 2079 2080 e.addContent(values = new Element(Xml.LOCAL_FORMAT)); 2081 storeXmlMessageFormat(values, getLocalPrefix(), getLocalManifestMessageFormat()); 2082 2083 e.addContent(values = new Element(Xml.MISSING_CAR_FORMAT)); 2084 storeXmlMessageFormat(values, NONE, getMissingCarMessageFormat()); 2085 2086 e.addContent(values = new Element(Xml.SWITCH_LIST)); 2087 values.setAttribute(Xml.SAME_AS_MANIFEST, isSwitchListFormatSameAsManifest() ? Xml.TRUE : Xml.FALSE); 2088 values.setAttribute(Xml.REAL_TIME, isSwitchListRealTime() ? Xml.TRUE : Xml.FALSE); 2089 values.setAttribute(Xml.ALL_TRAINS, isSwitchListAllTrainsEnabled() ? Xml.TRUE : Xml.FALSE); 2090 2091 // save switch list format 2092 String format = Xml.PAGE_NORMAL; 2093 if (getSwitchListPageFormat().equals(PAGE_PER_TRAIN)) { 2094 format = Xml.PAGE_PER_TRAIN; 2095 values.setAttribute(Xml.PAGE_MODE, Xml.TRUE); // backwards compatible for versions before 3.11 2096 } else if (getSwitchListPageFormat().equals(PAGE_PER_VISIT)) { 2097 format = Xml.PAGE_PER_VISIT; 2098 } 2099 values.setAttribute(Xml.PAGE_FORMAT, format); 2100 2101 values.setAttribute(Xml.PRINT_ROUTE_LOCATION, isSwitchListRouteLocationCommentEnabled() ? Xml.TRUE : Xml.FALSE); 2102 values.setAttribute(Xml.TRACK_SUMMARY, isPrintTrackSummaryEnabled() ? Xml.TRUE : Xml.FALSE); 2103 values.setAttribute(Xml.USE_DEPARTURE_TIME, isUseSwitchListDepartureTimeEnabled() ? Xml.TRUE : Xml.FALSE); 2104 2105 e.addContent(values = new Element(Xml.SWITCH_LIST_PICKUP_CAR_FORMAT)); 2106 storeXmlMessageFormat(values, getSwitchListPickupCarPrefix(), getPickupSwitchListMessageFormat()); 2107 2108 e.addContent(values = new Element(Xml.SWITCH_LIST_DROP_CAR_FORMAT)); 2109 storeXmlMessageFormat(values, getSwitchListDropCarPrefix(), getDropSwitchListMessageFormat()); 2110 2111 e.addContent(values = new Element(Xml.SWITCH_LIST_LOCAL_FORMAT)); 2112 storeXmlMessageFormat(values, getSwitchListLocalPrefix(), getLocalSwitchListMessageFormat()); 2113 2114 e.addContent(values = new Element(Xml.PANEL)); 2115 values.setAttribute(Xml.NAME, getPanelName()); 2116 values.setAttribute(Xml.TRAIN_ICONXY, isTrainIconCordEnabled() ? Xml.TRUE : Xml.FALSE); 2117 values.setAttribute(Xml.TRAIN_ICON_APPEND, isTrainIconAppendEnabled() ? Xml.TRUE : Xml.FALSE); 2118 2119 e.addContent(values = new Element(Xml.FONT_NAME)); 2120 values.setAttribute(Xml.NAME, getFontName()); 2121 2122 e.addContent(values = new Element(Xml.FONT_SIZE)); 2123 values.setAttribute(Xml.SIZE, Integer.toString(getManifestFontSize())); 2124 2125 e.addContent(values = new Element(Xml.PAGE_ORIENTATION)); 2126 values.setAttribute(Xml.MANIFEST, getManifestOrientation()); 2127 values.setAttribute(Xml.SWITCH_LIST, getSwitchListOrientation()); 2128 2129 e.addContent(values = new Element(Xml.PRINT_DUPLEX)); 2130 values.setAttribute(Xml.NAME, getPrintDuplexSides().toString()); 2131 2132 e.addContent(values = new Element(Xml.MANIFEST_COLORS)); 2133 values.setAttribute(Xml.DROP_ENGINE_COLOR, getDropEngineTextColor()); 2134 values.setAttribute(Xml.PICKUP_ENGINE_COLOR, getPickupEngineTextColor()); 2135 values.setAttribute(Xml.DROP_COLOR, getDropTextColor()); 2136 values.setAttribute(Xml.PICKUP_COLOR, getPickupTextColor()); 2137 values.setAttribute(Xml.LOCAL_COLOR, getLocalTextColor()); 2138 2139 e.addContent(values = new Element(Xml.TAB)); 2140 values.setAttribute(Xml.ENABLED, isTabEnabled() ? Xml.TRUE : Xml.FALSE); 2141 values.setAttribute(Xml.LENGTH, Integer.toString(getTab1Length())); 2142 values.setAttribute(Xml.TAB2_LENGTH, Integer.toString(getTab2Length())); 2143 values.setAttribute(Xml.TAB3_LENGTH, Integer.toString(getTab3Length())); 2144 values.setAttribute(Xml.MANIFEST_TAB_LENGTH, Integer.toString(getManifestTabLength())); 2145 2146 e.addContent(values = new Element(Xml.MANIFEST)); 2147 values.setAttribute(Xml.PRINT_LOC_COMMENTS, isPrintLocationCommentsEnabled() ? Xml.TRUE : Xml.FALSE); 2148 values.setAttribute(Xml.PRINT_ROUTE_COMMENTS, isPrintRouteCommentsEnabled() ? Xml.TRUE : Xml.FALSE); 2149 values.setAttribute(Xml.PRINT_LOADS_EMPTIES, isPrintLoadsAndEmptiesEnabled() ? Xml.TRUE : Xml.FALSE); 2150 values.setAttribute(Xml.PRINT_TRAIN_SCHEDULE, isPrintTrainScheduleNameEnabled() ? Xml.TRUE : Xml.FALSE); 2151 values.setAttribute(Xml.USE12HR_FORMAT, is12hrFormatEnabled() ? Xml.TRUE : Xml.FALSE); 2152 values.setAttribute(Xml.PRINT_VALID, isPrintValidEnabled() ? Xml.TRUE : Xml.FALSE); 2153 values.setAttribute(Xml.SORT_BY_TRACK, isSortByTrackNameEnabled() ? Xml.TRUE : Xml.FALSE); 2154 values.setAttribute(Xml.PRINT_PAGE_HEADER, isPrintPageHeaderEnabled() ? Xml.TRUE : Xml.FALSE); 2155 values.setAttribute(Xml.PRINT_HEADERS, isPrintHeadersEnabled() ? Xml.TRUE : Xml.FALSE); 2156 values.setAttribute(Xml.PRINT_NO_PAGE_BREAKS, isPrintNoPageBreaksEnabled() ? Xml.TRUE : Xml.FALSE); 2157 values.setAttribute(Xml.TRUNCATE, isPrintTruncateManifestEnabled() ? Xml.TRUE : Xml.FALSE); 2158 values.setAttribute(Xml.USE_DEPARTURE_TIME, isUseDepartureTimeEnabled() ? Xml.TRUE : Xml.FALSE); 2159 values.setAttribute(Xml.USE_EDITOR, isManifestEditorEnabled() ? Xml.TRUE : Xml.FALSE); 2160 values.setAttribute(Xml.PRINT_CABOOSE_LOAD, isPrintCabooseLoadEnabled() ? Xml.TRUE : Xml.FALSE); 2161 values.setAttribute(Xml.PRINT_PASSENGER_LOAD, isPrintPassengerLoadEnabled() ? Xml.TRUE : Xml.FALSE); 2162 values.setAttribute(Xml.GROUP_MOVES, isGroupCarMovesEnabled() ? Xml.TRUE : Xml.FALSE); 2163 values.setAttribute(Xml.PRINT_LOCO_LAST, isPrintLocoLastEnabled() ? Xml.TRUE : Xml.FALSE); 2164 values.setAttribute(Xml.HAZARDOUS_MSG, getHazardousMsg()); 2165 2166 // new format June 2014 2167 e.addContent(values = new Element(Xml.MANIFEST_FORMAT)); 2168 2169 // save manifest format 2170 String value = Xml.STANDARD; 2171 if (getManifestFormat().equals(TWO_COLUMN_FORMAT)) { 2172 value = Xml.TWO_COLUMN; 2173 } else if (getManifestFormat().equals(TWO_COLUMN_TRACK_FORMAT)) { 2174 value = Xml.TWO_COLUMN_TRACK; 2175 } 2176 values.setAttribute(Xml.VALUE, value); 2177 2178 // new format June 2025 2179 e.addContent(values = new Element(Xml.HEADER_LINES)); 2180 values.setAttribute(Xml.PRINT_HEADER_LINE1, isPrintHeaderLine1Enabled() ? Xml.TRUE : Xml.FALSE); 2181 values.setAttribute(Xml.PRINT_HEADER_LINE2, isPrintHeaderLine2Enabled() ? Xml.TRUE : Xml.FALSE); 2182 values.setAttribute(Xml.PRINT_HEADER_LINE3, isPrintHeaderLine3Enabled() ? Xml.TRUE : Xml.FALSE); 2183 values.setAttribute(Xml.HORIZONTAL_LINE_ADJ, Integer.toString(getHorizontalLineAdjustment())); 2184 2185 if (!getManifestLogoURL().equals(NONE)) { 2186 values = new Element(Xml.MANIFEST_LOGO); 2187 values.setAttribute(Xml.NAME, getManifestLogoURL()); 2188 e.addContent(values); 2189 } 2190 2191 // manifest save file options 2192 e.addContent(values = new Element(Xml.MANIFEST_FILE_OPTIONS)); 2193 values.setAttribute(Xml.MANIFEST_SAVE, isSaveTrainManifestsEnabled() ? Xml.TRUE : Xml.FALSE); 2194 2195 e.addContent(values = new Element(Xml.BUILD_OPTIONS)); 2196 values.setAttribute(Xml.AGGRESSIVE, isBuildAggressive() ? Xml.TRUE : Xml.FALSE); 2197 values.setAttribute(Xml.NUMBER_PASSES, Integer.toString(getNumberPasses())); 2198 values.setAttribute(Xml.ON_TIME, isBuildOnTime() ? Xml.TRUE : Xml.FALSE); 2199 values.setAttribute(Xml.DWELL_TIME, Integer.toString(getDwellTime())); 2200 2201 values.setAttribute(Xml.ALLOW_LOCAL_INTERCHANGE, isLocalInterchangeMovesEnabled() ? Xml.TRUE : Xml.FALSE); 2202 values.setAttribute(Xml.ALLOW_LOCAL_SPUR, isLocalSpurMovesEnabled() ? Xml.TRUE : Xml.FALSE); 2203 values.setAttribute(Xml.ALLOW_LOCAL_YARD, isLocalYardMovesEnabled() ? Xml.TRUE : Xml.FALSE); 2204 2205 values.setAttribute(Xml.STAGING_RESTRICTION_ENABLED, isStagingTrainCheckEnabled() ? Xml.TRUE : Xml.FALSE); 2206 values.setAttribute(Xml.STAGING_TRACK_AVAIL, isStagingTrackImmediatelyAvail() ? Xml.TRUE : Xml.FALSE); 2207 values.setAttribute(Xml.ALLOW_RETURN_STAGING, isStagingAllowReturnEnabled() ? Xml.TRUE : Xml.FALSE); 2208 values.setAttribute(Xml.PROMPT_STAGING_ENABLED, isStagingPromptFromEnabled() ? Xml.TRUE : Xml.FALSE); 2209 values.setAttribute(Xml.PROMPT_TO_STAGING_ENABLED, isStagingPromptToEnabled() ? Xml.TRUE : Xml.FALSE); 2210 values.setAttribute(Xml.STAGING_TRY_NORMAL, isStagingTryNormalBuildEnabled() ? Xml.TRUE : Xml.FALSE); 2211 2212 values.setAttribute(Xml.GENERATE_CSV_MANIFEST, isGenerateCsvManifestEnabled() ? Xml.TRUE : Xml.FALSE); 2213 values.setAttribute(Xml.GENERATE_CSV_SWITCH_LIST, isGenerateCsvSwitchListEnabled() ? Xml.TRUE : Xml.FALSE); 2214 2215 e.addContent(values = new Element(Xml.BUILD_REPORT)); 2216 values.setAttribute(Xml.LEVEL, getBuildReportLevel()); 2217 values.setAttribute(Xml.ROUTER_LEVEL, getRouterBuildReportLevel()); 2218 values.setAttribute(Xml.USE_EDITOR, isBuildReportEditorEnabled() ? Xml.TRUE : Xml.FALSE); 2219 values.setAttribute(Xml.INDENT, isBuildReportIndentEnabled() ? Xml.TRUE : Xml.FALSE); 2220 values.setAttribute(Xml.ALWAYS_PREVIEW, isBuildReportAlwaysPreviewEnabled() ? Xml.TRUE : Xml.FALSE); 2221 values.setAttribute(Xml.FONT_SIZE, Integer.toString(getBuildReportFontSize())); 2222 2223 // new format for router options 2224 e.addContent(values = new Element(Xml.ROUTER)); 2225 values.setAttribute(Xml.CAR_ROUTING_ENABLED, isCarRoutingEnabled() ? Xml.TRUE : Xml.FALSE); 2226 values.setAttribute(Xml.CAR_ROUTING_VIA_YARDS, isCarRoutingViaYardsEnabled() ? Xml.TRUE : Xml.FALSE); 2227 values.setAttribute(Xml.CAR_ROUTING_VIA_STAGING, isCarRoutingViaStagingEnabled() ? Xml.TRUE : Xml.FALSE); 2228 values.setAttribute(Xml.FORWARD_TO_YARD, isForwardToYardEnabled() ? Xml.TRUE : Xml.FALSE); 2229 values.setAttribute(Xml.ONLY_ACTIVE_TRAINS, isOnlyActiveTrainsEnabled() ? Xml.TRUE : Xml.FALSE); 2230 values.setAttribute(Xml.CHECK_CAR_DESTINATION, isCheckCarDestinationEnabled() ? Xml.TRUE : Xml.FALSE); 2231 2232 // new format for logger options 2233 e.addContent(values = new Element(Xml.LOGGER)); 2234 values.setAttribute(Xml.CAR_LOGGER, isCarLoggerEnabled() ? Xml.TRUE : Xml.FALSE); 2235 values.setAttribute(Xml.ENGINE_LOGGER, isEngineLoggerEnabled() ? Xml.TRUE : Xml.FALSE); 2236 values.setAttribute(Xml.TRAIN_LOGGER, isTrainLoggerEnabled() ? Xml.TRUE : Xml.FALSE); 2237 2238 e.addContent(values = new Element(Xml.OWNER)); 2239 values.setAttribute(Xml.NAME, getOwnerName()); 2240 2241 e.addContent(values = new Element(Xml.ICON_COLOR)); 2242 values.setAttribute(Xml.NORTH, getTrainIconColorNorth()); 2243 values.setAttribute(Xml.SOUTH, getTrainIconColorSouth()); 2244 values.setAttribute(Xml.EAST, getTrainIconColorEast()); 2245 values.setAttribute(Xml.WEST, getTrainIconColorWest()); 2246 values.setAttribute(Xml.LOCAL, getTrainIconColorLocal()); 2247 values.setAttribute(Xml.TERMINATE, getTrainIconColorTerminate()); 2248 2249 e.addContent(values = new Element(Xml.COMMENTS)); 2250 values.setAttribute(Xml.MISPLACED_CARS, getMiaComment()); 2251 2252 e.addContent(values = new Element(Xml.DISPLAY)); 2253 values.setAttribute(Xml.SHOW_TRACK_MOVES, isShowTrackMovesEnabled() ? Xml.TRUE : Xml.FALSE); 2254 2255 if (isVsdPhysicalLocationEnabled()) { 2256 e.addContent(values = new Element(Xml.VSD)); 2257 values.setAttribute(Xml.ENABLE_PHYSICAL_LOCATIONS, isVsdPhysicalLocationEnabled() ? Xml.TRUE : Xml.FALSE); 2258 } 2259 // Save CATS setting 2260 e.addContent(values = new Element(Xml.CATS)); 2261 values.setAttribute(Xml.EXACT_LOCATION_NAME, 2262 AbstractOperationsServer.isExactLoationNameEnabled() ? Xml.TRUE : Xml.FALSE); 2263 // day to name mapping 2264 e.addContent(values = new Element(Xml.DAY_NAME_MAP)); 2265 for (int i = 0; i < Control.numberOfDays; i++) { 2266 Element map; 2267 String day = Integer.toString(i); 2268 String name = getDefault().hashTableDayToName.get(day); 2269 if (name != null && !name.isBlank()) { 2270 values.addContent(map = new Element(Xml.MAP)); 2271 map.setAttribute(Xml.DAY, day); 2272 map.setAttribute(Xml.NAME, name); 2273 } 2274 } 2275 return e; 2276 } 2277 2278 private static void storeXmlMessageFormat(Element values, String prefix, String[] messageFormat) { 2279 values.setAttribute(Xml.PREFIX, prefix); 2280 StringBuilder buf = new StringBuilder(); 2281 stringToTagConversion(messageFormat); 2282 for (String attibute : messageFormat) { 2283 buf.append(attibute).append(","); 2284 } 2285 values.setAttribute(Xml.SETTING, buf.toString()); 2286 } 2287 2288 public static void load(Element e) { 2289 if (e.getChild(Xml.OPERATIONS) == null) { 2290 log.warn("OperationsPro settings values not found"); 2291 return; 2292 } 2293 Element operations = e.getChild(Xml.OPERATIONS); 2294 org.jdom2.Attribute a; 2295 2296 if ((operations.getChild(Xml.RAIL_ROAD) != null) && 2297 (a = operations.getChild(Xml.RAIL_ROAD).getAttribute(Xml.NAME)) != null) { 2298 String name = a.getValue(); 2299 log.debug("railroadName: {}", name); 2300 // code before 4.11 "useJmriRailroadName" when using the preferences railroad 2301 // name. 2302 // here for backwards compatibility 2303 if (!name.equals(Xml.USE_JMRI_RAILROAD_NAME)) { 2304 getDefault().railroadName = name; // don't set the dirty bit 2305 } 2306 } 2307 2308 if ((operations.getChild(Xml.SETUP) != null) && 2309 (a = operations.getChild(Xml.SETUP).getAttribute(Xml.COMMENT)) != null) { 2310 String comment = a.getValue(); 2311 log.debug("setup comment: {}", comment); 2312 getDefault().setupComment = comment; 2313 } 2314 2315 if (operations.getChild(Xml.SETTINGS) != null) { 2316 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.MAIN_MENU)) != null) { 2317 String enabled = a.getValue(); 2318 log.debug("mainMenu: {}", enabled); 2319 setMainMenuEnabled(enabled.equals(Xml.TRUE)); 2320 } 2321 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CLOSE_ON_SAVE)) != null) { 2322 String enabled = a.getValue(); 2323 log.debug("closeOnSave: {}", enabled); 2324 setCloseWindowOnSaveEnabled(enabled.equals(Xml.TRUE)); 2325 } 2326 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.TRAIN_DIRECTION)) != null) { 2327 String dir = a.getValue(); 2328 log.debug("direction: {}", dir); 2329 try { 2330 getDefault().traindir = Integer.parseInt(dir); 2331 } catch (NumberFormatException ee) { 2332 log.error("Train direction ({}) isn't a valid number", a.getValue()); 2333 } 2334 } 2335 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.TRAIN_LENGTH)) != null) { 2336 String length = a.getValue(); 2337 log.debug("Max train length: {}", length); 2338 try { 2339 setMaxTrainLength(Integer.parseInt(length)); 2340 } catch (NumberFormatException ee) { 2341 log.error("Train maximum length ({}) isn't a valid number", a.getValue()); 2342 } 2343 } 2344 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.MAX_ENGINES)) != null) { 2345 String size = a.getValue(); 2346 log.debug("Max number of engines: {}", size); 2347 try { 2348 setMaxNumberEngines(Integer.parseInt(size)); 2349 } catch (NumberFormatException ee) { 2350 log.error("Maximum number of engines ({}) isn't a valid number", a.getValue()); 2351 } 2352 } 2353 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.HPT)) != null) { 2354 String value = a.getValue(); 2355 log.debug("HPT: {}", value); 2356 try { 2357 setHorsePowerPerTon(Double.parseDouble(value)); 2358 } catch (NumberFormatException ee) { 2359 log.error("Train HPT ({}) isn't a valid number", a.getValue()); 2360 } 2361 } 2362 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SCALE)) != null) { 2363 String scale = a.getValue(); 2364 log.debug("scale: {}", scale); 2365 try { 2366 setScale(Integer.parseInt(scale)); 2367 } catch (NumberFormatException ee) { 2368 log.error("Scale ({}) isn't a valid number", a.getValue()); 2369 } 2370 } 2371 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_TYPES)) != null) { 2372 String types = a.getValue(); 2373 log.debug("CarTypes: {}", types); 2374 setCarTypes(types); 2375 } 2376 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SWITCH_TIME)) != null) { 2377 String minutes = a.getValue(); 2378 log.debug("switchTime: {}", minutes); 2379 try { 2380 setSwitchTime(Integer.parseInt(minutes)); 2381 } catch (NumberFormatException ee) { 2382 log.error("Switch time ({}) isn't a valid number", a.getValue()); 2383 } 2384 } 2385 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.TRAVEL_TIME)) != null) { 2386 String minutes = a.getValue(); 2387 log.debug("travelTime: {}", minutes); 2388 try { 2389 setTravelTime(Integer.parseInt(minutes)); 2390 } catch (NumberFormatException ee) { 2391 log.error("Travel time ({}) isn't a valid number", a.getValue()); 2392 } 2393 } 2394 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SHOW_VALUE)) != null) { 2395 String enable = a.getValue(); 2396 log.debug("showValue: {}", enable); 2397 setValueEnabled(enable.equals(Xml.TRUE)); 2398 } 2399 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.VALUE_LABEL)) != null) { 2400 String label = a.getValue(); 2401 log.debug("valueLabel: {}", label); 2402 setValueLabel(label); 2403 } 2404 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SHOW_RFID)) != null) { 2405 String enable = a.getValue(); 2406 log.debug("showRfid: {}", enable); 2407 setRfidEnabled(enable.equals(Xml.TRUE)); 2408 } 2409 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.RFID_LABEL)) != null) { 2410 String label = a.getValue(); 2411 log.debug("rfidLabel: {}", label); 2412 setRfidLabel(label); 2413 } 2414 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.LENGTH_UNIT)) != null) { 2415 String unit = a.getValue(); 2416 log.debug("lengthUnit: {}", unit); 2417 setLengthUnit(unit); 2418 } 2419 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.YEAR_MODELED)) != null) { 2420 String year = a.getValue(); 2421 log.debug("yearModeled: {}", year); 2422 setYearModeled(year); 2423 } 2424 // next eight attributes are here for backward compatibility 2425 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_LOC_COMMENTS)) != null) { 2426 String enable = a.getValue(); 2427 log.debug("printLocComments: {}", enable); 2428 setPrintLocationCommentsEnabled(enable.equals(Xml.TRUE)); 2429 } 2430 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_ROUTE_COMMENTS)) != null) { 2431 String enable = a.getValue(); 2432 log.debug("printRouteComments: {}", enable); 2433 setPrintRouteCommentsEnabled(enable.equals(Xml.TRUE)); 2434 } 2435 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_LOADS_EMPTIES)) != null) { 2436 String enable = a.getValue(); 2437 log.debug("printLoadsEmpties: {}", enable); 2438 setPrintLoadsAndEmptiesEnabled(enable.equals(Xml.TRUE)); 2439 } 2440 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_TRAIN_SCHEDULE)) != null) { 2441 String enable = a.getValue(); 2442 log.debug("printTrainSchedule: {}", enable); 2443 setPrintTrainScheduleNameEnabled(enable.equals(Xml.TRUE)); 2444 } 2445 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.USE12HR_FORMAT)) != null) { 2446 String enable = a.getValue(); 2447 log.debug("use12hrFormat: {}", enable); 2448 set12hrFormatEnabled(enable.equals(Xml.TRUE)); 2449 } 2450 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_VALID)) != null) { 2451 String enable = a.getValue(); 2452 log.debug("printValid: {}", enable); 2453 setPrintValidEnabled(enable.equals(Xml.TRUE)); 2454 } 2455 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SORT_BY_TRACK)) != null) { 2456 String enable = a.getValue(); 2457 log.debug("sortByTrack: {}", enable); 2458 setSortByTrackNameEnabled(enable.equals(Xml.TRUE)); 2459 } 2460 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_HEADERS)) != null) { 2461 String enable = a.getValue(); 2462 log.debug("printHeaders: {}", enable); 2463 setPrintHeadersEnabled(enable.equals(Xml.TRUE)); 2464 } 2465 } 2466 if (operations.getChild(Xml.PICKUP_ENG_FORMAT) != null) { 2467 if ((a = operations.getChild(Xml.PICKUP_ENG_FORMAT).getAttribute(Xml.PREFIX)) != null) { 2468 setPickupEnginePrefix(a.getValue()); 2469 } 2470 if ((a = operations.getChild(Xml.PICKUP_ENG_FORMAT).getAttribute(Xml.SETTING)) != null) { 2471 String setting = a.getValue(); 2472 log.debug("pickupEngFormat: {}", setting); 2473 String[] keys = setting.split(","); 2474 xmlAttributeToKeyConversion(keys); 2475 keyToStringConversion(keys); 2476 setPickupEngineMessageFormat(keys); 2477 } 2478 } 2479 if (operations.getChild(Xml.DROP_ENG_FORMAT) != null) { 2480 if ((a = operations.getChild(Xml.DROP_ENG_FORMAT).getAttribute(Xml.PREFIX)) != null) { 2481 setDropEnginePrefix(a.getValue()); 2482 } 2483 if ((a = operations.getChild(Xml.DROP_ENG_FORMAT).getAttribute(Xml.SETTING)) != null) { 2484 String setting = a.getValue(); 2485 log.debug("dropEngFormat: {}", setting); 2486 String[] keys = setting.split(","); 2487 xmlAttributeToKeyConversion(keys); 2488 keyToStringConversion(keys); 2489 setDropEngineMessageFormat(keys); 2490 } 2491 } 2492 if (operations.getChild(Xml.PICKUP_CAR_FORMAT) != null) { 2493 if ((a = operations.getChild(Xml.PICKUP_CAR_FORMAT).getAttribute(Xml.PREFIX)) != null) { 2494 setPickupCarPrefix(a.getValue()); 2495 } 2496 if ((a = operations.getChild(Xml.PICKUP_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) { 2497 String setting = a.getValue(); 2498 log.debug("pickupCarFormat: {}", setting); 2499 String[] keys = setting.split(","); 2500 replaceOldFormat(keys); 2501 xmlAttributeToKeyConversion(keys); 2502 keyToStringConversion(keys); 2503 setPickupManifestMessageFormat(keys); 2504 } 2505 } 2506 if (operations.getChild(Xml.DROP_CAR_FORMAT) != null) { 2507 if ((a = operations.getChild(Xml.DROP_CAR_FORMAT).getAttribute(Xml.PREFIX)) != null) { 2508 setDropCarPrefix(a.getValue()); 2509 } 2510 if ((a = operations.getChild(Xml.DROP_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) { 2511 String setting = a.getValue(); 2512 log.debug("dropCarFormat: {}", setting); 2513 String[] keys = setting.split(","); 2514 replaceOldFormat(keys); 2515 xmlAttributeToKeyConversion(keys); 2516 keyToStringConversion(keys); 2517 setDropManifestMessageFormat(keys); 2518 } 2519 } 2520 if (operations.getChild(Xml.LOCAL_FORMAT) != null) { 2521 if ((a = operations.getChild(Xml.LOCAL_FORMAT).getAttribute(Xml.PREFIX)) != null) { 2522 setLocalPrefix(a.getValue()); 2523 } 2524 if ((a = operations.getChild(Xml.LOCAL_FORMAT).getAttribute(Xml.SETTING)) != null) { 2525 String setting = a.getValue(); 2526 log.debug("localFormat: {}", setting); 2527 String[] keys = setting.split(","); 2528 replaceOldFormat(keys); 2529 xmlAttributeToKeyConversion(keys); 2530 keyToStringConversion(keys); 2531 setLocalManifestMessageFormat(keys); 2532 } 2533 } 2534 if (operations.getChild(Xml.MISSING_CAR_FORMAT) != null) { 2535 if ((a = operations.getChild(Xml.MISSING_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) { 2536 String setting = a.getValue(); 2537 log.debug("missingCarFormat: {}", setting); 2538 String[] keys = setting.split(","); 2539 xmlAttributeToKeyConversion(keys); 2540 keyToStringConversion(keys); 2541 setMissingCarMessageFormat(keys); 2542 } 2543 } 2544 if (operations.getChild(Xml.SWITCH_LIST) != null) { 2545 if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.SAME_AS_MANIFEST)) != null) { 2546 String b = a.getValue(); 2547 log.debug("sameAsManifest: {}", b); 2548 setSwitchListFormatSameAsManifest(b.equals(Xml.TRUE)); 2549 } 2550 if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.REAL_TIME)) != null) { 2551 String b = a.getValue(); 2552 log.debug("realTime: {}", b); 2553 getDefault().switchListRealTime = b.equals(Xml.TRUE); 2554 } 2555 if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.ALL_TRAINS)) != null) { 2556 String b = a.getValue(); 2557 log.debug("allTrains: {}", b); 2558 getDefault().switchListAllTrains = b.equals(Xml.TRUE); 2559 } 2560 if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.PAGE_FORMAT)) != null) { 2561 switch (a.getValue()) { 2562 case Xml.PAGE_NORMAL: 2563 getDefault().switchListPageFormat = PAGE_NORMAL; 2564 break; 2565 case Xml.PAGE_PER_TRAIN: 2566 getDefault().switchListPageFormat = PAGE_PER_TRAIN; 2567 break; 2568 case Xml.PAGE_PER_VISIT: 2569 getDefault().switchListPageFormat = PAGE_PER_VISIT; 2570 break; 2571 default: 2572 log.error("Unknown switch list page format {}", a.getValue()); 2573 } 2574 } // old way to save switch list page format pre 3.11 2575 else if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.PAGE_MODE)) != null) { 2576 String b = a.getValue(); 2577 log.debug("old style pageMode: {}", b); 2578 if (b.equals(Xml.TRUE)) { 2579 getDefault().switchListPageFormat = PAGE_PER_TRAIN; 2580 } 2581 } 2582 if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.PRINT_ROUTE_LOCATION)) != null) { 2583 String b = a.getValue(); 2584 log.debug("print route location comment: {}", b); 2585 setSwitchListRouteLocationCommentEnabled(b.equals(Xml.TRUE)); 2586 } 2587 if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.TRACK_SUMMARY)) != null) { 2588 String b = a.getValue(); 2589 log.debug("track summary: {}", b); 2590 setPrintTrackSummaryEnabled(b.equals(Xml.TRUE)); 2591 } 2592 if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.USE_DEPARTURE_TIME)) != null) { 2593 String b = a.getValue(); 2594 log.debug("switch list departure time: {}", b); 2595 setUseSwitchListDepartureTimeEnabled(b.equals(Xml.TRUE)); 2596 } 2597 } 2598 if (operations.getChild(Xml.SWITCH_LIST_PICKUP_CAR_FORMAT) != null) { 2599 if ((a = operations.getChild(Xml.SWITCH_LIST_PICKUP_CAR_FORMAT).getAttribute(Xml.PREFIX)) != null) { 2600 setSwitchListPickupCarPrefix(a.getValue()); 2601 } 2602 if ((a = operations.getChild(Xml.SWITCH_LIST_PICKUP_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) { 2603 String setting = a.getValue(); 2604 log.debug("switchListpickupCarFormat: {}", setting); 2605 String[] keys = setting.split(","); 2606 replaceOldFormat(keys); 2607 xmlAttributeToKeyConversion(keys); 2608 keyToStringConversion(keys); 2609 setPickupSwitchListMessageFormat(keys); 2610 } 2611 } 2612 if (operations.getChild(Xml.SWITCH_LIST_DROP_CAR_FORMAT) != null) { 2613 if ((a = operations.getChild(Xml.SWITCH_LIST_DROP_CAR_FORMAT).getAttribute(Xml.PREFIX)) != null) { 2614 setSwitchListDropCarPrefix(a.getValue()); 2615 } 2616 if ((a = operations.getChild(Xml.SWITCH_LIST_DROP_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) { 2617 String setting = a.getValue(); 2618 log.debug("switchListDropCarFormat: {}", setting); 2619 String[] keys = setting.split(","); 2620 replaceOldFormat(keys); 2621 xmlAttributeToKeyConversion(keys); 2622 keyToStringConversion(keys); 2623 setDropSwitchListMessageFormat(keys); 2624 } 2625 } 2626 if (operations.getChild(Xml.SWITCH_LIST_LOCAL_FORMAT) != null) { 2627 if ((a = operations.getChild(Xml.SWITCH_LIST_LOCAL_FORMAT).getAttribute(Xml.PREFIX)) != null) { 2628 setSwitchListLocalPrefix(a.getValue()); 2629 } 2630 if ((a = operations.getChild(Xml.SWITCH_LIST_LOCAL_FORMAT).getAttribute(Xml.SETTING)) != null) { 2631 String setting = a.getValue(); 2632 log.debug("switchListLocalFormat: {}", setting); 2633 String[] keys = setting.split(","); 2634 replaceOldFormat(keys); 2635 xmlAttributeToKeyConversion(keys); 2636 keyToStringConversion(keys); 2637 setLocalSwitchListMessageFormat(keys); 2638 } 2639 } 2640 if (operations.getChild(Xml.PANEL) != null) { 2641 if ((a = operations.getChild(Xml.PANEL).getAttribute(Xml.NAME)) != null) { 2642 String panel = a.getValue(); 2643 log.debug("panel: {}", panel); 2644 setPanelName(panel); 2645 } 2646 if ((a = operations.getChild(Xml.PANEL).getAttribute(Xml.TRAIN_ICONXY)) != null) { 2647 String enable = a.getValue(); 2648 log.debug("TrainIconXY: {}", enable); 2649 setTrainIconCordEnabled(enable.equals(Xml.TRUE)); 2650 } 2651 if ((a = operations.getChild(Xml.PANEL).getAttribute(Xml.TRAIN_ICON_APPEND)) != null) { 2652 String enable = a.getValue(); 2653 log.debug("TrainIconAppend: {}", enable); 2654 setTrainIconAppendEnabled(enable.equals(Xml.TRUE)); 2655 } 2656 } 2657 if ((operations.getChild(Xml.FONT_NAME) != null) && 2658 (a = operations.getChild(Xml.FONT_NAME).getAttribute(Xml.NAME)) != null) { 2659 String font = a.getValue(); 2660 log.debug("fontName: {}", font); 2661 setFontName(font); 2662 } 2663 if ((operations.getChild(Xml.FONT_SIZE) != null) && 2664 (a = operations.getChild(Xml.FONT_SIZE).getAttribute(Xml.SIZE)) != null) { 2665 String size = a.getValue(); 2666 log.debug("fontsize: {}", size); 2667 try { 2668 setManifestFontSize(Integer.parseInt(size)); 2669 } catch (NumberFormatException ee) { 2670 log.error("Manifest font size ({}) isn't a valid number", a.getValue()); 2671 } 2672 } 2673 if ((operations.getChild(Xml.PAGE_ORIENTATION) != null)) { 2674 if ((a = operations.getChild(Xml.PAGE_ORIENTATION).getAttribute(Xml.MANIFEST)) != null) { 2675 String orientation = a.getValue(); 2676 log.debug("manifestOrientation: {}", orientation); 2677 setManifestOrientation(orientation); 2678 } 2679 if ((a = operations.getChild(Xml.PAGE_ORIENTATION).getAttribute(Xml.SWITCH_LIST)) != null) { 2680 String orientation = a.getValue(); 2681 log.debug("switchListOrientation: {}", orientation); 2682 setSwitchListOrientation(orientation); 2683 } 2684 } 2685 if ((operations.getChild(Xml.PRINT_DUPLEX) != null)) { 2686 if ((a = operations.getChild(Xml.PRINT_DUPLEX).getAttribute(Xml.NAME)) != null) { 2687 String sides = a.getValue(); 2688 log.debug("Print duplex: {}", sides); 2689 if (sides.equals(SidesType.TWO_SIDED_LONG_EDGE.toString())) { 2690 setPrintDuplexSides(Sides.TWO_SIDED_LONG_EDGE); 2691 } 2692 if (sides.equals(SidesType.TWO_SIDED_SHORT_EDGE.toString())) { 2693 setPrintDuplexSides(Sides.TWO_SIDED_SHORT_EDGE); 2694 } 2695 } 2696 } 2697 if ((operations.getChild(Xml.MANIFEST_COLORS) != null)) { 2698 if ((a = operations.getChild(Xml.MANIFEST_COLORS).getAttribute(Xml.DROP_COLOR)) != null) { 2699 String dropColor = a.getValue(); 2700 log.debug("dropColor: {}", dropColor); 2701 setDropTextColor(dropColor); 2702 } 2703 if ((a = operations.getChild(Xml.MANIFEST_COLORS).getAttribute(Xml.PICKUP_COLOR)) != null) { 2704 String pickupColor = a.getValue(); 2705 log.debug("pickupColor: {}", pickupColor); 2706 setPickupTextColor(pickupColor); 2707 } 2708 if ((a = operations.getChild(Xml.MANIFEST_COLORS).getAttribute(Xml.LOCAL_COLOR)) != null) { 2709 String localColor = a.getValue(); 2710 log.debug("localColor: {}", localColor); 2711 setLocalTextColor(localColor); 2712 } 2713 if ((a = operations.getChild(Xml.MANIFEST_COLORS).getAttribute(Xml.DROP_ENGINE_COLOR)) != null) { 2714 String dropColor = a.getValue(); 2715 log.debug("dropEngineColor: {}", dropColor); 2716 setDropEngineTextColor(dropColor); 2717 } else { 2718 // Engine drop color didn't exist before 5.11.3 2719 setDropEngineTextColor(getDropTextColor()); 2720 } 2721 if ((a = operations.getChild(Xml.MANIFEST_COLORS).getAttribute(Xml.PICKUP_ENGINE_COLOR)) != null) { 2722 String pickupColor = a.getValue(); 2723 log.debug("pickupEngineColor: {}", pickupColor); 2724 setPickupEngineTextColor(pickupColor); 2725 } else { 2726 // Engine pick up color didn't exist before 5.11.3 2727 setPickupEngineTextColor(getPickupTextColor()); 2728 } 2729 } 2730 if ((operations.getChild(Xml.TAB) != null)) { 2731 if ((a = operations.getChild(Xml.TAB).getAttribute(Xml.ENABLED)) != null) { 2732 String enable = a.getValue(); 2733 log.debug("tab: {}", enable); 2734 setTabEnabled(enable.equals(Xml.TRUE)); 2735 } 2736 if ((a = operations.getChild(Xml.TAB).getAttribute(Xml.LENGTH)) != null) { 2737 String length = a.getValue(); 2738 log.debug("tab 1 length: {}", length); 2739 try { 2740 setTab1length(Integer.parseInt(length)); 2741 } catch (NumberFormatException ee) { 2742 log.error("Tab 1 length ({}) isn't a valid number", a.getValue()); 2743 } 2744 } 2745 if ((a = operations.getChild(Xml.TAB).getAttribute(Xml.TAB2_LENGTH)) != null) { 2746 String length = a.getValue(); 2747 log.debug("tab 2 length: {}", length); 2748 try { 2749 setTab2length(Integer.parseInt(length)); 2750 } catch (NumberFormatException ee) { 2751 log.error("Tab 2 length ({}) isn't a valid number", a.getValue()); 2752 } 2753 } 2754 if ((a = operations.getChild(Xml.TAB).getAttribute(Xml.TAB3_LENGTH)) != null) { 2755 String length = a.getValue(); 2756 log.debug("tab 3 length: {}", length); 2757 try { 2758 setTab3length(Integer.parseInt(length)); 2759 } catch (NumberFormatException ee) { 2760 log.error("Tab 3 length ({}) isn't a valid number", a.getValue()); 2761 } 2762 } 2763 if ((a = operations.getChild(Xml.TAB).getAttribute(Xml.MANIFEST_TAB_LENGTH)) != null) { 2764 String length = a.getValue(); 2765 log.debug("Manifest tab length: {}", length); 2766 try { 2767 setManifestTablength(Integer.parseInt(length)); 2768 } catch (NumberFormatException ee) { 2769 log.error("Manifest tab length ({}) isn't a valid number", a.getValue()); 2770 } 2771 } 2772 } 2773 if ((operations.getChild(Xml.MANIFEST) != null)) { 2774 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_LOC_COMMENTS)) != null) { 2775 String enable = a.getValue(); 2776 log.debug("manifest printLocComments: {}", enable); 2777 setPrintLocationCommentsEnabled(enable.equals(Xml.TRUE)); 2778 } 2779 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_ROUTE_COMMENTS)) != null) { 2780 String enable = a.getValue(); 2781 log.debug("manifest printRouteComments: {}", enable); 2782 setPrintRouteCommentsEnabled(enable.equals(Xml.TRUE)); 2783 } 2784 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_LOADS_EMPTIES)) != null) { 2785 String enable = a.getValue(); 2786 log.debug("manifest printLoadsEmpties: {}", enable); 2787 setPrintLoadsAndEmptiesEnabled(enable.equals(Xml.TRUE)); 2788 } 2789 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_TRAIN_SCHEDULE)) != null) { 2790 String enable = a.getValue(); 2791 log.debug("manifest printTrainSchedule: {}", enable); 2792 setPrintTrainScheduleNameEnabled(enable.equals(Xml.TRUE)); 2793 } 2794 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.USE12HR_FORMAT)) != null) { 2795 String enable = a.getValue(); 2796 log.debug("manifest use12hrFormat: {}", enable); 2797 set12hrFormatEnabled(enable.equals(Xml.TRUE)); 2798 } 2799 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_VALID)) != null) { 2800 String enable = a.getValue(); 2801 log.debug("manifest printValid: {}", enable); 2802 setPrintValidEnabled(enable.equals(Xml.TRUE)); 2803 } 2804 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.SORT_BY_TRACK)) != null) { 2805 String enable = a.getValue(); 2806 log.debug("manifest sortByTrack: {}", enable); 2807 setSortByTrackNameEnabled(enable.equals(Xml.TRUE)); 2808 } 2809 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_PAGE_HEADER)) != null) { 2810 String enable = a.getValue(); 2811 log.debug("manifest printPageHeader: {}", enable); 2812 setPrintPageHeaderEnabled(enable.equals(Xml.TRUE)); 2813 } 2814 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_HEADERS)) != null) { 2815 String enable = a.getValue(); 2816 log.debug("manifest print headers: {}", enable); 2817 setPrintHeadersEnabled(enable.equals(Xml.TRUE)); 2818 } 2819 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_NO_PAGE_BREAKS)) != null) { 2820 String enable = a.getValue(); 2821 log.debug("printNoPageBreaks: {}", enable); 2822 setPrintNoPageBreaksEnabled(enable.equals(Xml.TRUE)); 2823 } 2824 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.TRUNCATE)) != null) { 2825 String enable = a.getValue(); 2826 log.debug("manifest truncate: {}", enable); 2827 setPrintTruncateManifestEnabled(enable.equals(Xml.TRUE)); 2828 } 2829 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.USE_DEPARTURE_TIME)) != null) { 2830 String enable = a.getValue(); 2831 log.debug("manifest use departure time: {}", enable); 2832 setUseDepartureTimeEnabled(enable.equals(Xml.TRUE)); 2833 } 2834 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.USE_EDITOR)) != null) { 2835 String enable = a.getValue(); 2836 log.debug("manifest useEditor: {}", enable); 2837 setManifestEditorEnabled(enable.equals(Xml.TRUE)); 2838 } 2839 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_CABOOSE_LOAD)) != null) { 2840 String enable = a.getValue(); 2841 log.debug("manifest print caboose load: {}", enable); 2842 setPrintCabooseLoadEnabled(enable.equals(Xml.TRUE)); 2843 } 2844 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_PASSENGER_LOAD)) != null) { 2845 String enable = a.getValue(); 2846 log.debug("manifest print passenger load: {}", enable); 2847 setPrintPassengerLoadEnabled(enable.equals(Xml.TRUE)); 2848 } 2849 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.GROUP_MOVES)) != null) { 2850 String enable = a.getValue(); 2851 log.debug("manifest group car moves: {}", enable); 2852 setGroupCarMoves(enable.equals(Xml.TRUE)); 2853 } 2854 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_LOCO_LAST)) != null) { 2855 String enable = a.getValue(); 2856 log.debug("manifest print loco last: {}", enable); 2857 setPrintLocoLast(enable.equals(Xml.TRUE)); 2858 } 2859 if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.HAZARDOUS_MSG)) != null) { 2860 String message = a.getValue(); 2861 log.debug("manifest hazardousMsg: {}", message); 2862 setHazardousMsg(message); 2863 } 2864 } 2865 if ((operations.getChild(Xml.MANIFEST_FORMAT) != null)) { 2866 if ((a = operations.getChild(Xml.MANIFEST_FORMAT).getAttribute(Xml.VALUE)) != null) { 2867 switch (a.getValue()) { 2868 case Xml.STANDARD: 2869 getDefault().manifestFormat = STANDARD_FORMAT; 2870 break; 2871 case Xml.TWO_COLUMN: 2872 getDefault().manifestFormat = TWO_COLUMN_FORMAT; 2873 break; 2874 case Xml.TWO_COLUMN_TRACK: 2875 getDefault().manifestFormat = TWO_COLUMN_TRACK_FORMAT; 2876 break; 2877 default: 2878 log.debug("Unknown manifest format"); 2879 } 2880 } 2881 } else if ((operations.getChild(Xml.COLUMN_FORMAT) != null)) { 2882 if ((a = operations.getChild(Xml.COLUMN_FORMAT).getAttribute(Xml.TWO_COLUMNS)) != null) { 2883 String enable = a.getValue(); 2884 log.debug("two columns: {}", enable); 2885 if (enable.equals(Xml.TRUE)) { 2886 setManifestFormat(TWO_COLUMN_FORMAT); 2887 } 2888 } 2889 } 2890 if ((operations.getChild(Xml.HEADER_LINES) != null)) { 2891 if ((a = operations.getChild(Xml.HEADER_LINES).getAttribute(Xml.PRINT_HEADER_LINE1)) != null) { 2892 String enable = a.getValue(); 2893 setPrintHeaderLine1Enabled(enable.equals(Xml.TRUE)); 2894 } 2895 if ((a = operations.getChild(Xml.HEADER_LINES).getAttribute(Xml.PRINT_HEADER_LINE2)) != null) { 2896 String enable = a.getValue(); 2897 setPrintHeaderLine2Enabled(enable.equals(Xml.TRUE)); 2898 } 2899 if ((a = operations.getChild(Xml.HEADER_LINES).getAttribute(Xml.PRINT_HEADER_LINE3)) != null) { 2900 String enable = a.getValue(); 2901 setPrintHeaderLine3Enabled(enable.equals(Xml.TRUE)); 2902 } 2903 if ((a = operations.getChild(Xml.HEADER_LINES).getAttribute(Xml.HORIZONTAL_LINE_ADJ)) != null) { 2904 String number = a.getValue(); 2905 try { 2906 setHorizontalLineAdjustment(Integer.parseInt(number)); 2907 } catch (NumberFormatException ne) { 2908 log.error("Horizontal line adjustment isn't a number"); 2909 } 2910 } 2911 } 2912 // get manifest logo 2913 if ((operations.getChild(Xml.MANIFEST_LOGO) != null)) { 2914 if ((a = operations.getChild(Xml.MANIFEST_LOGO).getAttribute(Xml.NAME)) != null) { 2915 setManifestLogoURL(a.getValue()); 2916 } 2917 } 2918 // manifest file options 2919 if ((operations.getChild(Xml.MANIFEST_FILE_OPTIONS) != null)) { 2920 if ((a = operations.getChild(Xml.MANIFEST_FILE_OPTIONS).getAttribute(Xml.MANIFEST_SAVE)) != null) { 2921 String enable = a.getValue(); 2922 log.debug("manifest file save option: {}", enable); 2923 getDefault().saveTrainManifests = enable.equals(Xml.TRUE); 2924 } 2925 } 2926 if ((operations.getChild(Xml.BUILD_OPTIONS) != null)) { 2927 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.AGGRESSIVE)) != null) { 2928 String enable = a.getValue(); 2929 log.debug("aggressive: {}", enable); 2930 setBuildAggressive(enable.equals(Xml.TRUE)); 2931 } 2932 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.NUMBER_PASSES)) != null) { 2933 String number = a.getValue(); 2934 log.debug("number of passes: {}", number); 2935 try { 2936 setNumberPasses(Integer.parseInt(number)); 2937 } catch (NumberFormatException ne) { 2938 log.debug("Number of passes isn't a number"); 2939 } 2940 } 2941 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ON_TIME)) != null) { 2942 String enable = a.getValue(); 2943 log.debug("on time: {}", enable); 2944 setBuildOnTime(enable.equals(Xml.TRUE)); 2945 } 2946 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.DWELL_TIME)) != null) { 2947 String minutes = a.getValue(); 2948 log.debug("dwell time: {}", minutes); 2949 try { 2950 setDwellTime(Integer.parseInt(minutes)); 2951 } catch (NumberFormatException ne) { 2952 log.debug("dwell time isn't a number"); 2953 } 2954 } 2955 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_LOCAL_INTERCHANGE)) != null) { 2956 String enable = a.getValue(); 2957 log.debug("allowLocalInterchangeMoves: {}", enable); 2958 setLocalInterchangeMovesEnabled(enable.equals(Xml.TRUE)); 2959 } 2960 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_LOCAL_SPUR)) != null) { 2961 String enable = a.getValue(); 2962 log.debug("allowLocalSpurMoves: {}", enable); 2963 setLocalSpurMovesEnabled(enable.equals(Xml.TRUE)); 2964 } else if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_LOCAL_SIDING)) != null) { 2965 String enable = a.getValue(); 2966 log.debug("allowLocalSidingMoves: {}", enable); 2967 setLocalSpurMovesEnabled(enable.equals(Xml.TRUE)); 2968 } 2969 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_LOCAL_YARD)) != null) { 2970 String enable = a.getValue(); 2971 log.debug("allowLocalYardMoves: {}", enable); 2972 setLocalYardMovesEnabled(enable.equals(Xml.TRUE)); 2973 } 2974 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.STAGING_RESTRICTION_ENABLED)) != null) { 2975 String enable = a.getValue(); 2976 log.debug("stagingRestrictionEnabled: {}", enable); 2977 setStagingTrainCheckEnabled(enable.equals(Xml.TRUE)); 2978 } 2979 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.STAGING_TRACK_AVAIL)) != null) { 2980 String enable = a.getValue(); 2981 log.debug("stagingTrackAvail: {}", enable); 2982 setStagingTrackImmediatelyAvail(enable.equals(Xml.TRUE)); 2983 } 2984 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_RETURN_STAGING)) != null) { 2985 String enable = a.getValue(); 2986 log.debug("allowReturnStaging: {}", enable); 2987 getDefault().allowCarsReturnStaging = enable.equals(Xml.TRUE); 2988 } 2989 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.PROMPT_STAGING_ENABLED)) != null) { 2990 String enable = a.getValue(); 2991 log.debug("promptStagingEnabled: {}", enable); 2992 setStagingPromptFromEnabled(enable.equals(Xml.TRUE)); 2993 } 2994 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.PROMPT_TO_STAGING_ENABLED)) != null) { 2995 String enable = a.getValue(); 2996 log.debug("promptToStagingEnabled: {}", enable); 2997 setStagingPromptToEnabled(enable.equals(Xml.TRUE)); 2998 } 2999 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.STAGING_TRY_NORMAL)) != null) { 3000 String enable = a.getValue(); 3001 log.debug("stagingTryNormalEnabled: {}", enable); 3002 setStagingTryNormalBuildEnabled(enable.equals(Xml.TRUE)); 3003 } 3004 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.GENERATE_CSV_MANIFEST)) != null) { 3005 String enable = a.getValue(); 3006 log.debug("generateCvsManifest: {}", enable); 3007 getDefault().generateCsvManifest = enable.equals(Xml.TRUE); 3008 } 3009 if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.GENERATE_CSV_SWITCH_LIST)) != null) { 3010 String enable = a.getValue(); 3011 log.debug("generateCvsSwitchList: {}", enable); 3012 getDefault().generateCsvSwitchList = enable.equals(Xml.TRUE); 3013 } 3014 } 3015 if (operations.getChild(Xml.BUILD_REPORT) != null) { 3016 if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.LEVEL)) != null) { 3017 String level = a.getValue(); 3018 log.debug("buildReportLevel: {}", level); 3019 setBuildReportLevel(level); 3020 } 3021 if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.ROUTER_LEVEL)) != null) { 3022 String level = a.getValue(); 3023 log.debug("routerBuildReportLevel: {}", level); 3024 setRouterBuildReportLevel(level); 3025 } 3026 if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.USE_EDITOR)) != null) { 3027 String enable = a.getValue(); 3028 log.debug("build report useEditor: {}", enable); 3029 setBuildReportEditorEnabled(enable.equals(Xml.TRUE)); 3030 } 3031 if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.INDENT)) != null) { 3032 String enable = a.getValue(); 3033 log.debug("build report indent: {}", enable); 3034 setBuildReportIndentEnabled(enable.equals(Xml.TRUE)); 3035 } 3036 if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.FONT_SIZE)) != null) { 3037 String size = a.getValue(); 3038 log.debug("build font size: {}", size); 3039 try { 3040 setBuildReportFontSize(Integer.parseInt(size)); 3041 } catch (NumberFormatException ee) { 3042 log.error("Build report font size ({}) isn't a valid number", a.getValue()); 3043 } 3044 } 3045 if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.ALWAYS_PREVIEW)) != null) { 3046 String enable = a.getValue(); 3047 log.debug("build report always preview: {}", enable); 3048 setBuildReportAlwaysPreviewEnabled(enable.equals(Xml.TRUE)); 3049 } 3050 } 3051 3052 if (operations.getChild(Xml.ROUTER) != null) { 3053 if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.CAR_ROUTING_ENABLED)) != null) { 3054 String enable = a.getValue(); 3055 log.debug("carRoutingEnabled: {}", enable); 3056 setCarRoutingEnabled(enable.equals(Xml.TRUE)); 3057 } 3058 if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.CAR_ROUTING_VIA_YARDS)) != null) { 3059 String enable = a.getValue(); 3060 log.debug("carRoutingViaYards: {}", enable); 3061 setCarRoutingViaYardsEnabled(enable.equals(Xml.TRUE)); 3062 } 3063 if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.CAR_ROUTING_VIA_STAGING)) != null) { 3064 String enable = a.getValue(); 3065 log.debug("carRoutingViaStaging: {}", enable); 3066 setCarRoutingViaStagingEnabled(enable.equals(Xml.TRUE)); 3067 } 3068 if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.FORWARD_TO_YARD)) != null) { 3069 String enable = a.getValue(); 3070 log.debug("forwardToYard: {}", enable); 3071 setForwardToYardEnabled(enable.equals(Xml.TRUE)); 3072 } 3073 if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.ONLY_ACTIVE_TRAINS)) != null) { 3074 String enable = a.getValue(); 3075 log.debug("onlyActiveTrains: {}", enable); 3076 setOnlyActiveTrainsEnabled(enable.equals(Xml.TRUE)); 3077 } 3078 if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.CHECK_CAR_DESTINATION)) != null) { 3079 String enable = a.getValue(); 3080 log.debug("checkCarDestination: {}", enable); 3081 setCheckCarDestinationEnabled(enable.equals(Xml.TRUE)); 3082 } 3083 } else if (operations.getChild(Xml.SETTINGS) != null) { 3084 // the next four items are for backwards compatibility 3085 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_ROUTING_ENABLED)) != null) { 3086 String enable = a.getValue(); 3087 log.debug("carRoutingEnabled: {}", enable); 3088 setCarRoutingEnabled(enable.equals(Xml.TRUE)); 3089 } 3090 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_ROUTING_VIA_YARDS)) != null) { 3091 String enable = a.getValue(); 3092 log.debug("carRoutingViaYards: {}", enable); 3093 setCarRoutingViaYardsEnabled(enable.equals(Xml.TRUE)); 3094 } 3095 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_ROUTING_VIA_STAGING)) != null) { 3096 String enable = a.getValue(); 3097 log.debug("carRoutingViaStaging: {}", enable); 3098 setCarRoutingViaStagingEnabled(enable.equals(Xml.TRUE)); 3099 } 3100 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.FORWARD_TO_YARD)) != null) { 3101 String enable = a.getValue(); 3102 log.debug("forwardToYard: {}", enable); 3103 setForwardToYardEnabled(enable.equals(Xml.TRUE)); 3104 } 3105 } 3106 3107 if ((operations.getChild(Xml.OWNER) != null) && 3108 (a = operations.getChild(Xml.OWNER).getAttribute(Xml.NAME)) != null) { 3109 String owner = a.getValue(); 3110 log.debug("owner: {}", owner); 3111 setOwnerName(owner); 3112 } 3113 if (operations.getChild(Xml.ICON_COLOR) != null) { 3114 if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.NORTH)) != null) { 3115 String color = a.getValue(); 3116 log.debug("north color: {}", color); 3117 setTrainIconColorNorth(color); 3118 } 3119 if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.SOUTH)) != null) { 3120 String color = a.getValue(); 3121 log.debug("south color: {}", color); 3122 setTrainIconColorSouth(color); 3123 } 3124 if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.EAST)) != null) { 3125 String color = a.getValue(); 3126 log.debug("east color: {}", color); 3127 setTrainIconColorEast(color); 3128 } 3129 if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.WEST)) != null) { 3130 String color = a.getValue(); 3131 log.debug("west color: {}", color); 3132 setTrainIconColorWest(color); 3133 } 3134 if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.LOCAL)) != null) { 3135 String color = a.getValue(); 3136 log.debug("local color: {}", color); 3137 setTrainIconColorLocal(color); 3138 } 3139 if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.TERMINATE)) != null) { 3140 String color = a.getValue(); 3141 log.debug("terminate color: {}", color); 3142 setTrainIconColorTerminate(color); 3143 } 3144 } 3145 if (operations.getChild(Xml.COMMENTS) != null) { 3146 if ((a = operations.getChild(Xml.COMMENTS).getAttribute(Xml.MISPLACED_CARS)) != null) { 3147 String comment = a.getValue(); 3148 log.debug("Misplaced comment: {}", comment); 3149 setMiaComment(comment); 3150 } 3151 } 3152 3153 if (operations.getChild(Xml.DISPLAY) != null) { 3154 if ((a = operations.getChild(Xml.DISPLAY).getAttribute(Xml.SHOW_TRACK_MOVES)) != null) { 3155 String enable = a.getValue(); 3156 log.debug("show track moves: {}", enable); 3157 getDefault().showTrackMoves = enable.equals(Xml.TRUE); 3158 } 3159 } 3160 3161 if (operations.getChild(Xml.VSD) != null) { 3162 if ((a = operations.getChild(Xml.VSD).getAttribute(Xml.ENABLE_PHYSICAL_LOCATIONS)) != null) { 3163 String enable = a.getValue(); 3164 setVsdPhysicalLocationEnabled(enable.equals(Xml.TRUE)); 3165 } 3166 } 3167 if (operations.getChild(Xml.CATS) != null) { 3168 if ((a = operations.getChild(Xml.CATS).getAttribute(Xml.EXACT_LOCATION_NAME)) != null) { 3169 String enable = a.getValue(); 3170 AbstractOperationsServer.setExactLocationName(enable.equals(Xml.TRUE)); 3171 } 3172 } 3173 3174 if (operations.getChild(Xml.SETTINGS) != null) { 3175 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.AUTO_SAVE)) != null) { 3176 String enabled = a.getValue(); 3177 log.debug("autoSave: {}", enabled); 3178 setAutoSaveEnabled(enabled.equals(Xml.TRUE)); 3179 } 3180 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.AUTO_BACKUP)) != null) { 3181 String enabled = a.getValue(); 3182 log.debug("autoBackup: {}", enabled); 3183 setAutoBackupEnabled(enabled.equals(Xml.TRUE)); 3184 } 3185 } 3186 3187 if (operations.getChild(Xml.LOGGER) != null) { 3188 if ((a = operations.getChild(Xml.LOGGER).getAttribute(Xml.CAR_LOGGER)) != null) { 3189 String enable = a.getValue(); 3190 log.debug("carLogger: {}", enable); 3191 getDefault().carLogger = enable.equals(Xml.TRUE); 3192 } 3193 if ((a = operations.getChild(Xml.LOGGER).getAttribute(Xml.ENGINE_LOGGER)) != null) { 3194 String enable = a.getValue(); 3195 log.debug("engineLogger: {}", enable); 3196 getDefault().engineLogger = enable.equals(Xml.TRUE); 3197 } 3198 if ((a = operations.getChild(Xml.LOGGER).getAttribute(Xml.TRAIN_LOGGER)) != null) { 3199 String enable = a.getValue(); 3200 log.debug("trainLogger: {}", enable); 3201 getDefault().trainLogger = enable.equals(Xml.TRUE); 3202 } 3203 } else if (operations.getChild(Xml.SETTINGS) != null) { 3204 // for backward compatibility 3205 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_LOGGER)) != null) { 3206 String enable = a.getValue(); 3207 log.debug("carLogger: {}", enable); 3208 getDefault().carLogger = enable.equals(Xml.TRUE); 3209 } 3210 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.ENGINE_LOGGER)) != null) { 3211 String enable = a.getValue(); 3212 log.debug("engineLogger: {}", enable); 3213 getDefault().engineLogger = enable.equals(Xml.TRUE); 3214 } 3215 if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.TRAIN_LOGGER)) != null) { 3216 String enable = a.getValue(); 3217 log.debug("trainLogger: {}", enable); 3218 getDefault().trainLogger = enable.equals(Xml.TRUE); 3219 } 3220 } 3221 if (operations.getChild(Xml.DAY_NAME_MAP) != null) { 3222 List<Element> eMap = operations.getChild(Xml.DAY_NAME_MAP).getChildren(Xml.MAP); 3223 for (Element eDay : eMap) { 3224 if (eDay.getAttribute(Xml.DAY) != null && eDay.getAttribute(Xml.NAME) != null) { 3225 String day = eDay.getAttribute(Xml.DAY).getValue(); 3226 String name = eDay.getAttribute(Xml.NAME).getValue(); 3227 setDayToName(day, name); 3228 log.debug("Mapping day: {} to name: {}", day, name); 3229 } 3230 } 3231 } 3232 } 3233 3234 // replace old pickup and drop message keys 3235 // Change happened from 2.11.3 to 2.11.4 3236 // 4/16/2014 3237 private static void replaceOldFormat(String[] format) { 3238 for (int i = 0; i < format.length; i++) { 3239 if (format[i].equals("Pickup Msg")) // NOI18N 3240 { 3241 format[i] = PICKUP_COMMENT; 3242 } else if (format[i].equals("Drop Msg")) // NOI18N 3243 { 3244 format[i] = DROP_COMMENT; 3245 } 3246 } 3247 } 3248 3249 /** 3250 * Converts the xml key to the proper locale text 3251 * 3252 */ 3253 private static void keyToStringConversion(String[] keys) { 3254 for (int i = 0; i < keys.length; i++) { 3255 if (keys[i].equals(BLANK)) { 3256 continue; 3257 } 3258 try { 3259 keys[i] = Bundle.getMessage(keys[i]); 3260 } catch (Exception e) { 3261 log.warn("Key {}: ({}) not found", i, keys[i]); 3262 } 3263 } 3264 } 3265 3266 /* 3267 * Converts the strings into English tags for xml storage 3268 * 3269 */ 3270 public static void stringToTagConversion(String[] strings) { 3271 for (int i = 0; i < strings.length; i++) { 3272 if (strings[i].equals(BLANK)) { 3273 continue; 3274 } 3275 for (String key : KEYS) { 3276 if (strings[i].equals(Bundle.getMessage(key))) { 3277 strings[i] = Bundle.getMessage(Locale.ROOT, key); 3278 break; 3279 } 3280 } 3281 // log.debug("Converted {} to {}", old, strings[i]); 3282 } 3283 } 3284 3285 /* 3286 * The xml attributes stored using the English translation. This converts the 3287 * attribute to the appropriate key for language conversion. 3288 */ 3289 private static void xmlAttributeToKeyConversion(String[] format) { 3290 for (int i = 0; i < format.length; i++) { 3291 for (String key : KEYS) { 3292 if (format[i].equals(Bundle.getMessage(Locale.ROOT, key))) { 3293 format[i] = key; 3294 } 3295 } 3296 } 3297 } 3298 3299 protected static void setDirtyAndFirePropertyChange(String p, Object old, Object n) { 3300 InstanceManager.getDefault(OperationsSetupXml.class).setDirty(true); 3301 getDefault().firePropertyChange(p, old, n); 3302 } 3303 3304 public static Setup getDefault() { 3305 return InstanceManager.getDefault(Setup.class); 3306 } 3307 3308 private static final Logger log = LoggerFactory.getLogger(Setup.class); 3309 3310 @Override 3311 public void dispose() { 3312 AutoSave.stop(); 3313 } 3314 3315}