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