Search in sources :

Example 56 with Attribute

use of ucar.nc2.Attribute in project JMRI by JMRI.

the class TrainManifestText method load.

public static void load(Element e) {
    Element emts = e.getChild(Xml.MANIFEST_TEXT_STRINGS);
    if (emts == null) {
        return;
    }
    Attribute a;
    if (emts.getChild(Xml.MANIFEST_FOR_TRAIN) != null) {
        if ((a = emts.getChild(Xml.MANIFEST_FOR_TRAIN).getAttribute(Xml.TEXT)) != null) {
            setStringManifestForTrain(a.getValue());
        }
    }
    if (emts.getChild(Xml.VALID) != null) {
        if ((a = emts.getChild(Xml.VALID).getAttribute(Xml.TEXT)) != null) {
            setStringValid(a.getValue());
        }
    }
    if (emts.getChild(Xml.SCHEDULED_WORK) != null) {
        if ((a = emts.getChild(Xml.SCHEDULED_WORK).getAttribute(Xml.TEXT)) != null) {
            setStringScheduledWork(a.getValue());
        }
    }
    if (emts.getChild(Xml.WORK_DEPARTURE_TIME) != null) {
        if ((a = emts.getChild(Xml.WORK_DEPARTURE_TIME).getAttribute(Xml.TEXT)) != null) {
            setStringWorkDepartureTime(a.getValue());
        }
    }
    if (emts.getChild(Xml.WORK_ARRIVAL_TIME) != null) {
        if ((a = emts.getChild(Xml.WORK_ARRIVAL_TIME).getAttribute(Xml.TEXT)) != null) {
            setStringWorkArrivalTime(a.getValue());
        }
    }
    if (emts.getChild(Xml.NO_SCHEDULED_WORK) != null) {
        if ((a = emts.getChild(Xml.NO_SCHEDULED_WORK).getAttribute(Xml.TEXT)) != null) {
            setStringNoScheduledWork(a.getValue());
        }
    }
    if (emts.getChild(Xml.NO_SCHEDULED_WORK_ROUTE_COMMENT) != null) {
        if ((a = emts.getChild(Xml.NO_SCHEDULED_WORK_ROUTE_COMMENT).getAttribute(Xml.TEXT)) != null) {
            setStringNoScheduledWorkWithRouteComment(a.getValue());
        }
    }
    if (emts.getChild(Xml.DEPART_TIME) != null) {
        if ((a = emts.getChild(Xml.DEPART_TIME).getAttribute(Xml.TEXT)) != null) {
            setStringDepartTime(a.getValue());
        }
    }
    if (emts.getChild(Xml.TRAIN_DEPARTS_CARS) != null) {
        if ((a = emts.getChild(Xml.TRAIN_DEPARTS_CARS).getAttribute(Xml.TEXT)) != null) {
            setStringTrainDepartsCars(a.getValue());
        }
    }
    if (emts.getChild(Xml.TRAIN_DEPARTS_LOADS) != null) {
        if ((a = emts.getChild(Xml.TRAIN_DEPARTS_LOADS).getAttribute(Xml.TEXT)) != null) {
            setStringTrainDepartsLoads(a.getValue());
        }
    }
    if (emts.getChild(Xml.TRAIN_TERMINATES) != null) {
        if ((a = emts.getChild(Xml.TRAIN_TERMINATES).getAttribute(Xml.TEXT)) != null) {
            setStringTrainTerminates(a.getValue());
        }
    }
    if (emts.getChild(Xml.DESTINATION) != null) {
        if ((a = emts.getChild(Xml.DESTINATION).getAttribute(Xml.TEXT)) != null) {
            setStringDestination(a.getValue());
        }
    }
    if (emts.getChild(Xml.TO) != null) {
        if ((a = emts.getChild(Xml.TO).getAttribute(Xml.TEXT)) != null) {
            setStringTo(a.getValue());
        }
    }
    if (emts.getChild(Xml.FROM) != null) {
        if ((a = emts.getChild(Xml.FROM).getAttribute(Xml.TEXT)) != null) {
            setStringFrom(a.getValue());
        }
    }
    if (emts.getChild(Xml.DEST) != null) {
        if ((a = emts.getChild(Xml.DEST).getAttribute(Xml.TEXT)) != null) {
            setStringDest(a.getValue());
        }
    }
    if (emts.getChild(Xml.FINAL_DEST) != null) {
        if ((a = emts.getChild(Xml.FINAL_DEST).getAttribute(Xml.TEXT)) != null) {
            setStringFinalDestination(a.getValue());
        }
    }
    if (emts.getChild(Xml.ADD_HELPERS) != null) {
        if ((a = emts.getChild(Xml.ADD_HELPERS).getAttribute(Xml.TEXT)) != null) {
            setStringAddHelpers(a.getValue());
        }
    }
    if (emts.getChild(Xml.REMOVE_HELPERS) != null) {
        if ((a = emts.getChild(Xml.REMOVE_HELPERS).getAttribute(Xml.TEXT)) != null) {
            setStringRemoveHelpers(a.getValue());
        }
    }
    if (emts.getChild(Xml.LOCO_CHANGE) != null) {
        if ((a = emts.getChild(Xml.LOCO_CHANGE).getAttribute(Xml.TEXT)) != null) {
            setStringLocoChange(a.getValue());
        }
    }
    if (emts.getChild(Xml.CABOOSE_CHANGE) != null) {
        if ((a = emts.getChild(Xml.CABOOSE_CHANGE).getAttribute(Xml.TEXT)) != null) {
            setStringCabooseChange(a.getValue());
        }
    }
    if (emts.getChild(Xml.LOCO_CABOOSE_CHANGE) != null) {
        if ((a = emts.getChild(Xml.LOCO_CABOOSE_CHANGE).getAttribute(Xml.TEXT)) != null) {
            setStringLocoAndCabooseChange(a.getValue());
        }
    }
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element)

Example 57 with Attribute

use of ucar.nc2.Attribute in project JMRI by JMRI.

the class RosterEntry method loadFunctions.

/**
     * Loads function names from a JDOM element. Does not change values that are
     * already present!
     *
     * @param e3     the XML element containing the functions
     * @param source "family" if source is the decoder definition, or "model" if
     *               source is the roster entry itself
     */
public void loadFunctions(Element e3, String source) {
    /*Load flag once, means that when the roster entry is edited only the first set of function labels are displayed 
         ie those saved in the roster file, rather than those being left blank
         rather than being over-written by the defaults linked to the decoder def*/
    if (loadedOnce) {
        return;
    }
    if (e3 != null) {
        // load function names
        List<Element> l = e3.getChildren(RosterEntry.FUNCTION_LABEL);
        for (Element fn : l) {
            int num = Integer.parseInt(fn.getAttribute("num").getValue());
            String lock = fn.getAttribute("lockable").getValue();
            String val = fn.getText();
            if ((this.getFunctionLabel(num) == null) || (source.equalsIgnoreCase("model"))) {
                this.setFunctionLabel(num, val);
                this.setFunctionLockable(num, lock.equals("true"));
                Attribute a;
                if ((a = fn.getAttribute("functionImage")) != null && !a.getValue().isEmpty()) {
                    try {
                        if (FileUtil.getFile(a.getValue()).isFile()) {
                            this.setFunctionImage(num, FileUtil.getAbsoluteFilename(a.getValue()));
                        }
                    } catch (FileNotFoundException ex) {
                        try {
                            if (FileUtil.getFile(FileUtil.getUserResourcePath() + a.getValue()).isFile()) {
                                this.setFunctionImage(num, FileUtil.getUserResourcePath() + a.getValue());
                            }
                        } catch (FileNotFoundException ex1) {
                            this.setFunctionImage(num, null);
                        }
                    }
                }
                if ((a = fn.getAttribute("functionImageSelected")) != null && !a.getValue().isEmpty()) {
                    try {
                        if (FileUtil.getFile(a.getValue()).isFile()) {
                            this.setFunctionSelectedImage(num, FileUtil.getAbsoluteFilename(a.getValue()));
                        }
                    } catch (FileNotFoundException ex) {
                        try {
                            if (FileUtil.getFile(FileUtil.getUserResourcePath() + a.getValue()).isFile()) {
                                this.setFunctionSelectedImage(num, FileUtil.getUserResourcePath() + a.getValue());
                            }
                        } catch (FileNotFoundException ex1) {
                            this.setFunctionSelectedImage(num, null);
                        }
                    }
                }
            }
        }
    }
    if (source.equalsIgnoreCase("RosterEntry")) {
        loadedOnce = true;
    }
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) FileNotFoundException(java.io.FileNotFoundException)

Example 58 with Attribute

use of ucar.nc2.Attribute in project JMRI by JMRI.

the class PaneProgPane method newGridItem.

/**
     * Create a grid item from the JDOM Element
     *
     * @param element     element containing grid item contents
     * @param showStdName show the name following the rules for the
     * <em>nameFmt</em> element
     * @param modelElem   element containing the decoder model
     * @param globs       properties to configure the layout
     * @return a panel containing the group
     */
public JPanel newGridItem(Element element, boolean showStdName, Element modelElem, GridGlobals globs) {
    // get item-level attributes
    List<Attribute> itemAttList = element.getAttributes();
    List<Attribute> attList = new ArrayList<>(globs.gridAttList);
    // merge grid and item-level attributes
    attList.addAll(itemAttList);
    //                log.info("New gridtiem -----------------------------------------------");
    //                log.info("Attribute list:"+attList);
    attList.add(new Attribute(LAST_GRIDX, ""));
    attList.add(new Attribute(LAST_GRIDY, ""));
    //                log.info("Previous gridxCurrent="+globs.gridxCurrent+";gridyCurrent="+globs.gridyCurrent);
    for (int j = 0; j < attList.size(); j++) {
        Attribute attrib = attList.get(j);
        String attribName = attrib.getName();
        String attribRawValue = attrib.getValue();
        Field constraint = null;
        String constraintType = null;
        // make sure we only process the last gridx or gridy attribute in the list
        if (attribName.equals("gridx")) {
            Attribute a = new Attribute(LAST_GRIDX, attribRawValue);
            attList.set(attList.size() - 2, a);
            //. don't process now
            continue;
        }
        if (attribName.equals("gridy")) {
            Attribute a = new Attribute(LAST_GRIDY, attribRawValue);
            attList.set(attList.size() - 1, a);
            //. don't process now
            continue;
        }
        if (attribName.equals(LAST_GRIDX)) {
            // we must be at end of original list, restore last gridx
            attribName = "gridx";
            if (attribRawValue.equals("")) {
                // don't process blank (unused)
                continue;
            }
        }
        if (attribName.equals(LAST_GRIDY)) {
            // we must be at end of original list, restore last gridy
            attribName = "gridy";
            if (attribRawValue.equals("")) {
                // don't process blank (unused)
                continue;
            }
        }
        if ((attribName.equals("gridx") || attribName.equals("gridy")) && attribRawValue.equals("RELATIVE")) {
            // NEXT is a synonym for RELATIVE
            attribRawValue = "NEXT";
        }
        if (attribName.equals("gridx") && attribRawValue.equals("CURRENT")) {
            attribRawValue = String.valueOf(Math.max(0, globs.gridxCurrent));
        }
        if (attribName.equals("gridy") && attribRawValue.equals("CURRENT")) {
            attribRawValue = String.valueOf(Math.max(0, globs.gridyCurrent));
        }
        if (attribName.equals("gridx") && attribRawValue.equals("NEXT")) {
            attribRawValue = String.valueOf(++globs.gridxCurrent);
        }
        if (attribName.equals("gridy") && attribRawValue.equals("NEXT")) {
            attribRawValue = String.valueOf(++globs.gridyCurrent);
        }
        //                    log.info("attribName="+attribName+";attribRawValue="+attribRawValue);
        try {
            constraint = globs.gridConstraints.getClass().getDeclaredField(attribName);
            constraintType = constraint.getType().toString();
            constraint.setAccessible(true);
        } catch (NoSuchFieldException ex) {
            log.error("Unrecognised attribute \"" + attribName + "\", skipping");
            continue;
        }
        switch(constraintType) {
            case "int":
                {
                    int attribValue;
                    try {
                        attribValue = Integer.valueOf(attribRawValue);
                        constraint.set(globs.gridConstraints, attribValue);
                    } catch (IllegalAccessException ey) {
                        log.error("Unable to set constraint \"" + attribName + ". IllegalAccessException error thrown.");
                    } catch (NumberFormatException ex) {
                        try {
                            Field constant = globs.gridConstraints.getClass().getDeclaredField(attribRawValue);
                            constant.setAccessible(true);
                            attribValue = (Integer) GridBagConstraints.class.getField(attribRawValue).get(constant);
                            constraint.set(globs.gridConstraints, attribValue);
                        } catch (NoSuchFieldException ey) {
                            log.error("Invalid value \"" + attribRawValue + "\" for attribute \"" + attribName + "\"");
                        } catch (IllegalAccessException ey) {
                            log.error("Unable to set constraint \"" + attribName + ". IllegalAccessException error thrown.");
                        }
                    }
                    break;
                }
            case "double":
                {
                    double attribValue;
                    try {
                        attribValue = Double.valueOf(attribRawValue);
                        constraint.set(globs.gridConstraints, attribValue);
                    } catch (IllegalAccessException ey) {
                        log.error("Unable to set constraint \"" + attribName + ". IllegalAccessException error thrown.");
                    } catch (NumberFormatException ex) {
                        log.error("Invalid value \"" + attribRawValue + "\" for attribute \"" + attribName + "\"");
                    }
                    break;
                }
            case "class java.awt.Insets":
                try {
                    String[] insetStrings = attribRawValue.split(",");
                    if (insetStrings.length == 4) {
                        Insets attribValue = new Insets(Integer.valueOf(insetStrings[0]), Integer.valueOf(insetStrings[1]), Integer.valueOf(insetStrings[2]), Integer.valueOf(insetStrings[3]));
                        constraint.set(globs.gridConstraints, attribValue);
                    } else {
                        log.error("Invalid value \"" + attribRawValue + "\" for attribute \"" + attribName + "\"");
                        log.error("Value should be four integers of the form \"top,left,bottom,right\"");
                    }
                } catch (IllegalAccessException ey) {
                    log.error("Unable to set constraint \"" + attribName + ". IllegalAccessException error thrown.");
                } catch (NumberFormatException ex) {
                    log.error("Invalid value \"" + attribRawValue + "\" for attribute \"" + attribName + "\"");
                    log.error("Value should be four integers of the form \"top,left,bottom,right\"");
                }
                break;
            default:
                log.error("Required \"" + constraintType + "\" handler for attribute \"" + attribName + "\" not defined in JMRI code");
                log.error("Please file a JMRI bug report at https://sourceforge.net/p/jmri/bugs/new/");
                break;
        }
    }
    //                log.info("Updated globs.GridBagConstraints.gridx="+globs.gridConstraints.gridx+";globs.GridBagConstraints.gridy="+globs.gridConstraints.gridy);
    // create a panel to add as a new grid item
    final JPanel c = new JPanel();
    panelList.add(c);
    GridBagLayout g = new GridBagLayout();
    GridBagConstraints cs = new GridBagConstraints();
    c.setLayout(g);
    // handle the xml definition
    // for all elements in the grid item
    List<Element> elemList = element.getChildren();
    log.trace("newGridItem starting with {} elements", elemList.size());
    for (int i = 0; i < elemList.size(); i++) {
        // update the grid position
        cs.gridy = 0;
        cs.gridx++;
        Element e = elemList.get(i);
        String name = e.getName();
        log.trace("newGridItem processing {} element", name);
        // decode the type
        if (name.equals("display")) {
            // its a variable
            // load the variable
            newVariable(e, c, g, cs, showStdName);
        } else if (name.equals("separator")) {
            // its a separator
            JSeparator j = new JSeparator(javax.swing.SwingConstants.VERTICAL);
            cs.fill = GridBagConstraints.BOTH;
            cs.gridheight = GridBagConstraints.REMAINDER;
            g.setConstraints(j, cs);
            c.add(j);
            cs.fill = GridBagConstraints.NONE;
            cs.gridheight = 1;
        } else if (name.equals("label")) {
            cs.gridheight = GridBagConstraints.REMAINDER;
            makeLabel(e, c, g, cs);
        } else if (name.equals("soundlabel")) {
            cs.gridheight = GridBagConstraints.REMAINDER;
            makeSoundLabel(e, c, g, cs);
        } else if (name.equals("cvtable")) {
            makeCvTable(cs, g, c);
        } else if (name.equals("indxcvtable")) {
            log.debug("starting to build IndexedCvTable pane");
            JTable indxcvTable = new JTable(_indexedCvModel);
            JScrollPane cvScroll = new JScrollPane(indxcvTable);
            indxcvTable.setDefaultRenderer(JTextField.class, new ValueRenderer());
            indxcvTable.setDefaultRenderer(JButton.class, new ValueRenderer());
            indxcvTable.setDefaultEditor(JTextField.class, new ValueEditor());
            indxcvTable.setDefaultEditor(JButton.class, new ValueEditor());
            indxcvTable.setRowHeight(new JButton("X").getPreferredSize().height);
            indxcvTable.setPreferredScrollableViewportSize(new Dimension(700, indxcvTable.getRowHeight() * 14));
            cvScroll.setColumnHeaderView(indxcvTable.getTableHeader());
            // don't want a horizontal scroll bar
            // Need to see the whole row at one time
            //                indxcvTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            cs.gridwidth = GridBagConstraints.REMAINDER;
            g.setConstraints(cvScroll, cs);
            c.add(cvScroll);
            cs.gridwidth = 1;
            // remember which indexed CVs to read/write
            for (int j = 0; j < _indexedCvModel.getRowCount(); j++) {
                String sz = "CV" + _indexedCvModel.getName(j);
                int in = _varModel.findVarIndex(sz);
                indexedCvList.add(in);
            }
            _cvTable = true;
            log.debug("end of building IndexedCvTable pane");
        } else if (name.equals("fnmapping")) {
            pickFnMapPanel(c, g, cs, modelElem);
        } else if (name.equals("dccaddress")) {
            JPanel l = addDccAddressPanel(e);
            if (l.getComponentCount() > 0) {
                cs.gridheight = GridBagConstraints.REMAINDER;
                g.setConstraints(l, cs);
                c.add(l);
                cs.gridheight = 1;
            }
        } else if (name.equals("column")) {
            // nested "column" elements ...
            cs.gridheight = GridBagConstraints.REMAINDER;
            JPanel l = newColumn(e, showStdName, modelElem);
            if (l.getComponentCount() > 0) {
                panelList.add(l);
                g.setConstraints(l, cs);
                c.add(l);
                cs.gridheight = 1;
            }
        } else if (name.equals("row")) {
            // nested "row" elements ...
            cs.gridwidth = GridBagConstraints.REMAINDER;
            JPanel l = newRow(e, showStdName, modelElem);
            if (l.getComponentCount() > 0) {
                panelList.add(l);
                g.setConstraints(l, cs);
                c.add(l);
                cs.gridwidth = 1;
            }
        } else if (name.equals("grid")) {
            // nested "grid" elements ...
            cs.gridwidth = GridBagConstraints.REMAINDER;
            JPanel l = newGrid(e, showStdName, modelElem);
            if (l.getComponentCount() > 0) {
                panelList.add(l);
                g.setConstraints(l, cs);
                c.add(l);
                cs.gridwidth = 1;
            }
        } else if (name.equals("group")) {
            // nested "group" elements ...
            JPanel l = newGroup(e, showStdName, modelElem);
            if (l.getComponentCount() > 0) {
                panelList.add(l);
                g.setConstraints(l, cs);
                c.add(l);
            }
        } else if (!name.equals("qualifier")) {
            // its a mistake
            log.error("No code to handle element of type " + e.getName() + " in newGridItem");
        }
    }
    globs.gridxCurrent = globs.gridConstraints.gridx;
    globs.gridyCurrent = globs.gridConstraints.gridy;
    // add glue to the bottom to allow resize
    if (c.getComponentCount() > 0) {
        c.add(Box.createVerticalGlue());
    }
    // handle qualification if any
    QualifierAdder qa = new QualifierAdder() {

        @Override
        protected Qualifier createQualifier(VariableValue var, String relation, String value) {
            return new JComponentQualifier(c, var, Integer.parseInt(value), relation);
        }

        @Override
        protected void addListener(java.beans.PropertyChangeListener qc) {
            c.addPropertyChangeListener(qc);
        }
    };
    qa.processModifierElements(element, _varModel);
    return c;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) ValueRenderer(jmri.jmrit.symbolicprog.ValueRenderer) JTextField(javax.swing.JTextField) Field(java.lang.reflect.Field) QualifierAdder(jmri.jmrit.symbolicprog.QualifierAdder) JScrollPane(javax.swing.JScrollPane) VariableValue(jmri.jmrit.symbolicprog.VariableValue) ValueEditor(jmri.jmrit.symbolicprog.ValueEditor) Dimension(java.awt.Dimension) JTable(javax.swing.JTable)

Example 59 with Attribute

use of ucar.nc2.Attribute in project JMRI by JMRI.

the class PaneProgPane method newVariable.

/**
     * Add the representation of a single variable. The variable is defined by a
     * JDOM variable Element from the XML file.
     *
     * @param var         element containing variable
     * @param col         column to insert label into
     * @param g           panel layout manager
     * @param cs          constraints on layout manager
     * @param showStdName show the name following the rules for the
     * <em>nameFmt</em> element
     */
public void newVariable(Element var, JComponent col, GridBagLayout g, GridBagConstraints cs, boolean showStdName) {
    // get the name
    String name = var.getAttribute("item").getValue();
    // if it doesn't exist, do nothing
    int i = _varModel.findVarIndex(name);
    if (i < 0) {
        log.trace("Variable \"{}\" not found, omitted", name);
        return;
    }
    //        Leave here for now. Need to track pre-existing corner-case issue
    //        log.info("Entry item="+name+";cs.gridx="+cs.gridx+";cs.gridy="+cs.gridy+";cs.anchor="+cs.anchor+";cs.ipadx="+cs.ipadx);
    // check label orientation
    Attribute attr;
    // this default is also set in the DTD
    String layout = "left";
    if ((attr = var.getAttribute("layout")) != null && attr.getValue() != null) {
        layout = attr.getValue();
    }
    // load label if specified, else use name
    String label = name;
    if (!showStdName) {
        // get name attribute from variable, as that's the mfg name
        label = _varModel.getLabel(i);
    }
    String temp = LocaleSelector.getAttribute(var, "label");
    if (temp != null) {
        label = temp;
    }
    // get representation; store into the list to be programmed
    JComponent rep = getRepresentation(name, var);
    varList.add(i);
    // create the paired label
    JLabel l = new WatchingLabel(label, rep);
    int spaceWidth = getFontMetrics(l.getFont()).stringWidth(" ");
    // assemble v from label, rep
    switch(layout) {
        case "left":
            cs.anchor = GridBagConstraints.EAST;
            cs.ipadx = spaceWidth;
            g.setConstraints(l, cs);
            col.add(l);
            cs.ipadx = 0;
            cs.gridx++;
            cs.anchor = GridBagConstraints.WEST;
            g.setConstraints(rep, cs);
            col.add(rep);
            break;
        //        log.info("Exit item="+name+";cs.gridx="+cs.gridx+";cs.gridy="+cs.gridy+";cs.anchor="+cs.anchor+";cs.ipadx="+cs.ipadx);
        case "right":
            cs.anchor = GridBagConstraints.EAST;
            g.setConstraints(rep, cs);
            col.add(rep);
            cs.gridx++;
            cs.anchor = GridBagConstraints.WEST;
            cs.ipadx = spaceWidth;
            g.setConstraints(l, cs);
            col.add(l);
            cs.ipadx = 0;
            break;
        case "below":
            // variable in center of upper line
            cs.anchor = GridBagConstraints.CENTER;
            g.setConstraints(rep, cs);
            col.add(rep);
            // label aligned like others
            cs.gridy++;
            cs.anchor = GridBagConstraints.WEST;
            cs.ipadx = spaceWidth;
            g.setConstraints(l, cs);
            col.add(l);
            cs.ipadx = 0;
            break;
        case "above":
            // label aligned like others
            cs.anchor = GridBagConstraints.WEST;
            cs.ipadx = spaceWidth;
            g.setConstraints(l, cs);
            col.add(l);
            cs.ipadx = 0;
            // variable in center of lower line
            cs.gridy++;
            cs.anchor = GridBagConstraints.CENTER;
            g.setConstraints(rep, cs);
            col.add(rep);
            break;
        default:
            log.error("layout internally inconsistent: " + layout);
    }
}
Also used : Attribute(org.jdom2.Attribute) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel)

Example 60 with Attribute

use of ucar.nc2.Attribute in project JMRI by JMRI.

the class WiThrottlePreferences method load.

@Override
public void load(Element child) {
    Attribute a;
    if ((a = child.getAttribute("isUseEStop")) != null) {
        setUseEStop(a.getValue().equalsIgnoreCase("true"));
        this.asLoadedUseEStop = this.isUseEStop();
    }
    if ((a = child.getAttribute("getEStopDelay")) != null) {
        try {
            setEStopDelay(Integer.valueOf(a.getValue()));
            this.asLoadedEStopDelay = this.getEStopDelay();
        } catch (NumberFormatException e) {
            log.debug(e.getLocalizedMessage(), e);
        }
    }
    if ((a = child.getAttribute("isUseMomF2")) != null) {
        setUseMomF2(a.getValue().equalsIgnoreCase("true"));
        this.asLoadedUseMomF2 = this.isUseMomF2();
    }
    if ((a = child.getAttribute("getPort")) != null) {
        try {
            setPort(a.getIntValue());
        } catch (DataConversionException ex) {
            log.error("Port {} is invalid.", a.getValue());
        }
        this.asLoadedPort = this.getPort();
    }
    if ((a = child.getAttribute("isAllowTrackPower")) != null) {
        setAllowTrackPower(a.getValue().equalsIgnoreCase("true"));
        this.asLoadedAllowTrackPower = this.isAllowTrackPower();
    }
    if ((a = child.getAttribute("isAllowTurnout")) != null) {
        setAllowTurnout(a.getValue().equalsIgnoreCase("true"));
        this.asLoadedAllowTurnout = this.isAllowTurnout();
    }
    if ((a = child.getAttribute("isAllowRoute")) != null) {
        setAllowRoute(a.getValue().equalsIgnoreCase("true"));
        this.asLoadedAllowRoute = this.isAllowRoute();
    }
    if ((a = child.getAttribute("isAllowConsist")) != null) {
        setAllowConsist(a.getValue().equalsIgnoreCase("true"));
        this.asLoadedAllowConsist = this.isAllowConsist();
    }
    if ((a = child.getAttribute("isUseWiFiConsist")) != null) {
        setUseWiFiConsist(a.getValue().equalsIgnoreCase("true"));
        this.asLoadedUseWiFiConsist = this.isUseWiFiConsist();
    }
}
Also used : Attribute(org.jdom2.Attribute) DataConversionException(org.jdom2.DataConversionException)

Aggregations

Attribute (org.jdom2.Attribute)106 Element (org.jdom2.Element)75 Editor (jmri.jmrit.display.Editor)15 DataConversionException (org.jdom2.DataConversionException)14 NamedIcon (jmri.jmrit.catalog.NamedIcon)13 IOException (java.io.IOException)12 ArrayList (java.util.ArrayList)12 LayoutEditor (jmri.jmrit.display.layoutEditor.LayoutEditor)9 List (java.util.List)7 Color (java.awt.Color)6 File (java.io.File)6 HashMap (java.util.HashMap)6 ConfigureManager (jmri.ConfigureManager)6 Asn1Integer (com.android.hotspot2.asn1.Asn1Integer)5 Asn1Object (com.android.hotspot2.asn1.Asn1Object)5 Asn1Oid (com.android.hotspot2.asn1.Asn1Oid)5 OidMappings (com.android.hotspot2.asn1.OidMappings)5 ASN1Encodable (com.android.org.bouncycastle.asn1.ASN1Encodable)5 ASN1EncodableVector (com.android.org.bouncycastle.asn1.ASN1EncodableVector)5 ASN1Set (com.android.org.bouncycastle.asn1.ASN1Set)5