Search in sources :

Example 56 with RosterEntry

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

the class PaneNewProgAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (log.isDebugEnabled()) {
        log.debug("New roster entry programmer requested");
    }
    // create the initial frame that steers
    final JmriJFrame f = new JmriJFrame(SymbolicProgBundle.getMessage("FrameNewEntrySetup"));
    f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
    // add the Roster menu
    JMenuBar menuBar = new JMenuBar();
    // menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
    JMenu j = new JMenu(SymbolicProgBundle.getMessage("MenuFile"));
    j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintDecoderDefinitions"), f, false));
    j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintPreviewDecoderDefinitions"), f, true));
    menuBar.add(j);
    menuBar.add(new jmri.jmrit.roster.swing.RosterMenu(SymbolicProgBundle.getMessage("MenuRoster"), jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
    f.setJMenuBar(menuBar);
    // new Loco on programming track
    JPanel pane1 = new LocoSelTreePane(null, null) {

        @Override
        protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
            String title = SymbolicProgBundle.getMessage("FrameNewEntryTitle");
            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) LocoSelTreePane(jmri.jmrit.symbolicprog.LocoSelTreePane) JmriJFrame(jmri.util.JmriJFrame) JmriJFrame(jmri.util.JmriJFrame) JFrame(javax.swing.JFrame) RosterEntry(jmri.jmrit.roster.RosterEntry) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 57 with RosterEntry

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

the class AutoSpeedAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (log.isInfoEnabled()) {
        log.debug("auto speed tool requested");
    }
    // create the initial frame that steers
    final JFrame f = new JFrame("Auto-speed Tool Setup");
    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("Roster", jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
    f.setJMenuBar(menuBar);
    // known loco on main track
    JPanel pane1 = new // no ident in ops mode yet
    KnownLocoSelPane(// no ident in ops mode yet
    false) {

        @Override
        protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
            String title = "Set speed info for " + re.getId() + " on main track";
            // find the ops-mode programmer
            int address = Integer.parseInt(re.getDccAddress());
            boolean longAddr = true;
            if (address < 100) {
                longAddr = false;
            }
            Programmer programmer = InstanceManager.getDefault(jmri.ProgrammerManager.class).getAddressedProgrammer(longAddr, address);
            // and created the frame
            JFrame p = new PaneOpsProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", programmer);
            p.pack();
            p.setVisible(true);
            f.setVisible(false);
            f.dispose();
        }
    };
    // load primary frame
    pane1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    f.getContentPane().add(pane1);
    f.pack();
    if (log.isInfoEnabled()) {
        log.debug("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) PaneOpsProgFrame(jmri.jmrit.symbolicprog.tabbedframe.PaneOpsProgFrame) JFrame(javax.swing.JFrame) Programmer(jmri.Programmer) RosterEntry(jmri.jmrit.roster.RosterEntry) JMenuBar(javax.swing.JMenuBar)

Example 58 with RosterEntry

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

the class FunctionPanel method setFnButtons.

// Update buttons value from slot + load buttons definition from roster if any
private void setFnButtons() {
    if (mThrottle != null) {
        if (addressPanel == null) {
            return;
        }
        RosterEntry rosterEntry = addressPanel.getRosterEntry();
        if ((rosterEntry != null) && (log.isDebugEnabled())) {
            log.debug("RosterEntry found: " + rosterEntry.getId());
        }
        // the number of function buttons defined for this entry
        int maxi = 0;
        for (int i = 0; i < FunctionPanel.NUM_FUNCTION_BUTTONS; i++) {
            try {
                // full reset of function
                functionButton[i].setIdentity(i);
                // buttons in this case
                java.lang.reflect.Method getter = mThrottle.getClass().getMethod("getF" + i, (Class[]) null);
                Boolean state = (Boolean) getter.invoke(mThrottle, (Object[]) null);
                // reset button state
                functionButton[i].setState(state.booleanValue());
            } catch (java.lang.NoSuchMethodException ex1) {
                log.warn("Exception in notifyThrottleFound: " + ex1);
            } catch (java.lang.IllegalAccessException ex2) {
                log.warn("Exception in notifyThrottleFound: " + ex2);
            } catch (java.lang.reflect.InvocationTargetException ex3) {
                log.warn("Exception in notifyThrottleFound: " + ex3);
            }
            if (rosterEntry != null) {
                // from here, update button text with roster data
                String text = rosterEntry.getFunctionLabel(i);
                if (text != null) {
                    functionButton[i].setDisplay(true);
                    functionButton[i].setButtonLabel(text);
                    if ((jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesPreferences().isUsingExThrottle()) && (jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesPreferences().isUsingFunctionIcon())) {
                        functionButton[i].setIconPath(rosterEntry.getFunctionImage(i));
                        functionButton[i].setSelectedIconPath(rosterEntry.getFunctionSelectedImage(i));
                    } else {
                        functionButton[i].setIconPath(null);
                        functionButton[i].setSelectedIconPath(null);
                    }
                    functionButton[i].setIsLockable(rosterEntry.getFunctionLockable(i));
                    functionButton[i].updateLnF();
                    if (maxi < NUM_FUNC_BUTTONS_INIT) {
                        functionButton[i].setVisible(true);
                    }
                    // bump number of buttons shown
                    maxi++;
                } else if (jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesPreferences().isUsingExThrottle() && jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesPreferences().isHidingUndefinedFuncButt()) {
                    functionButton[i].setDisplay(false);
                    functionButton[i].setVisible(false);
                }
            }
        }
        // hide alt buttons if not required
        if ((rosterEntry != null) && (maxi < NUM_FUNC_BUTTONS_INIT && jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesPreferences().isUsingExThrottle() && jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesPreferences().isHidingUndefinedFuncButt())) {
            alt1Button.setVisible(false);
            alt2Button.setVisible(false);
        }
    }
}
Also used : RosterEntry(jmri.jmrit.roster.RosterEntry)

Example 59 with RosterEntry

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

the class AddressPanel method setRosterSelectedIndex.

/**
     * Sets the selected index of the roster combo box. Implemented to support
     * xboxThrottle.py This method temporarily disables roster box actions so it
     * can change the selected index without triggering a cascade of events.
     *
     * @param index the index to select in the combo box
     */
public void setRosterSelectedIndex(int index) {
    if (getRosterEntrySelector().isEnabled() && index >= 0 && index < getRosterEntrySelector().getRosterEntryComboBox().getItemCount()) {
        getRosterEntrySelector().getRosterEntryComboBox().setSelectedIndex(index);
    }
    if ((backgroundPanel != null) && (!(rosterBox.getSelectedRosterEntries().length != 0))) {
        backgroundPanel.setImagePath(null);
        String rosterEntryTitle = getRosterEntrySelector().getSelectedRosterEntries()[0].titleString();
        RosterEntry re = Roster.getDefault().entryFromTitle(rosterEntryTitle);
        if (re != null) {
            backgroundPanel.setImagePath(re.getImagePath());
        }
    }
}
Also used : RosterEntry(jmri.jmrit.roster.RosterEntry) NceConsistRosterEntry(jmri.jmrix.nce.consist.NceConsistRosterEntry)

Example 60 with RosterEntry

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

the class AddRosterEntryToEcos method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    roster = Roster.getDefault();
    rosterEntryUpdate();
    int retval = JOptionPane.showOptionDialog(null, "Select the roster entry to add to the Ecos\nThe Drop down list only shows locos that have not already been added. ", "Add to Ecos", 0, JOptionPane.INFORMATION_MESSAGE, null, new Object[] { "Cancel", "OK", rosterEntry }, null);
    log.debug("Dialog value " + retval + " selected, " + rosterEntry.getSelectedIndex() + ":" + rosterEntry.getSelectedItem());
    if (retval != 1) {
        return;
    }
    String selEntry = (String) rosterEntry.getSelectedItem();
    RosterEntry re = roster.entryFromTitle(selEntry);
    //System.out.println("Add " + re.getId() + " to Ecos");
    RosterToEcos rosterToEcos = new RosterToEcos();
    rosterToEcos.createEcosLoco(re, adaptermemo);
}
Also used : 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