Search in sources :

Example 16 with RosterEntry

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

the class CombinedLocoSelListPane method setDecoderSelectionFromLoco.

/**
     * Set the decoder selection to a specific decoder from a selected Loco
     */
@Override
void setDecoderSelectionFromLoco(String loco) {
    // if there's a valid loco entry...
    RosterEntry locoEntry = Roster.getDefault().entryFromTitle(loco);
    if (locoEntry == null) {
        return;
    }
    // get the decoder type, it has to be there (assumption!),
    String modelString = locoEntry.getDecoderModel();
    // find the decoder mfg
    String mfgString = DecoderIndexFile.instance().fileFromTitle(modelString).getMfg();
    // then select it
    updateMfgListWithoutTrigger(mfgString);
    // decoder has to be there (assumption!)
    // so load it into the list directly
    String[] tempArray = new String[1];
    tempArray[0] = modelString;
    mDecoderList.setListData(tempArray);
    // select the entry you just put in, but don't trigger anything!
    mDecoderList.removeListSelectionListener(mDecoderListener);
    mDecoderList.setSelectedIndex(0);
    mDecoderList.addListSelectionListener(mDecoderListener);
}
Also used : RosterEntry(jmri.jmrit.roster.RosterEntry)

Example 17 with RosterEntry

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

the class KnownLocoSelPane method selectLoco.

protected void selectLoco(int dccAddress) {
    // locate that loco
    List<RosterEntry> l = Roster.getDefault().matchingList(null, null, Integer.toString(dccAddress), null, null, null, null);
    if (log.isDebugEnabled()) {
        log.debug("selectLoco found " + l.size() + " matches");
    }
    if (l.size() > 0) {
        RosterEntry r = l.get(0);
        String id = r.getId();
        if (log.isDebugEnabled()) {
            log.debug("Loco id is " + id);
        }
        String group = locoBox.getSelectedRosterGroup();
        if (group != null && !group.equals(Roster.ALLENTRIES)) {
            List<RosterEntry> entries = Roster.getDefault().getEntriesWithAttributeKeyValue(Roster.getRosterGroupProperty(group), "yes");
            if (entries.contains(r)) {
                locoBox.setSelectedRosterEntry(r);
            } else {
                locoBox.setSelectedRosterEntryAndGroup(r, Roster.ALLENTRIES);
            }
        } else {
            locoBox.setSelectedRosterEntry(r);
        }
    } else {
        log.warn("Read address " + dccAddress + ", but no such loco in roster");
    }
}
Also used : RosterEntry(jmri.jmrit.roster.RosterEntry)

Example 18 with RosterEntry

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

the class PaneEditAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (log.isDebugEnabled()) {
        log.debug("Pane programmer requested");
    }
    // create the initial frame that steers
    final JmriJFrame f = new JmriJFrame(SymbolicProgBundle.getMessage("FrameEditEntrySetup"));
    f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
    // add the Roster menu
    JMenuBar menuBar = new JMenuBar();
    // menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
    menuBar.add(new jmri.jmrit.roster.swing.RosterMenu(SymbolicProgBundle.getMessage("MenuRoster"), jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
    f.setJMenuBar(menuBar);
    // known entry, no programmer
    JPanel pane1 = new // not programming
    KnownLocoSelPane(// not programming
    false) {

        @Override
        protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
            String title = SymbolicProgBundle.getMessage("FrameEditEntryTitle");
            JFrame p = new PaneProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", null, false) {

                @Override
                protected JPanel getModePane() {
                    return null;
                }
            };
            p.pack();
            p.setVisible(true);
        }
    };
    // load primary frame
    pane1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    f.getContentPane().add(pane1);
    f.pack();
    if (log.isDebugEnabled()) {
        log.debug("Tab-Programmer setup created");
    }
    f.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) DecoderFile(jmri.jmrit.decoderdefn.DecoderFile) BoxLayout(javax.swing.BoxLayout) KnownLocoSelPane(jmri.jmrit.symbolicprog.KnownLocoSelPane) JmriJFrame(jmri.util.JmriJFrame) JmriJFrame(jmri.util.JmriJFrame) JFrame(javax.swing.JFrame) RosterEntry(jmri.jmrit.roster.RosterEntry) JMenuBar(javax.swing.JMenuBar)

Example 19 with RosterEntry

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

the class VSDConfigDialog method rosterSaveButtonAction.

/**
     * rosterSaveButtonAction()
     *
     * ActionEventListener method for rosterSaveButton Writes VSDecoder info to
     * the RosterEntry.
     */
private void rosterSaveButtonAction(ActionEvent e) {
    log.debug("rosterSaveButton pressed");
    if (rosterSelector.getSelectedRosterEntries().length != 0) {
        RosterEntry r = rosterSelector.getSelectedRosterEntries()[0];
        String profile = profileComboBox.getSelectedItem().toString();
        String path = VSDecoderManager.instance().getProfilePath(profile);
        if ((path == null) || (profile == null)) {
            log.debug("Path and/or Profile not selected.  Ignore Save button press.");
            return;
        } else {
            r.setOpen(true);
            r.putAttribute("VSDecoder_Path", path);
            r.putAttribute("VSDecoder_Profile", profile);
            int value = JOptionPane.showConfirmDialog(null, MessageFormat.format(Bundle.getMessage("UpdateRoster"), new Object[] { r.titleString() }), Bundle.getMessage("SaveRoster?"), JOptionPane.YES_NO_OPTION);
            if (value == JOptionPane.YES_OPTION) {
                storeFile(r);
            }
            r.setOpen(false);
        }
    // Need to write RosterEntry to file.
    }
}
Also used : RosterEntry(jmri.jmrit.roster.RosterEntry)

Example 20 with RosterEntry

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

the class VSDConfigDialog method updateProfileList.

/**
     * Update the profile combo box
     */
private void updateProfileList(ArrayList<String> s) {
    if (s == null) {
        return;
    }
    // This is a bit tedious...
    // Pull all of the existing names from the Profile ComboBox
    ArrayList<String> ce_list = new ArrayList<>();
    for (int i = 0; i < profileComboBox.getItemCount(); i++) {
        ce_list.add(profileComboBox.getItemAt(i).toString());
    }
    // Cycle through the list provided as "s" and add only
    // those profiles that aren't already there.
    Iterator<String> itr = s.iterator();
    while (itr.hasNext()) {
        String st = itr.next();
        if (!ce_list.contains(st)) {
            log.debug("added item " + st);
            profileComboBox.addItem(st);
        }
    }
    // Roster Save button.
    if (profileComboBox.getItemCount() > 0) {
        profileComboBox.setEnabled(true);
        // Enable the roster save button if roster items are available.
        if (rosterSelector.getSelectedRosterEntries().length > 0) {
            RosterEntry r = rosterSelector.getSelectedRosterEntries()[0];
            String profile = r.getAttribute("VSDecoder_Profile");
            log.debug("Trying to set the ProfileComboBox to this Profile: " + profile);
            if (profile != null) {
                profileComboBox.setSelectedItem(profile);
            }
            rosterSaveButton.setEnabled(true);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) 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