Search in sources :

Example 66 with Element

use of org.jdom2.Element in project JMRI by JMRI.

the class EngineManager method load.

public void load(Element root) {
    // new format using elements starting version 3.3.1
    if (root.getChild(Xml.NEW_CONSISTS) != null) {
        @SuppressWarnings("unchecked") List<Element> consists = root.getChild(Xml.NEW_CONSISTS).getChildren(Xml.CONSIST);
        log.debug("Engine manager sees {} consists", consists.size());
        Attribute a;
        for (Element consist : consists) {
            if ((a = consist.getAttribute(Xml.NAME)) != null) {
                newConsist(a.getValue());
            }
        }
    } else // old format
    if (root.getChild(Xml.CONSISTS) != null) {
        String names = root.getChildText(Xml.CONSISTS);
        if (!names.equals(NONE)) {
            // NOI18N
            String[] consistNames = names.split("%%");
            log.debug("consists: {}", names);
            for (String name : consistNames) {
                newConsist(name);
            }
        }
    }
    if (root.getChild(Xml.ENGINES) != null) {
        @SuppressWarnings("unchecked") List<Element> engines = root.getChild(Xml.ENGINES).getChildren(Xml.ENGINE);
        log.debug("readFile sees {} engines", engines.size());
        for (Element e : engines) {
            register(new Engine(e));
        }
    }
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element)

Example 67 with Element

use of org.jdom2.Element in project JMRI by JMRI.

the class Setup method load.

public static void load(Element e) {
    if (e.getChild(Xml.OPERATIONS) == null) {
        log.debug("operation setup values missing");
        return;
    }
    Element operations = e.getChild(Xml.OPERATIONS);
    org.jdom2.Attribute a;
    if ((operations.getChild(Xml.RAIL_ROAD) != null) && (a = operations.getChild(Xml.RAIL_ROAD).getAttribute(Xml.NAME)) != null) {
        String name = a.getValue();
        log.debug("railroadName: {}", name);
        if (name.equals(Xml.USE_JMRI_RAILROAD_NAME)) {
            getDefault().railroadName = null;
        } else {
            // don't set the dirty bit
            getDefault().railroadName = name;
        }
    }
    if ((operations.getChild(Xml.SETUP) != null) && (a = operations.getChild(Xml.SETUP).getAttribute(Xml.COMMENT)) != null) {
        String comment = a.getValue();
        log.debug("setup comment: {}", comment);
        getDefault().setupComment = comment;
    }
    if (operations.getChild(Xml.SETTINGS) != null) {
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.MAIN_MENU)) != null) {
            String enabled = a.getValue();
            log.debug("mainMenu: {}", enabled);
            setMainMenuEnabled(enabled.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CLOSE_ON_SAVE)) != null) {
            String enabled = a.getValue();
            log.debug("closeOnSave: {}", enabled);
            setCloseWindowOnSaveEnabled(enabled.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.TRAIN_DIRECTION)) != null) {
            String dir = a.getValue();
            log.debug("direction: {}", dir);
            try {
                setTrainDirection(Integer.parseInt(dir));
            } catch (NumberFormatException ee) {
                log.error("Train direction ({}) isn't a valid number", a.getValue());
            }
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.TRAIN_LENGTH)) != null) {
            String length = a.getValue();
            log.debug("Max train length: {}", length);
            try {
                setMaxTrainLength(Integer.parseInt(length));
            } catch (NumberFormatException ee) {
                log.error("Train maximum length ({}) isn't a valid number", a.getValue());
            }
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.MAX_ENGINES)) != null) {
            String size = a.getValue();
            log.debug("Max number of engines: {}", size);
            try {
                setMaxNumberEngines(Integer.parseInt(size));
            } catch (NumberFormatException ee) {
                log.error("Maximum number of engines ({}) isn't a valid number", a.getValue());
            }
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.HPT)) != null) {
            String value = a.getValue();
            log.debug("HPT: {}", value);
            try {
                setHorsePowerPerTon(Integer.parseInt(value));
            } catch (NumberFormatException ee) {
                log.error("Train HPT ({}) isn't a valid number", a.getValue());
            }
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SCALE)) != null) {
            String scale = a.getValue();
            log.debug("scale: " + scale);
            try {
                setScale(Integer.parseInt(scale));
            } catch (NumberFormatException ee) {
                log.error("Scale ({}) isn't a valid number", a.getValue());
            }
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_TYPES)) != null) {
            String types = a.getValue();
            log.debug("CarTypes: " + types);
            setCarTypes(types);
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SWITCH_TIME)) != null) {
            String minutes = a.getValue();
            log.debug("switchTime: {}", minutes);
            try {
                setSwitchTime(Integer.parseInt(minutes));
            } catch (NumberFormatException ee) {
                log.error("Switch time ({}) isn't a valid number", a.getValue());
            }
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.TRAVEL_TIME)) != null) {
            String minutes = a.getValue();
            log.debug("travelTime: {}", minutes);
            try {
                setTravelTime(Integer.parseInt(minutes));
            } catch (NumberFormatException ee) {
                log.error("Travel time ({}) isn't a valid number", a.getValue());
            }
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SHOW_VALUE)) != null) {
            String enable = a.getValue();
            log.debug("showValue: {}", enable);
            setValueEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.VALUE_LABEL)) != null) {
            String label = a.getValue();
            log.debug("valueLabel: {}", label);
            setValueLabel(label);
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SHOW_RFID)) != null) {
            String enable = a.getValue();
            log.debug("showRfid: {}", enable);
            setRfidEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.RFID_LABEL)) != null) {
            String label = a.getValue();
            log.debug("rfidLabel: {}", label);
            setRfidLabel(label);
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.LENGTH_UNIT)) != null) {
            String unit = a.getValue();
            log.debug("lengthUnit: {}", unit);
            setLengthUnit(unit);
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.YEAR_MODELED)) != null) {
            String year = a.getValue();
            log.debug("yearModeled: {}", year);
            setYearModeled(year);
        }
        // next eight attributes are here for backward compatibility
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_LOC_COMMENTS)) != null) {
            String enable = a.getValue();
            log.debug("printLocComments: {}", enable);
            setPrintLocationCommentsEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_ROUTE_COMMENTS)) != null) {
            String enable = a.getValue();
            log.debug("printRouteComments: {}", enable);
            setPrintRouteCommentsEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_LOADS_EMPTIES)) != null) {
            String enable = a.getValue();
            log.debug("printLoadsEmpties: {}", enable);
            setPrintLoadsAndEmptiesEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_TIMETABLE)) != null) {
            String enable = a.getValue();
            log.debug("printTimetable: {}", enable);
            setPrintTimetableNameEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.USE12HR_FORMAT)) != null) {
            String enable = a.getValue();
            log.debug("use12hrFormat: {}", enable);
            set12hrFormatEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_VALID)) != null) {
            String enable = a.getValue();
            log.debug("printValid: {}", enable);
            setPrintValidEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SORT_BY_TRACK)) != null) {
            String enable = a.getValue();
            log.debug("sortByTrack: {}", enable);
            setSortByTrackNameEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_HEADERS)) != null) {
            String enable = a.getValue();
            log.debug("printHeaders: {}", enable);
            setPrintHeadersEnabled(enable.equals(Xml.TRUE));
        }
    }
    if (operations.getChild(Xml.PICKUP_ENG_FORMAT) != null) {
        if ((a = operations.getChild(Xml.PICKUP_ENG_FORMAT).getAttribute(Xml.PREFIX)) != null) {
            setPickupEnginePrefix(a.getValue());
        }
        if ((a = operations.getChild(Xml.PICKUP_ENG_FORMAT).getAttribute(Xml.SETTING)) != null) {
            String setting = a.getValue();
            log.debug("pickupEngFormat: {}", setting);
            String[] keys = setting.split(",");
            keyToStringConversion(keys);
            setPickupEngineMessageFormat(keys);
        }
    }
    if (operations.getChild(Xml.DROP_ENG_FORMAT) != null) {
        if ((a = operations.getChild(Xml.DROP_ENG_FORMAT).getAttribute(Xml.PREFIX)) != null) {
            setDropEnginePrefix(a.getValue());
        }
        if ((a = operations.getChild(Xml.DROP_ENG_FORMAT).getAttribute(Xml.SETTING)) != null) {
            String setting = a.getValue();
            log.debug("dropEngFormat: {}", setting);
            String[] keys = setting.split(",");
            keyToStringConversion(keys);
            setDropEngineMessageFormat(keys);
        }
    }
    if (operations.getChild(Xml.PICKUP_CAR_FORMAT) != null) {
        if ((a = operations.getChild(Xml.PICKUP_CAR_FORMAT).getAttribute(Xml.PREFIX)) != null) {
            setPickupCarPrefix(a.getValue());
        }
        if ((a = operations.getChild(Xml.PICKUP_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) {
            String setting = a.getValue();
            log.debug("pickupCarFormat: {}", setting);
            String[] keys = setting.split(",");
            replaceOldFormat(keys);
            xmlAttributeToKeyConversion(keys);
            keyToStringConversion(keys);
            setPickupManifestMessageFormat(keys);
        }
    }
    if (operations.getChild(Xml.DROP_CAR_FORMAT) != null) {
        if ((a = operations.getChild(Xml.DROP_CAR_FORMAT).getAttribute(Xml.PREFIX)) != null) {
            setDropCarPrefix(a.getValue());
        }
        if ((a = operations.getChild(Xml.DROP_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) {
            String setting = a.getValue();
            log.debug("dropCarFormat: {}", setting);
            String[] keys = setting.split(",");
            replaceOldFormat(keys);
            xmlAttributeToKeyConversion(keys);
            keyToStringConversion(keys);
            setDropManifestMessageFormat(keys);
        }
    }
    if (operations.getChild(Xml.LOCAL_FORMAT) != null) {
        if ((a = operations.getChild(Xml.LOCAL_FORMAT).getAttribute(Xml.PREFIX)) != null) {
            setLocalPrefix(a.getValue());
        }
        if ((a = operations.getChild(Xml.LOCAL_FORMAT).getAttribute(Xml.SETTING)) != null) {
            String setting = a.getValue();
            log.debug("localFormat: {}", setting);
            String[] keys = setting.split(",");
            replaceOldFormat(keys);
            xmlAttributeToKeyConversion(keys);
            keyToStringConversion(keys);
            setLocalManifestMessageFormat(keys);
        }
    }
    if (operations.getChild(Xml.MISSING_CAR_FORMAT) != null) {
        if ((a = operations.getChild(Xml.MISSING_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) {
            String setting = a.getValue();
            log.debug("missingCarFormat: {}", setting);
            String[] keys = setting.split(",");
            keyToStringConversion(keys);
            setMissingCarMessageFormat(keys);
        }
    }
    if (operations.getChild(Xml.SWITCH_LIST) != null) {
        if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.SAME_AS_MANIFEST)) != null) {
            String b = a.getValue();
            log.debug("sameAsManifest: {}", b);
            setSwitchListFormatSameAsManifest(b.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.REAL_TIME)) != null) {
            String b = a.getValue();
            log.debug("realTime: {}", b);
            getDefault().switchListRealTime = b.equals(Xml.TRUE);
        }
        if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.ALL_TRAINS)) != null) {
            String b = a.getValue();
            log.debug("allTrains: {}", b);
            getDefault().switchListAllTrains = b.equals(Xml.TRUE);
        }
        if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.PAGE_FORMAT)) != null) {
            switch(a.getValue()) {
                case Xml.PAGE_NORMAL:
                    getDefault().switchListPageFormat = PAGE_NORMAL;
                    break;
                case Xml.PAGE_PER_TRAIN:
                    getDefault().switchListPageFormat = PAGE_PER_TRAIN;
                    break;
                case Xml.PAGE_PER_VISIT:
                    getDefault().switchListPageFormat = PAGE_PER_VISIT;
                    break;
                default:
                    log.error("Unknown switch list page format {}", a.getValue());
            }
        } else // old way to save switch list page format pre 3.11
        if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.PAGE_MODE)) != null) {
            String b = a.getValue();
            log.debug("old style pageMode: {}", b);
            if (b.equals(Xml.TRUE)) {
                getDefault().switchListPageFormat = PAGE_PER_TRAIN;
            }
        }
        if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.PRINT_ROUTE_LOCATION)) != null) {
            String b = a.getValue();
            log.debug("print route location comment: {}", b);
            setSwitchListRouteLocationCommentEnabled(b.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.TRACK_SUMMARY)) != null) {
            String b = a.getValue();
            log.debug("track summary: {}", b);
            setTrackSummaryEnabled(b.equals(Xml.TRUE));
        }
    }
    if (operations.getChild(Xml.SWITCH_LIST_PICKUP_CAR_FORMAT) != null) {
        if ((a = operations.getChild(Xml.SWITCH_LIST_PICKUP_CAR_FORMAT).getAttribute(Xml.PREFIX)) != null) {
            setSwitchListPickupCarPrefix(a.getValue());
        }
        if ((a = operations.getChild(Xml.SWITCH_LIST_PICKUP_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) {
            String setting = a.getValue();
            log.debug("switchListpickupCarFormat: {}", setting);
            String[] keys = setting.split(",");
            replaceOldFormat(keys);
            xmlAttributeToKeyConversion(keys);
            keyToStringConversion(keys);
            setPickupSwitchListMessageFormat(keys);
        }
    }
    if (operations.getChild(Xml.SWITCH_LIST_DROP_CAR_FORMAT) != null) {
        if ((a = operations.getChild(Xml.SWITCH_LIST_DROP_CAR_FORMAT).getAttribute(Xml.PREFIX)) != null) {
            setSwitchListDropCarPrefix(a.getValue());
        }
        if ((a = operations.getChild(Xml.SWITCH_LIST_DROP_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) {
            String setting = a.getValue();
            log.debug("switchListDropCarFormat: {}", setting);
            String[] keys = setting.split(",");
            replaceOldFormat(keys);
            xmlAttributeToKeyConversion(keys);
            keyToStringConversion(keys);
            setDropSwitchListMessageFormat(keys);
        }
    }
    if (operations.getChild(Xml.SWITCH_LIST_LOCAL_FORMAT) != null) {
        if ((a = operations.getChild(Xml.SWITCH_LIST_LOCAL_FORMAT).getAttribute(Xml.PREFIX)) != null) {
            setSwitchListLocalPrefix(a.getValue());
        }
        if ((a = operations.getChild(Xml.SWITCH_LIST_LOCAL_FORMAT).getAttribute(Xml.SETTING)) != null) {
            String setting = a.getValue();
            log.debug("switchListLocalFormat: {}", setting);
            String[] keys = setting.split(",");
            replaceOldFormat(keys);
            xmlAttributeToKeyConversion(keys);
            keyToStringConversion(keys);
            setLocalSwitchListMessageFormat(keys);
        }
    }
    if (operations.getChild(Xml.PANEL) != null) {
        if ((a = operations.getChild(Xml.PANEL).getAttribute(Xml.NAME)) != null) {
            String panel = a.getValue();
            log.debug("panel: {}", panel);
            setPanelName(panel);
        }
        if ((a = operations.getChild(Xml.PANEL).getAttribute(Xml.TRAIN_ICONXY)) != null) {
            String enable = a.getValue();
            log.debug("TrainIconXY: {}", enable);
            setTrainIconCordEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.PANEL).getAttribute(Xml.TRAIN_ICON_APPEND)) != null) {
            String enable = a.getValue();
            log.debug("TrainIconAppend: {}", enable);
            setTrainIconAppendEnabled(enable.equals(Xml.TRUE));
        }
    }
    if ((operations.getChild(Xml.FONT_NAME) != null) && (a = operations.getChild(Xml.FONT_NAME).getAttribute(Xml.NAME)) != null) {
        String font = a.getValue();
        log.debug("fontName: {}", font);
        setFontName(font);
    }
    if ((operations.getChild(Xml.FONT_SIZE) != null) && (a = operations.getChild(Xml.FONT_SIZE).getAttribute(Xml.SIZE)) != null) {
        String size = a.getValue();
        log.debug("fontsize: {}", size);
        try {
            setManifestFontSize(Integer.parseInt(size));
        } catch (NumberFormatException ee) {
            log.error("Manifest font size ({}) isn't a valid number", a.getValue());
        }
    }
    if ((operations.getChild(Xml.PAGE_ORIENTATION) != null)) {
        if ((a = operations.getChild(Xml.PAGE_ORIENTATION).getAttribute(Xml.MANIFEST)) != null) {
            String orientation = a.getValue();
            log.debug("manifestOrientation: {}", orientation);
            setManifestOrientation(orientation);
        }
        if ((a = operations.getChild(Xml.PAGE_ORIENTATION).getAttribute(Xml.SWITCH_LIST)) != null) {
            String orientation = a.getValue();
            log.debug("switchListOrientation: {}", orientation);
            setSwitchListOrientation(orientation);
        }
    }
    if ((operations.getChild(Xml.MANIFEST_COLORS) != null)) {
        if ((a = operations.getChild(Xml.MANIFEST_COLORS).getAttribute(Xml.DROP_COLOR)) != null) {
            String dropColor = a.getValue();
            log.debug("dropColor: {}", dropColor);
            setDropTextColor(dropColor);
        }
        if ((a = operations.getChild(Xml.MANIFEST_COLORS).getAttribute(Xml.PICKUP_COLOR)) != null) {
            String pickupColor = a.getValue();
            log.debug("pickupColor: {}", pickupColor);
            setPickupTextColor(pickupColor);
        }
        if ((a = operations.getChild(Xml.MANIFEST_COLORS).getAttribute(Xml.LOCAL_COLOR)) != null) {
            String localColor = a.getValue();
            log.debug("localColor: {}", localColor);
            setLocalTextColor(localColor);
        }
    }
    if ((operations.getChild(Xml.TAB) != null)) {
        if ((a = operations.getChild(Xml.TAB).getAttribute(Xml.ENABLED)) != null) {
            String enable = a.getValue();
            log.debug("tab: {}", enable);
            setTabEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.TAB).getAttribute(Xml.LENGTH)) != null) {
            String length = a.getValue();
            log.debug("tab 1 length: {}", length);
            try {
                setTab1length(Integer.parseInt(length));
            } catch (NumberFormatException ee) {
                log.error("Tab 1 length ({}) isn't a valid number", a.getValue());
            }
        }
        if ((a = operations.getChild(Xml.TAB).getAttribute(Xml.TAB2_LENGTH)) != null) {
            String length = a.getValue();
            log.debug("tab 2 length: {}", length);
            try {
                setTab2length(Integer.parseInt(length));
            } catch (NumberFormatException ee) {
                log.error("Tab 2 length ({}) isn't a valid number", a.getValue());
            }
        }
        if ((a = operations.getChild(Xml.TAB).getAttribute(Xml.TAB3_LENGTH)) != null) {
            String length = a.getValue();
            log.debug("tab 3 length: {}", length);
            try {
                setTab3length(Integer.parseInt(length));
            } catch (NumberFormatException ee) {
                log.error("Tab 3 length ({}) isn't a valid number", a.getValue());
            }
        }
    }
    if ((operations.getChild(Xml.MANIFEST) != null)) {
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_LOC_COMMENTS)) != null) {
            String enable = a.getValue();
            log.debug("manifest printLocComments: {}", enable);
            setPrintLocationCommentsEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_ROUTE_COMMENTS)) != null) {
            String enable = a.getValue();
            log.debug("manifest printRouteComments: {}", enable);
            setPrintRouteCommentsEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_LOADS_EMPTIES)) != null) {
            String enable = a.getValue();
            log.debug("manifest printLoadsEmpties: {}", enable);
            setPrintLoadsAndEmptiesEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_TIMETABLE)) != null) {
            String enable = a.getValue();
            log.debug("manifest printTimetable: {}", enable);
            setPrintTimetableNameEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.USE12HR_FORMAT)) != null) {
            String enable = a.getValue();
            log.debug("manifest use12hrFormat: {}", enable);
            set12hrFormatEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_VALID)) != null) {
            String enable = a.getValue();
            log.debug("manifest printValid: {}", enable);
            setPrintValidEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.SORT_BY_TRACK)) != null) {
            String enable = a.getValue();
            log.debug("manifest sortByTrack: {}", enable);
            setSortByTrackNameEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_HEADERS)) != null) {
            String enable = a.getValue();
            log.debug("manifest print headers: {}", enable);
            setPrintHeadersEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.TRUNCATE)) != null) {
            String enable = a.getValue();
            log.debug("manifest truncate: {}", enable);
            setTruncateManifestEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.USE_DEPARTURE_TIME)) != null) {
            String enable = a.getValue();
            log.debug("manifest use departure time: {}", enable);
            setUseDepartureTimeEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.USE_EDITOR)) != null) {
            String enable = a.getValue();
            log.debug("manifest useEditor: {}", enable);
            setManifestEditorEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_CABOOSE_LOAD)) != null) {
            String enable = a.getValue();
            log.debug("manifest print caboose load: {}", enable);
            setPrintCabooseLoadEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_PASSENGER_LOAD)) != null) {
            String enable = a.getValue();
            log.debug("manifest print passenger load: {}", enable);
            setPrintPassengerLoadEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.HAZARDOUS_MSG)) != null) {
            String message = a.getValue();
            log.debug("manifest hazardousMsg: {}", message);
            setHazardousMsg(message);
        }
    }
    if ((operations.getChild(Xml.MANIFEST_FORMAT) != null)) {
        if ((a = operations.getChild(Xml.MANIFEST_FORMAT).getAttribute(Xml.VALUE)) != null) {
            switch(a.getValue()) {
                case Xml.STANDARD:
                    getDefault().manifestFormat = STANDARD_FORMAT;
                    break;
                case Xml.TWO_COLUMN:
                    getDefault().manifestFormat = TWO_COLUMN_FORMAT;
                    break;
                case Xml.TWO_COLUMN_TRACK:
                    getDefault().manifestFormat = TWO_COLUMN_TRACK_FORMAT;
                    break;
                default:
                    log.debug("Unknown manifest format");
            }
        }
    } else if ((operations.getChild(Xml.COLUMN_FORMAT) != null)) {
        if ((a = operations.getChild(Xml.COLUMN_FORMAT).getAttribute(Xml.TWO_COLUMNS)) != null) {
            String enable = a.getValue();
            log.debug("two columns: {}", enable);
            if (enable.equals(Xml.TRUE)) {
                setManifestFormat(TWO_COLUMN_FORMAT);
            }
        }
    }
    // get manifest logo
    if ((operations.getChild(Xml.MANIFEST_LOGO) != null)) {
        if ((a = operations.getChild(Xml.MANIFEST_LOGO).getAttribute(Xml.NAME)) != null) {
            setManifestLogoURL(a.getValue());
        }
    }
    // manifest file options
    if ((operations.getChild(Xml.MANIFEST_FILE_OPTIONS) != null)) {
        if ((a = operations.getChild(Xml.MANIFEST_FILE_OPTIONS).getAttribute(Xml.MANIFEST_SAVE)) != null) {
            String enable = a.getValue();
            log.debug("manifest file save option: {}", enable);
            getDefault().saveTrainManifests = enable.equals(Xml.TRUE);
        }
    }
    if ((operations.getChild(Xml.BUILD_OPTIONS) != null)) {
        if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.AGGRESSIVE)) != null) {
            String enable = a.getValue();
            log.debug("aggressive: {}", enable);
            setBuildAggressive(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.NUMBER_PASSES)) != null) {
            String number = a.getValue();
            log.debug("number of passes: {}", number);
            try {
                setNumberPasses(Integer.parseInt(number));
            } catch (NumberFormatException ne) {
                log.debug("Number of passes isn't a number");
            }
        }
        if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_LOCAL_INTERCHANGE)) != null) {
            String enable = a.getValue();
            log.debug("noLocalInterchange: {}", enable);
            setLocalInterchangeMovesEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_LOCAL_SPUR)) != null) {
            String enable = a.getValue();
            log.debug("noLocalSpur: {}", enable);
            setLocalSpurMovesEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_LOCAL_YARD)) != null) {
            String enable = a.getValue();
            log.debug("noLocalYard: {}", enable);
            setLocalYardMovesEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.STAGING_RESTRICTION_ENABLED)) != null) {
            String enable = a.getValue();
            log.debug("stagingRestrictionEnabled: {}", enable);
            setTrainIntoStagingCheckEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.STAGING_TRACK_AVAIL)) != null) {
            String enable = a.getValue();
            log.debug("stagingTrackAvail: {}", enable);
            setStagingTrackImmediatelyAvail(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_RETURN_STAGING)) != null) {
            String enable = a.getValue();
            log.debug("allowReturnStaging: {}", enable);
            setAllowReturnToStagingEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.PROMPT_STAGING_ENABLED)) != null) {
            String enable = a.getValue();
            log.debug("promptStagingEnabled: {}", enable);
            setPromptFromStagingEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.PROMPT_TO_STAGING_ENABLED)) != null) {
            String enable = a.getValue();
            log.debug("promptToStagingEnabled: {}", enable);
            setPromptToStagingEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.GENERATE_CSV_MANIFEST)) != null) {
            String enable = a.getValue();
            log.debug("generateCvsManifest: {}", enable);
            getDefault().generateCsvManifest = enable.equals(Xml.TRUE);
        }
        if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.GENERATE_CSV_SWITCH_LIST)) != null) {
            String enable = a.getValue();
            log.debug("generateCvsSwitchList: {}", enable);
            getDefault().generateCsvSwitchList = enable.equals(Xml.TRUE);
        }
    }
    if (operations.getChild(Xml.BUILD_REPORT) != null) {
        if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.LEVEL)) != null) {
            String level = a.getValue();
            log.debug("buildReportLevel: {}", level);
            setBuildReportLevel(level);
        }
        if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.ROUTER_LEVEL)) != null) {
            String level = a.getValue();
            log.debug("routerBuildReportLevel: {}", level);
            setRouterBuildReportLevel(level);
        }
        if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.USE_EDITOR)) != null) {
            String enable = a.getValue();
            log.debug("build report useEditor: {}", enable);
            setBuildReportEditorEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.INDENT)) != null) {
            String enable = a.getValue();
            log.debug("build report indent: {}", enable);
            setBuildReportIndentEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.FONT_SIZE)) != null) {
            String size = a.getValue();
            log.debug("build font size: {}", size);
            try {
                setBuildReportFontSize(Integer.parseInt(size));
            } catch (NumberFormatException ee) {
                log.error("Build report font size ({}) isn't a valid number", a.getValue());
            }
        }
        if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.ALWAYS_PREVIEW)) != null) {
            String enable = a.getValue();
            log.debug("build report always preview: {}", enable);
            setBuildReportAlwaysPreviewEnabled(enable.equals(Xml.TRUE));
        }
    }
    if (operations.getChild(Xml.ROUTER) != null) {
        if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.CAR_ROUTING_ENABLED)) != null) {
            String enable = a.getValue();
            log.debug("carRoutingEnabled: {}", enable);
            setCarRoutingEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.CAR_ROUTING_VIA_YARDS)) != null) {
            String enable = a.getValue();
            log.debug("carRoutingViaYards: {}", enable);
            setCarRoutingViaYardsEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.CAR_ROUTING_VIA_STAGING)) != null) {
            String enable = a.getValue();
            log.debug("carRoutingViaStaging: {}", enable);
            setCarRoutingViaStagingEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.FORWARD_TO_YARD)) != null) {
            String enable = a.getValue();
            log.debug("forwardToYard: {}", enable);
            setForwardToYardEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.ONLY_ACTIVE_TRAINS)) != null) {
            String enable = a.getValue();
            log.debug("onlyActiveTrains: {}", enable);
            setOnlyActiveTrainsEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.CHECK_CAR_DESTINATION)) != null) {
            String enable = a.getValue();
            log.debug("checkCarDestination: {}", enable);
            setCheckCarDestinationEnabled(enable.equals(Xml.TRUE));
        }
    } else if (operations.getChild(Xml.SETTINGS) != null) {
        // the next four items are for backwards compatibility
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_ROUTING_ENABLED)) != null) {
            String enable = a.getValue();
            log.debug("carRoutingEnabled: {}", enable);
            setCarRoutingEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_ROUTING_VIA_YARDS)) != null) {
            String enable = a.getValue();
            log.debug("carRoutingViaYards: {}", enable);
            setCarRoutingViaYardsEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_ROUTING_VIA_STAGING)) != null) {
            String enable = a.getValue();
            log.debug("carRoutingViaStaging: {}", enable);
            setCarRoutingViaStagingEnabled(enable.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.FORWARD_TO_YARD)) != null) {
            String enable = a.getValue();
            log.debug("forwardToYard: {}", enable);
            setForwardToYardEnabled(enable.equals(Xml.TRUE));
        }
    }
    if ((operations.getChild(Xml.OWNER) != null) && (a = operations.getChild(Xml.OWNER).getAttribute(Xml.NAME)) != null) {
        String owner = a.getValue();
        log.debug("owner: {}", owner);
        setOwnerName(owner);
    }
    if (operations.getChild(Xml.ICON_COLOR) != null) {
        if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.NORTH)) != null) {
            String color = a.getValue();
            log.debug("north color: {}", color);
            setTrainIconColorNorth(color);
        }
        if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.SOUTH)) != null) {
            String color = a.getValue();
            log.debug("south color: {}", color);
            setTrainIconColorSouth(color);
        }
        if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.EAST)) != null) {
            String color = a.getValue();
            log.debug("east color: {}", color);
            setTrainIconColorEast(color);
        }
        if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.WEST)) != null) {
            String color = a.getValue();
            log.debug("west color: {}", color);
            setTrainIconColorWest(color);
        }
        if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.LOCAL)) != null) {
            String color = a.getValue();
            log.debug("local color: {}", color);
            setTrainIconColorLocal(color);
        }
        if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.TERMINATE)) != null) {
            String color = a.getValue();
            log.debug("terminate color: {}", color);
            setTrainIconColorTerminate(color);
        }
    }
    if (operations.getChild(Xml.COMMENTS) != null) {
        if ((a = operations.getChild(Xml.COMMENTS).getAttribute(Xml.MISPLACED_CARS)) != null) {
            String comment = a.getValue();
            log.debug("Misplaced comment: {}", comment);
            setMiaComment(comment);
        }
    }
    if (operations.getChild(Xml.DISPLAY) != null) {
        if ((a = operations.getChild(Xml.DISPLAY).getAttribute(Xml.SHOW_TRACK_MOVES)) != null) {
            String enable = a.getValue();
            log.debug("show track moves: {}", enable);
            getDefault().showTrackMoves = enable.equals(Xml.TRUE);
        }
    }
    if (operations.getChild(Xml.VSD) != null) {
        if ((a = operations.getChild(Xml.VSD).getAttribute(Xml.ENABLE_PHYSICAL_LOCATIONS)) != null) {
            String enable = a.getValue();
            setVsdPhysicalLocationEnabled(enable.equals(Xml.TRUE));
        }
    }
    if (operations.getChild(Xml.CATS) != null) {
        if ((a = operations.getChild(Xml.CATS).getAttribute(Xml.EXACT_LOCATION_NAME)) != null) {
            String enable = a.getValue();
            AbstractOperationsServer.setExactLocationName(enable.equals(Xml.TRUE));
        }
    }
    if (operations.getChild(Xml.SETTINGS) != null) {
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.AUTO_SAVE)) != null) {
            String enabled = a.getValue();
            log.debug("autoSave: {}", enabled);
            setAutoSaveEnabled(enabled.equals(Xml.TRUE));
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.AUTO_BACKUP)) != null) {
            String enabled = a.getValue();
            log.debug("autoBackup: {}", enabled);
            setAutoBackupEnabled(enabled.equals(Xml.TRUE));
        }
    }
    if (operations.getChild(Xml.LOGGER) != null) {
        if ((a = operations.getChild(Xml.LOGGER).getAttribute(Xml.CAR_LOGGER)) != null) {
            String enable = a.getValue();
            log.debug("carLogger: {}", enable);
            getDefault().carLogger = enable.equals(Xml.TRUE);
        }
        if ((a = operations.getChild(Xml.LOGGER).getAttribute(Xml.ENGINE_LOGGER)) != null) {
            String enable = a.getValue();
            log.debug("engineLogger: {}", enable);
            getDefault().engineLogger = enable.equals(Xml.TRUE);
        }
        if ((a = operations.getChild(Xml.LOGGER).getAttribute(Xml.TRAIN_LOGGER)) != null) {
            String enable = a.getValue();
            log.debug("trainLogger: {}", enable);
            getDefault().trainLogger = enable.equals(Xml.TRUE);
        }
    } else if (operations.getChild(Xml.SETTINGS) != null) {
        // for backward compatibility
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_LOGGER)) != null) {
            String enable = a.getValue();
            log.debug("carLogger: {}", enable);
            getDefault().carLogger = enable.equals(Xml.TRUE);
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.ENGINE_LOGGER)) != null) {
            String enable = a.getValue();
            log.debug("engineLogger: {}", enable);
            getDefault().engineLogger = enable.equals(Xml.TRUE);
        }
        if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.TRAIN_LOGGER)) != null) {
            String enable = a.getValue();
            log.debug("trainLogger: {}", enable);
            getDefault().trainLogger = enable.equals(Xml.TRUE);
        }
    }
}
Also used : Element(org.jdom2.Element)

Example 68 with Element

use of org.jdom2.Element in project JMRI by JMRI.

the class OperationsSetupXml method writeFile.

@Override
public void writeFile(String name) throws java.io.FileNotFoundException, java.io.IOException {
    log.debug("writeFile {}", name);
    // This is taken in large part from "Java and XML" page 368
    File file = findFile(name);
    if (file == null) {
        file = new File(name);
    }
    // create root element
    // NOI18N
    Element root = new Element("operations-config");
    // NOI18N
    Document doc = newDocument(root, dtdLocation + "operations-config.dtd");
    // add XSLT processing instruction
    java.util.Map<String, String> m = new java.util.HashMap<String, String>();
    // NOI18N
    m.put("type", "text/xsl");
    // NOI18N
    m.put("href", xsltLocation + "operations-config.xsl");
    // NOI18N
    ProcessingInstruction p = new ProcessingInstruction("xml-stylesheet", m);
    doc.addContent(0, p);
    // add top-level elements         
    root.addContent(Setup.store());
    // add manifest header text strings
    root.addContent(TrainManifestHeaderText.store());
    // add manifest text strings
    root.addContent(TrainManifestText.store());
    // add switch list text strings
    root.addContent(TrainSwitchListText.store());
    // add control elements
    root.addContent(Control.store());
    writeXML(file, doc);
    // done, so can't be dirty
    setDirty(false);
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) File(java.io.File) ProcessingInstruction(org.jdom2.ProcessingInstruction)

Example 69 with Element

use of org.jdom2.Element in project JMRI by JMRI.

the class TrainManifestHeaderText method store.

// must synchronize changes with operation-config.dtd
public static Element store() {
    Element values;
    Element e = new Element(Xml.MANIFEST_HEADER_TEXT_STRINGS);
    // only save strings that have been modified
    if (!getStringHeader_Road().equals(Bundle.getMessage("Road"))) {
        e.addContent(values = new Element(Xml.ROAD));
        values.setAttribute(Xml.TEXT, getStringHeader_Road());
    }
    if (!getStringHeader_Number().equals(Bundle.getMessage("Number"))) {
        e.addContent(values = new Element(Xml.NUMBER));
        values.setAttribute(Xml.TEXT, getStringHeader_Number());
    }
    if (!getStringHeader_EngineNumber().equals(Bundle.getMessage("Number"))) {
        e.addContent(values = new Element(Xml.ENGINE_NUMBER));
        values.setAttribute(Xml.TEXT, getStringHeader_EngineNumber());
    }
    if (!getStringHeader_Type().equals(Bundle.getMessage("Type"))) {
        e.addContent(values = new Element(Xml.TYPE));
        values.setAttribute(Xml.TEXT, getStringHeader_Type());
    }
    if (!getStringHeader_Model().equals(Bundle.getMessage("Model"))) {
        e.addContent(values = new Element(Xml.MODEL));
        values.setAttribute(Xml.TEXT, getStringHeader_Model());
    }
    if (!getStringHeader_Length().equals(Bundle.getMessage("Length"))) {
        e.addContent(values = new Element(Xml.LENGTH));
        values.setAttribute(Xml.TEXT, getStringHeader_Length());
    }
    if (!getStringHeader_Load().equals(Bundle.getMessage("Load"))) {
        e.addContent(values = new Element(Xml.LOAD));
        values.setAttribute(Xml.TEXT, getStringHeader_Load());
    }
    if (!getStringHeader_Color().equals(Bundle.getMessage("Color"))) {
        e.addContent(values = new Element(Xml.COLOR));
        values.setAttribute(Xml.TEXT, getStringHeader_Color());
    }
    if (!getStringHeader_Track().equals(Bundle.getMessage("Track"))) {
        e.addContent(values = new Element(Xml.TRACK));
        values.setAttribute(Xml.TEXT, getStringHeader_Track());
    }
    if (!getStringHeader_Destination().equals(Bundle.getMessage("Destination"))) {
        e.addContent(values = new Element(Xml.DESTINATION));
        values.setAttribute(Xml.TEXT, getStringHeader_Destination());
    }
    if (!getStringHeader_Dest_Track().equals(Bundle.getMessage("Dest&Track"))) {
        e.addContent(values = new Element(Xml.DEST_TRACK));
        values.setAttribute(Xml.TEXT, getStringHeader_Dest_Track());
    }
    if (!getStringHeader_Final_Dest().equals(Bundle.getMessage("Final_Dest"))) {
        e.addContent(values = new Element(Xml.FINAL_DEST));
        values.setAttribute(Xml.TEXT, getStringHeader_Final_Dest());
    }
    if (!getStringHeader_Final_Dest_Track().equals(Bundle.getMessage("FD&Track"))) {
        e.addContent(values = new Element(Xml.FINAL_DEST_TRACK));
        values.setAttribute(Xml.TEXT, getStringHeader_Final_Dest_Track());
    }
    if (!getStringHeader_Location().equals(Bundle.getMessage("Location"))) {
        e.addContent(values = new Element(Xml.LOCATION));
        values.setAttribute(Xml.TEXT, getStringHeader_Location());
    }
    if (!getStringHeader_Consist().equals(Bundle.getMessage("Consist"))) {
        e.addContent(values = new Element(Xml.CONSIST));
        values.setAttribute(Xml.TEXT, getStringHeader_Consist());
    }
    if (!getStringHeader_Kernel().equals(Bundle.getMessage("Kernel"))) {
        e.addContent(values = new Element(Xml.KERNEL));
        values.setAttribute(Xml.TEXT, getStringHeader_Kernel());
    }
    if (!getStringHeader_Owner().equals(Bundle.getMessage("Owner"))) {
        e.addContent(values = new Element(Xml.OWNER));
        values.setAttribute(Xml.TEXT, getStringHeader_Owner());
    }
    if (!getStringHeader_RWE().equals(Bundle.getMessage("RWELabel"))) {
        e.addContent(values = new Element(Xml.RWE));
        values.setAttribute(Xml.TEXT, getStringHeader_RWE());
    }
    if (!getStringHeader_Comment().equals(Bundle.getMessage("Comment"))) {
        e.addContent(values = new Element(Xml.COMMENT));
        values.setAttribute(Xml.TEXT, getStringHeader_Comment());
    }
    if (!getStringHeader_Drop_Comment().equals(Bundle.getMessage("SetOut_Msg"))) {
        e.addContent(values = new Element(Xml.DROP_COMMENT));
        values.setAttribute(Xml.TEXT, getStringHeader_Drop_Comment());
    }
    if (!getStringHeader_Pickup_Comment().equals(Bundle.getMessage("PickUp_Msg"))) {
        e.addContent(values = new Element(Xml.PICKUP_COMMENT));
        values.setAttribute(Xml.TEXT, getStringHeader_Pickup_Comment());
    }
    if (!getStringHeader_Hazardous().equals(Bundle.getMessage("Hazardous"))) {
        e.addContent(values = new Element(Xml.HAZARDOUS));
        values.setAttribute(Xml.TEXT, getStringHeader_Hazardous());
    }
    return e;
}
Also used : Element(org.jdom2.Element)

Example 70 with Element

use of org.jdom2.Element in project JMRI by JMRI.

the class TrainManifestText method store.

// must synchronize changes with operation-config.dtd
public static Element store() {
    Element values;
    Element e = new Element(Xml.MANIFEST_TEXT_STRINGS);
    // only save strings that have been modified
    if (!getStringManifestForTrain().equals(Bundle.getMessage("ManifestForTrain"))) {
        e.addContent(values = new Element(Xml.MANIFEST_FOR_TRAIN));
        values.setAttribute(Xml.TEXT, getStringManifestForTrain());
    }
    if (!getStringValid().equals(Bundle.getMessage("Valid"))) {
        e.addContent(values = new Element(Xml.VALID));
        values.setAttribute(Xml.TEXT, getStringValid());
    }
    if (!getStringScheduledWork().equals(Bundle.getMessage("ScheduledWorkAt"))) {
        e.addContent(values = new Element(Xml.SCHEDULED_WORK));
        values.setAttribute(Xml.TEXT, getStringScheduledWork());
    }
    if (!getStringWorkDepartureTime().equals(Bundle.getMessage("WorkDepartureTime"))) {
        e.addContent(values = new Element(Xml.WORK_DEPARTURE_TIME));
        values.setAttribute(Xml.TEXT, getStringWorkDepartureTime());
    }
    if (!getStringWorkArrivalTime().equals(Bundle.getMessage("WorkArrivalTime"))) {
        e.addContent(values = new Element(Xml.WORK_ARRIVAL_TIME));
        values.setAttribute(Xml.TEXT, getStringWorkArrivalTime());
    }
    if (!getStringNoScheduledWork().equals(Bundle.getMessage("NoScheduledWorkAt"))) {
        e.addContent(values = new Element(Xml.NO_SCHEDULED_WORK));
        values.setAttribute(Xml.TEXT, getStringNoScheduledWork());
    }
    if (!getStringNoScheduledWorkWithRouteComment().equals(Bundle.getMessage("NoScheduledWorkAtWithRouteComment"))) {
        e.addContent(values = new Element(Xml.NO_SCHEDULED_WORK_ROUTE_COMMENT));
        values.setAttribute(Xml.TEXT, getStringNoScheduledWorkWithRouteComment());
    }
    if (!getStringDepartTime().equals(Bundle.getMessage("departureTime"))) {
        e.addContent(values = new Element(Xml.DEPART_TIME));
        values.setAttribute(Xml.TEXT, getStringDepartTime());
    }
    if (!getStringTrainDepartsCars().equals(Bundle.getMessage("TrainDepartsCars"))) {
        e.addContent(values = new Element(Xml.TRAIN_DEPARTS_CARS));
        values.setAttribute(Xml.TEXT, getStringTrainDepartsCars());
    }
    if (!getStringTrainDepartsLoads().equals(Bundle.getMessage("TrainDepartsLoads"))) {
        e.addContent(values = new Element(Xml.TRAIN_DEPARTS_LOADS));
        values.setAttribute(Xml.TEXT, getStringTrainDepartsLoads());
    }
    if (!getStringTrainTerminates().equals(Bundle.getMessage("TrainTerminatesIn"))) {
        e.addContent(values = new Element(Xml.TRAIN_TERMINATES));
        values.setAttribute(Xml.TEXT, getStringTrainTerminates());
    }
    if (!getStringDestination().equals(Bundle.getMessage("destination"))) {
        e.addContent(values = new Element(Xml.DESTINATION));
        values.setAttribute(Xml.TEXT, getStringDestination());
    }
    if (!getStringFrom().equals(Bundle.getMessage("from"))) {
        e.addContent(values = new Element(Xml.FROM));
        values.setAttribute(Xml.TEXT, getStringFrom());
    }
    if (!getStringTo().equals(Bundle.getMessage("to"))) {
        e.addContent(values = new Element(Xml.TO));
        values.setAttribute(Xml.TEXT, getStringTo());
    }
    if (!getStringDest().equals(Bundle.getMessage("dest"))) {
        e.addContent(values = new Element(Xml.DEST));
        values.setAttribute(Xml.TEXT, getStringDest());
    }
    if (!getStringFinalDestination().equals(Bundle.getMessage("FD"))) {
        e.addContent(values = new Element(Xml.FINAL_DEST));
        values.setAttribute(Xml.TEXT, getStringFinalDestination());
    }
    if (!getStringAddHelpers().equals(Bundle.getMessage("AddHelpersAt"))) {
        e.addContent(values = new Element(Xml.ADD_HELPERS));
        values.setAttribute(Xml.TEXT, getStringAddHelpers());
    }
    if (!getStringRemoveHelpers().equals(Bundle.getMessage("RemoveHelpersAt"))) {
        e.addContent(values = new Element(Xml.REMOVE_HELPERS));
        values.setAttribute(Xml.TEXT, getStringRemoveHelpers());
    }
    if (!getStringLocoChange().equals(Bundle.getMessage("LocoChangeAt"))) {
        e.addContent(values = new Element(Xml.LOCO_CHANGE));
        values.setAttribute(Xml.TEXT, getStringLocoChange());
    }
    if (!getStringCabooseChange().equals(Bundle.getMessage("CabooseChangeAt"))) {
        e.addContent(values = new Element(Xml.CABOOSE_CHANGE));
        values.setAttribute(Xml.TEXT, getStringCabooseChange());
    }
    if (!getStringLocoAndCabooseChange().equals(Bundle.getMessage("LocoAndCabooseChangeAt"))) {
        e.addContent(values = new Element(Xml.LOCO_CABOOSE_CHANGE));
        values.setAttribute(Xml.TEXT, getStringLocoAndCabooseChange());
    }
    return e;
}
Also used : Element(org.jdom2.Element)

Aggregations

Element (org.jdom2.Element)673 Attribute (org.jdom2.Attribute)103 Document (org.jdom2.Document)64 File (java.io.File)49 ArrayList (java.util.ArrayList)36 NamedIcon (jmri.jmrit.catalog.NamedIcon)28 IOException (java.io.IOException)27 DataConversionException (org.jdom2.DataConversionException)26 JDOMException (org.jdom2.JDOMException)26 XmlFile (jmri.jmrit.XmlFile)24 Test (org.junit.Test)24 Editor (jmri.jmrit.display.Editor)22 DocType (org.jdom2.DocType)21 Turnout (jmri.Turnout)20 ProcessingInstruction (org.jdom2.ProcessingInstruction)16 Point (java.awt.Point)15 HashMap (java.util.HashMap)15 SignalHead (jmri.SignalHead)15 LayoutEditor (jmri.jmrit.display.layoutEditor.LayoutEditor)15 Dimension (java.awt.Dimension)14