Search in sources :

Example 61 with RosterEntry

use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.

the class EcosLocoToRoster method ecosLocoToRoster.

//Same Name as the constructor need to sort it out!
public void ecosLocoToRoster(String ecosObject) {
    frame = new JFrame();
    _ecosObject = ecosObject;
    _ecosObjectInt = Integer.parseInt(_ecosObject);
    ecosManager = adaptermemo.getLocoAddressManager();
    ecosLoco = ecosManager.getByEcosObject(ecosObject);
    String rosterId = ecosLoco.getEcosDescription();
    if (checkDuplicate(rosterId)) {
        int count = 0;
        String oldrosterId = rosterId;
        while (checkDuplicate(rosterId)) {
            rosterId = oldrosterId + "_" + count;
            count++;
        }
    }
    re = new RosterEntry();
    re.setId(rosterId);
    List<DecoderFile> decoder = decoderind.matchingDecoderList(null, null, ecosLoco.getCVAsString(8), ecosLoco.getCVAsString(7), null, null);
    if (decoder.size() == 1) {
        pDecoderFile = decoder.get(0);
        SelectedDecoder(pDecoderFile);
    } else {
        class WindowMaker implements Runnable {

            WindowMaker() {
            }

            @Override
            public void run() {
                comboPanel();
            }
        }
        WindowMaker t = new WindowMaker();
        javax.swing.SwingUtilities.invokeLater(t);
    }
}
Also used : DecoderFile(jmri.jmrit.decoderdefn.DecoderFile) JFrame(javax.swing.JFrame) RosterEntry(jmri.jmrit.roster.RosterEntry)

Example 62 with RosterEntry

use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.

the class NceConsistEditPanel method rosterBoxSelect.

// load a loco from roster
private void rosterBoxSelect(JComboBox<Object> locoRosterBox, JTextField locoTextField, JButton adrButton) {
    RosterEntry entry = null;
    Object o = locoRosterBox.getSelectedItem();
    if (o.getClass().equals(RosterEntry.class)) {
        entry = (RosterEntry) o;
    }
    if (entry != null) {
        DccLocoAddress a = entry.getDccLocoAddress();
        locoTextField.setText("" + a.getNumber());
        if (a.isLongAddress()) {
            adrButton.setText(rb.getString("KeyLONG"));
        } else {
            adrButton.setText(rb.getString("KeySHORT"));
        }
        // if lead loco get road number and name
        if (locoRosterBox == locoRosterBox1) {
            textConRoadName.setText(entry.getRoadName());
            textConRoadNumber.setText(entry.getRoadNumber());
            textConModel.setText(entry.getModel());
        }
    }
}
Also used : RosterEntry(jmri.jmrit.roster.RosterEntry) DccLocoAddress(jmri.DccLocoAddress)

Example 63 with RosterEntry

use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.

the class AbstractMemoryManagerConfigXML method loadValue.

void loadValue(Element memory, Memory m) {
    String value = memory.getAttribute("value").getValue();
    if (memory.getAttribute("valueClass") != null) {
        String adapter = memory.getAttribute("valueClass").getValue();
        if (adapter.equals("jmri.jmrit.roster.RosterEntry")) {
            RosterEntry re = jmri.jmrit.roster.Roster.getDefault().getEntryForId(value);
            m.setValue(re);
            return;
        }
    }
    m.setValue(value);
}
Also used : RosterEntry(jmri.jmrit.roster.RosterEntry)

Example 64 with RosterEntry

use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.

the class AbstractMemoryManagerConfigXML method store.

/**
     * Default implementation for storing the contents of a MemoryManager
     *
     * @param o Object to store, of type MemoryManager
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    Element memories = new Element("memories");
    setStoreElementClass(memories);
    MemoryManager tm = (MemoryManager) o;
    if (tm != null) {
        java.util.Iterator<String> iter = tm.getSystemNameList().iterator();
        // don't return an element if there are not memories to include
        if (!iter.hasNext()) {
            return null;
        }
        // store the memories
        while (iter.hasNext()) {
            String sname = iter.next();
            if (sname == null) {
                log.error("System name null during store");
                break;
            }
            log.debug("system name is " + sname);
            Memory m = tm.getBySystemName(sname);
            Element elem = new Element("memory");
            elem.addContent(new Element("systemName").addContent(sname));
            // store common part
            storeCommon(m, elem);
            // store value if non-null; null values omitted
            Object obj = m.getValue();
            if (obj != null) {
                if (obj instanceof jmri.jmrit.roster.RosterEntry) {
                    String valueClass = obj.getClass().getName();
                    String value = ((RosterEntry) obj).getId();
                    elem.setAttribute("value", value);
                    elem.setAttribute("valueClass", valueClass);
                } else {
                    String value = obj.toString();
                    elem.setAttribute("value", value);
                }
            }
            log.debug("store Memory " + sname);
            memories.addContent(elem);
        }
    }
    return memories;
}
Also used : Memory(jmri.Memory) Element(org.jdom2.Element) RosterEntry(jmri.jmrit.roster.RosterEntry) MemoryManager(jmri.MemoryManager)

Example 65 with RosterEntry

use of jmri.jmrit.roster.RosterEntry in project JMRI by JMRI.

the class LocoIconXml method store.

/**
     * Default implementation for storing the contents of a LocoIcon
     *
     * @param o Object to store, of type LocoIcon
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    LocoIcon p = (LocoIcon) o;
    if (!p.isActive()) {
        // if flagged as inactive, don't store
        return null;
    }
    Element element = new Element("locoicon");
    storeCommonAttributes(p, element);
    // include contents
    if (p.getUnRotatedText() != null) {
        element.setAttribute("text", p.getUnRotatedText());
    }
    storeTextInfo(p, element);
    element.setAttribute("icon", "yes");
    element.setAttribute("dockX", "" + p.getDockX());
    element.setAttribute("dockY", "" + p.getDockY());
    element.addContent(storeIcon("icon", (NamedIcon) p.getIcon()));
    RosterEntry entry = p.getRosterEntry();
    if (entry != null) {
        element.setAttribute("rosterentry", entry.getId());
    }
    element.setAttribute("class", "jmri.jmrit.display.configurexml.LocoIconXml");
    return element;
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) LocoIcon(jmri.jmrit.display.LocoIcon) Element(org.jdom2.Element) RosterEntry(jmri.jmrit.roster.RosterEntry)

Aggregations

RosterEntry (jmri.jmrit.roster.RosterEntry)77 DecoderFile (jmri.jmrit.decoderdefn.DecoderFile)12 JPanel (javax.swing.JPanel)11 Element (org.jdom2.Element)11 JFrame (javax.swing.JFrame)9 BoxLayout (javax.swing.BoxLayout)8 JLabel (javax.swing.JLabel)8 Test (org.junit.Test)7 ActionEvent (java.awt.event.ActionEvent)6 ActionListener (java.awt.event.ActionListener)6 JMenuBar (javax.swing.JMenuBar)6 CvTableModel (jmri.jmrit.symbolicprog.CvTableModel)6 IndexedCvTableModel (jmri.jmrit.symbolicprog.IndexedCvTableModel)6 VariableTableModel (jmri.jmrit.symbolicprog.VariableTableModel)6 ArrayList (java.util.ArrayList)5 JmriJFrame (jmri.util.JmriJFrame)5 File (java.io.File)4 JButton (javax.swing.JButton)3 JMenu (javax.swing.JMenu)3 NamedIcon (jmri.jmrit.catalog.NamedIcon)3