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