Search in sources :

Example 1 with SingleTurnoutSignalHead

use of jmri.implementation.SingleTurnoutSignalHead in project JMRI by JMRI.

the class SignalHeadTableAction method updatePressed.

@SuppressWarnings("fallthrough")
@SuppressFBWarnings(value = "SF_SWITCH_FALLTHROUGH")
void updatePressed(ActionEvent e) {
    String nam = eUserName.getText();
    // check if user name changed
    String uname = curS.getUserName();
    // TODO: not sure this if statement is right. I think (uname != null && !uname.equals(nam))
    if (!((uname != null) && (uname.equals(nam)))) {
        if (checkUserName(nam)) {
            curS.setUserName(nam);
        } else {
            return;
        }
    }
    // update according to class of signal head
    if (className.equals("jmri.implementation.QuadOutputSignalHead")) {
        Turnout t1 = updateTurnoutFromPanel(eto1, "SignalHead:" + eSysNameLabel.getText() + ":Green", ((QuadOutputSignalHead) curS).getGreen().getBean(), ev1Border.getTitle());
        if (t1 == null) {
            return;
        } else {
            ((QuadOutputSignalHead) curS).setGreen(nbhm.getNamedBeanHandle(eto1.getDisplayName(), t1));
        }
        Turnout t2 = updateTurnoutFromPanel(eto2, "SignalHead:" + eSysNameLabel.getText() + ":Yellow", ((QuadOutputSignalHead) curS).getYellow().getBean(), ev2Border.getTitle());
        if (t2 == null) {
            return;
        } else {
            ((QuadOutputSignalHead) curS).setYellow(nbhm.getNamedBeanHandle(eto2.getDisplayName(), t2));
        }
        Turnout t3 = updateTurnoutFromPanel(eto3, "SignalHead:" + eSysNameLabel.getText() + ":Red", ((QuadOutputSignalHead) curS).getRed().getBean(), ev3Border.getTitle());
        if (t3 == null) {
            return;
        } else {
            ((QuadOutputSignalHead) curS).setRed(nbhm.getNamedBeanHandle(eto3.getDisplayName(), t3));
        }
        Turnout t4 = updateTurnoutFromPanel(eto4, "SignalHead:" + eSysNameLabel.getText() + ":Lunar", ((QuadOutputSignalHead) curS).getLunar().getBean(), ev4Border.getTitle());
        if (t4 == null) {
            return;
        } else {
            ((QuadOutputSignalHead) curS).setLunar(nbhm.getNamedBeanHandle(eto4.getDisplayName(), t4));
        }
    } else if (className.equals("jmri.implementation.TripleTurnoutSignalHead")) {
        Turnout t1 = updateTurnoutFromPanel(eto1, "SignalHead:" + eSysNameLabel.getText() + ":Green", ((TripleTurnoutSignalHead) curS).getGreen().getBean(), ev1Border.getTitle());
        if (t1 == null) {
            return;
        } else {
            ((TripleTurnoutSignalHead) curS).setGreen(nbhm.getNamedBeanHandle(eto1.getDisplayName(), t1));
        }
        Turnout t2 = updateTurnoutFromPanel(eto2, "SignalHead:" + eSysNameLabel.getText() + ":Yellow", ((TripleTurnoutSignalHead) curS).getYellow().getBean(), ev2Border.getTitle());
        if (t2 == null) {
            return;
        } else {
            ((TripleTurnoutSignalHead) curS).setYellow(nbhm.getNamedBeanHandle(eto2.getDisplayName(), t2));
        }
        Turnout t3 = updateTurnoutFromPanel(eto3, "SignalHead:" + eSysNameLabel.getText() + ":Red", ((TripleTurnoutSignalHead) curS).getRed().getBean(), ev3Border.getTitle());
        if (t3 == null) {
            return;
        } else {
            ((TripleTurnoutSignalHead) curS).setRed(nbhm.getNamedBeanHandle(eto3.getDisplayName(), t3));
        }
    } else if (className.equals("jmri.implementation.TripleOutputSignalHead")) {
        Turnout t1 = updateTurnoutFromPanel(eto1, "SignalHead:" + eSysNameLabel.getText() + ":Green", ((TripleOutputSignalHead) curS).getGreen().getBean(), ev1Border.getTitle());
        if (t1 == null) {
            return;
        } else {
            ((TripleOutputSignalHead) curS).setGreen(nbhm.getNamedBeanHandle(eto1.getDisplayName(), t1));
        }
        Turnout t2 = updateTurnoutFromPanel(eto2, "SignalHead:" + eSysNameLabel.getText() + ":Blue", ((TripleOutputSignalHead) curS).getBlue().getBean(), ev2Border.getTitle());
        if (t2 == null) {
            return;
        } else {
            ((TripleOutputSignalHead) curS).setBlue(nbhm.getNamedBeanHandle(eto2.getDisplayName(), t2));
        }
        Turnout t3 = updateTurnoutFromPanel(eto3, "SignalHead:" + eSysNameLabel.getText() + ":Red", ((TripleOutputSignalHead) curS).getRed().getBean(), ev3Border.getTitle());
        if (t3 == null) {
            return;
        } else {
            ((TripleOutputSignalHead) curS).setRed(nbhm.getNamedBeanHandle(eto3.getDisplayName(), t3));
        }
    } else if (className.equals("jmri.implementation.DoubleTurnoutSignalHead")) {
        Turnout t1 = updateTurnoutFromPanel(eto1, "SignalHead:" + eSysNameLabel.getText() + ":Green", ((DoubleTurnoutSignalHead) curS).getGreen().getBean(), ev1Border.getTitle());
        Turnout t2 = updateTurnoutFromPanel(eto2, "SignalHead:" + eSysNameLabel.getText() + ":Red", ((DoubleTurnoutSignalHead) curS).getRed().getBean(), ev2Border.getTitle());
        if (t1 == null) {
            return;
        } else {
            ((DoubleTurnoutSignalHead) curS).setGreen(nbhm.getNamedBeanHandle(eto1.getDisplayName(), t1));
        }
        if (t2 == null) {
            return;
        } else {
            ((DoubleTurnoutSignalHead) curS).setRed(nbhm.getNamedBeanHandle(eto2.getDisplayName(), t2));
        }
    } else if (className.equals("jmri.implementation.SingleTurnoutSignalHead")) {
        Turnout t1 = updateTurnoutFromPanel(eto1, "SignalHead:" + eSysNameLabel.getText() + ":" + (String) es2aBox.getSelectedItem() + ":" + (String) es3aBox.getSelectedItem(), ((SingleTurnoutSignalHead) curS).getOutput().getBean(), ev1Border.getTitle());
        if (t1 == null) {
            noTurnoutMessage(ev1Border.getTitle(), eto1.getDisplayName());
            return;
        }
        ((SingleTurnoutSignalHead) curS).setOutput(nbhm.getNamedBeanHandle(eto1.getDisplayName(), t1));
        ((SingleTurnoutSignalHead) curS).setOnAppearance(signalStateFromBox(es2aBox));
        ((SingleTurnoutSignalHead) curS).setOffAppearance(signalStateFromBox(es3aBox));
    } else if (className.equals("jmri.implementation.LsDecSignalHead")) {
        Turnout t1 = updateTurnoutFromPanel(eto1, "SignalHead:" + eSysNameLabel.getText() + ":Green", ((jmri.implementation.LsDecSignalHead) curS).getGreen().getBean(), ev1Border.getTitle());
        if (t1 == null) {
            return;
        } else {
            ((jmri.implementation.LsDecSignalHead) curS).setGreen(nbhm.getNamedBeanHandle(eto1.getDisplayName(), t1));
            ((jmri.implementation.LsDecSignalHead) curS).setGreenState(turnoutStateFromBox(es1Box));
        }
        Turnout t2 = updateTurnoutFromPanel(eto2, "SignalHead:" + eSysNameLabel.getText() + ":Yellow", ((jmri.implementation.LsDecSignalHead) curS).getYellow().getBean(), ev2Border.getTitle());
        if (t2 == null) {
            return;
        } else {
            ((jmri.implementation.LsDecSignalHead) curS).setYellow(nbhm.getNamedBeanHandle(eto2.getDisplayName(), t2));
            ((jmri.implementation.LsDecSignalHead) curS).setYellowState(turnoutStateFromBox(es2Box));
        }
        Turnout t3 = updateTurnoutFromPanel(eto3, "SignalHead:" + eSysNameLabel.getText() + ":Red", ((jmri.implementation.LsDecSignalHead) curS).getRed().getBean(), ev3Border.getTitle());
        if (t3 == null) {
            return;
        } else {
            ((jmri.implementation.LsDecSignalHead) curS).setRed(nbhm.getNamedBeanHandle(eto3.getDisplayName(), t3));
            ((jmri.implementation.LsDecSignalHead) curS).setRedState(turnoutStateFromBox(es3Box));
        }
        Turnout t4 = updateTurnoutFromPanel(eto4, "SignalHead:" + eSysNameLabel.getText() + ":FlashGreen", ((jmri.implementation.LsDecSignalHead) curS).getFlashGreen().getBean(), ev4Border.getTitle());
        if (t4 == null) {
            return;
        } else {
            ((jmri.implementation.LsDecSignalHead) curS).setFlashGreen(nbhm.getNamedBeanHandle(eto4.getDisplayName(), t4));
            ((jmri.implementation.LsDecSignalHead) curS).setFlashGreenState(turnoutStateFromBox(es4Box));
        }
        Turnout t5 = updateTurnoutFromPanel(eto5, "SignalHead:" + eSysNameLabel.getText() + ":FlashYellow", ((jmri.implementation.LsDecSignalHead) curS).getFlashYellow().getBean(), ev5Border.getTitle());
        if (t5 == null) {
            return;
        } else {
            ((jmri.implementation.LsDecSignalHead) curS).setFlashYellow(nbhm.getNamedBeanHandle(eto5.getDisplayName(), t5));
            ((jmri.implementation.LsDecSignalHead) curS).setFlashYellowState(turnoutStateFromBox(es5Box));
        }
        Turnout t6 = updateTurnoutFromPanel(eto6, "SignalHead:" + eSysNameLabel.getText() + ":FlashRed", ((jmri.implementation.LsDecSignalHead) curS).getFlashRed().getBean(), ev6Border.getTitle());
        if (t6 == null) {
            return;
        } else {
            ((jmri.implementation.LsDecSignalHead) curS).setFlashRed(nbhm.getNamedBeanHandle(eto6.getDisplayName(), t6));
            ((jmri.implementation.LsDecSignalHead) curS).setFlashRedState(turnoutStateFromBox(es6Box));
        }
        Turnout t7 = updateTurnoutFromPanel(eto7, "SignalHead:" + eSysNameLabel.getText() + ":Dark", ((jmri.implementation.LsDecSignalHead) curS).getDark().getBean(), ev7Border.getTitle());
        if (t7 == null) {
            return;
        } else {
            ((jmri.implementation.LsDecSignalHead) curS).setDark(nbhm.getNamedBeanHandle(eto7.getDisplayName(), t7));
            ((jmri.implementation.LsDecSignalHead) curS).setDarkState(turnoutStateFromBox(es7Box));
        }
    } else if (className.equals("jmri.implementation.SE8cSignalHead")) {
        handleSE8cUpdatePressed();
    } else if (className.equals("jmri.jmrix.grapevine.SerialSignalHead")) {
    /*String nam = eUserName.getText();
             // check if user name changed
             if (!((curS.getUserName()!=null) && (curS.getUserName().equals(nam)))) {
             if(checkUserName(nam))
             curS.setUserName(nam);
             }*/
    } else if (className.equals("jmri.jmrix.acela.AcelaSignalHead")) {
        /*String nam = eUserName.getText();
             // check if user name changed
             if (!((curS.getUserName()!=null) && (curS.getUserName().equals(nam)))) {
             if(checkUserName(nam))
             curS.setUserName(nam);

             }*/
        AcelaNode tNode = AcelaAddress.getNodeFromSystemName(curS.getSystemName(), jmri.InstanceManager.getDefault(jmri.jmrix.acela.AcelaSystemConnectionMemo.class));
        if (tNode == null) {
            // node does not exist, ignore call
            log.error("Can't find new Acela Signal with name '{}'", curS.getSystemName());
            return;
        }
        int headnumber = Integer.parseInt(curS.getSystemName().substring(2, curS.getSystemName().length()));
        tNode.setOutputSignalHeadTypeString(headnumber, estBox.getSelectedItem().toString());
    //          setSignalheadTypeInBox(estBox, tNode.getOutputSignalHeadType(headnumber), signalheadTypeValues);
    //          ((jmri.AcelaSignalHead)curS).setDarkState(signalheadTypeFromBox(estBox));
    } else if (className.equals("jmri.implementation.MergSD2SignalHead")) {
        switch(ukSignalAspectsFromBox(emsaBox)) {
            case 4:
                Turnout t3 = updateTurnoutFromPanel(eto5, (Bundle.getMessage("OutputComment", Bundle.getMessage("BeanNameSignalHead"), eSysNameLabel.getText(), Bundle.getMessage("InputNum", "3"))), ((jmri.implementation.MergSD2SignalHead) curS).getInput3().getBean(), ev5Border.getTitle());
                if (t3 == null) {
                    return;
                } else {
                    ((jmri.implementation.MergSD2SignalHead) curS).setInput3(nbhm.getNamedBeanHandle(eto5.getDisplayName(), t3));
                }
            // fall through
            case 3:
                Turnout t2 = updateTurnoutFromPanel(eto4, (Bundle.getMessage("OutputComment", Bundle.getMessage("BeanNameSignalHead"), eSysNameLabel.getText(), Bundle.getMessage("InputNum", "2"))), ((jmri.implementation.MergSD2SignalHead) curS).getInput2().getBean(), ev4Border.getTitle());
                if (t2 == null) {
                    return;
                } else {
                    ((jmri.implementation.MergSD2SignalHead) curS).setInput2(nbhm.getNamedBeanHandle(eto4.getDisplayName(), t2));
                }
            // fall through
            case 2:
                Turnout t1 = updateTurnoutFromPanel(eto3, (Bundle.getMessage("OutputComment", Bundle.getMessage("BeanNameSignalHead"), eSysNameLabel.getText(), Bundle.getMessage("InputNum", "1"))), ((jmri.implementation.MergSD2SignalHead) curS).getInput1().getBean(), ev3Border.getTitle());
                if (t1 == null) {
                    return;
                } else {
                    ((jmri.implementation.MergSD2SignalHead) curS).setInput1(nbhm.getNamedBeanHandle(eto3.getDisplayName(), t1));
                }
                ((jmri.implementation.MergSD2SignalHead) curS).setAspects(ukSignalAspectsFromBox(emsaBox));
                if (ukSignalTypeFromBox(emstBox).equals("Distant")) {
                    ((jmri.implementation.MergSD2SignalHead) curS).setHome(false);
                } else {
                    ((jmri.implementation.MergSD2SignalHead) curS).setHome(true);
                }
            default:
                break;
        }
    //Need to add the code here for update!
    } else if (className.equals("jmri.implementation.DccSignalHead")) {
        for (int i = 0; i < dccAspectEdt.length; i++) {
            int number = (Integer) dccAspectEdt[i].getValue();
            try {
                ((DccSignalHead) curS).setOutputForAppearance(((DccSignalHead) curS).getValidStates()[i], number);
            } catch (Exception ex) {
                //in theory JSpinner should already have caught a number conversion error.
                log.error(ex.toString());
            }
        }
        ((DccSignalHead) curS).useAddressOffSet(dccOffSetAddressEdt.isSelected());
    } else {
        log.error("Internal error - cannot update signal of type " + className);
    }
    // successful
    editFrame.setVisible(false);
    editingHead = false;
}
Also used : AcelaNode(jmri.jmrix.acela.AcelaNode) TripleOutputSignalHead(jmri.implementation.TripleOutputSignalHead) SingleTurnoutSignalHead(jmri.implementation.SingleTurnoutSignalHead) QuadOutputSignalHead(jmri.implementation.QuadOutputSignalHead) Turnout(jmri.Turnout) DccSignalHead(jmri.implementation.DccSignalHead) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 2 with SingleTurnoutSignalHead

use of jmri.implementation.SingleTurnoutSignalHead in project JMRI by JMRI.

the class SignalHeadTableAction method makeEditSignalWindow.

void makeEditSignalWindow() {
    // keep border and label names the same as in typeChanged() above
    String eSName = _curSignal.getSystemName();
    if (editingHead) {
        if (eSName.equals(editSysName)) {
            editFrame.setVisible(true);
        } else {
            log.error("Attempt to edit two signal heads at the same time-" + editSysName + "-and-" + eSName + "-");
            String msg = Bundle.getMessage("WarningEdit", new Object[] { editSysName, eSName });
            JOptionPane.showMessageDialog(editFrame, msg, Bundle.getMessage("WarningTitle"), JOptionPane.ERROR_MESSAGE);
            editFrame.setVisible(true);
            return;
        }
    }
    // not currently editing a signal head
    editSysName = eSName;
    editingHead = true;
    curS = InstanceManager.getDefault(jmri.SignalHeadManager.class).getBySystemName(editSysName);
    if (editFrame == null) {
        dccSignalPanelEdt();
        eto1 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        eto2 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        eto3 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        eto4 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        eto5 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        eto6 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        eto7 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        // set up a new edit window
        editFrame = new JmriJFrame(Bundle.getMessage("TitleEditSignalHead"), false, true);
        editFrame.addHelpMenu("package.jmri.jmrit.beantable.SignalAddEdit", true);
        editFrame.getContentPane().setLayout(new BorderLayout());
        JPanel panelHeader = new JPanel();
        panelHeader.setLayout(new BoxLayout(panelHeader, BoxLayout.Y_AXIS));
        JPanel p;
        p = new JPanel();
        p.setLayout(new FlowLayout());
        p.add(signalType);
        panelHeader.add(p);
        panelHeader.add(new JSeparator());
        p = new JPanel();
        p.setLayout(new FlowLayout());
        p.add(eSystemNameLabel);
        p.add(eSystemName);
        p.add(eSysNameLabel);
        p.add(dccOffSetAddressEdt);
        dccOffSetAddressEdt.setToolTipText(Bundle.getMessage("DccOffsetTooltip"));
        panelHeader.add(p);
        p = new JPanel();
        p.setLayout(new FlowLayout());
        p.add(eUserNameLabel);
        p.add(eUserName);
        panelHeader.add(p);
        editFrame.getContentPane().add(panelHeader, BorderLayout.PAGE_START);
        // create seven boxes for input information, and put into pane
        JPanel panelCentre = new JPanel();
        panelCentre.setLayout(new BoxLayout(panelCentre, BoxLayout.Y_AXIS));
        ev1Panel = new JPanel();
        ev1Panel.setLayout(defaultFlow);
        ev1Panel.add(eto1);
        ev1Panel.add(es1Box);
        ev1Panel.add(emsaBox);
        emsaBox.setToolTipText(Bundle.getMessage("SignalHeadMergTooltip"));
        ev1Panel.setBorder(ev1Border);
        panelCentre.add(ev1Panel);
        ev2Panel = new JPanel();
        ev2Panel.setLayout(defaultFlow);
        ev2Panel.add(eto2);
        ev2Panel.add(es2Box);
        ev2Panel.add(es2aBox);
        ev2Panel.add(emstBox);
        emstBox.setToolTipText(Bundle.getMessage("SignalHeadUseTooltip"));
        ev2Panel.add(dccSignalPanelEdt);
        ev2Panel.setBorder(ev2Border);
        panelCentre.add(ev2Panel);
        ev3Panel = new JPanel();
        ev3Panel.setLayout(defaultFlow);
        ev3Panel.add(eto3);
        ev3Panel.add(es3Box);
        ev3Panel.add(es3aBox);
        ev3Panel.setBorder(ev3Border);
        panelCentre.add(ev3Panel);
        ev4Panel = new JPanel();
        ev4Panel.setLayout(defaultFlow);
        ev4Panel.add(eto4);
        ev4Panel.add(es4Box);
        ev4Panel.setBorder(ev4Border);
        panelCentre.add(ev4Panel);
        ev5Panel = new JPanel();
        ev5Panel.setLayout(defaultFlow);
        ev5Panel.add(eto5);
        ev5Panel.add(es5Box);
        ev5Panel.setBorder(ev5Border);
        panelCentre.add(ev5Panel);
        ev6Panel = new JPanel();
        ev6Panel.setLayout(defaultFlow);
        ev6Panel.add(eto6);
        ev6Panel.add(es6Box);
        ev6Panel.setBorder(ev6Border);
        panelCentre.add(ev6Panel);
        ev7Panel = new JPanel();
        ev7Panel.setLayout(defaultFlow);
        ev7Panel.add(eto7);
        ev7Panel.add(es7Box);
        ev7Panel.setBorder(ev7Border);
        panelCentre.add(ev7Panel);
        p = new JPanel();
        p.setLayout(defaultFlow);
        p.add(evtLabel);
        p.add(etot);
        p.add(estBox);
        panelCentre.add(p);
        JScrollPane scrollPane = new JScrollPane(panelCentre);
        editFrame.getContentPane().add(scrollPane, BorderLayout.CENTER);
        JPanel panelBottom = new JPanel();
        panelBottom.setLayout(new BoxLayout(panelBottom, BoxLayout.Y_AXIS));
        // add buttons
        p = new JPanel();
        p.setLayout(new FlowLayout(FlowLayout.TRAILING));
        JButton cancel;
        p.add(cancel = new JButton(Bundle.getMessage("ButtonCancel")));
        cancel.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                cancelPressed(e);
            }
        });
        JButton update;
        p.add(update = new JButton(Bundle.getMessage("ButtonUpdate")));
        update.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                updatePressed(e);
            }
        });
        panelBottom.add(p);
        editFrame.getContentPane().add(panelBottom, BorderLayout.PAGE_END);
        editFrame.addWindowListener(new java.awt.event.WindowAdapter() {

            @Override
            public void windowClosing(java.awt.event.WindowEvent e) {
                cancelPressed(null);
            }
        });
    } else {
        eto1.refresh();
        eto2.refresh();
        eto3.refresh();
        eto4.refresh();
        eto5.refresh();
        eto6.refresh();
        eto7.refresh();
    }
    // default the seven optional items to hidden, and system name to visible
    eSystemName.setVisible(false);
    eSysNameLabel.setVisible(true);
    eUserNameLabel.setVisible(true);
    eUserName.setVisible(true);
    ev1Panel.setVisible(false);
    dccOffSetAddressEdt.setVisible(false);
    eto1.setVisible(false);
    es1Box.setVisible(false);
    ev2Panel.setVisible(false);
    eto2.setVisible(false);
    es2Box.setVisible(false);
    es2aBox.setVisible(false);
    dccSignalPanelEdt.setVisible(false);
    ev3Panel.setVisible(false);
    eto3.setVisible(false);
    es3Box.setVisible(false);
    es3aBox.setVisible(false);
    ev4Panel.setVisible(false);
    eto4.setVisible(false);
    es4Box.setVisible(false);
    ev5Panel.setVisible(false);
    eto5.setVisible(false);
    es5Box.setVisible(false);
    ev6Panel.setVisible(false);
    eto6.setVisible(false);
    es6Box.setVisible(false);
    ev7Panel.setVisible(false);
    eto7.setVisible(false);
    es7Box.setVisible(false);
    evtLabel.setVisible(false);
    etot.setVisible(false);
    estBox.setVisible(false);
    emstBox.setVisible(false);
    emsaBox.setVisible(false);
    // determine class name of signal head and initialize edit panel for this class of signal
    className = curS.getClass().getName();
    if (className.equals("jmri.implementation.QuadOutputSignalHead")) {
        signalType.setText(quadOutput);
        eSystemNameLabel.setText(Bundle.getMessage("LabelSystemName"));
        eSysNameLabel.setText(curS.getSystemName());
        eUserNameLabel.setText(Bundle.getMessage("LabelUserName"));
        eUserName.setText(curS.getUserName());
        ev1Border.setTitle(Bundle.getMessage("LabelGreenTurnoutNumber"));
        ev1Panel.setVisible(true);
        eto1.setVisible(true);
        et1 = ((TripleTurnoutSignalHead) curS).getGreen().getBean();
        eto1.setDefaultNamedBean(et1);
        ev2Border.setTitle(Bundle.getMessage("LabelYellowTurnoutNumber"));
        ev2Panel.setVisible(true);
        eto2.setVisible(true);
        eto2.setDefaultNamedBean(((TripleTurnoutSignalHead) curS).getYellow().getBean());
        ev3Border.setTitle(Bundle.getMessage("LabelRedTurnoutNumber"));
        ev3Panel.setVisible(true);
        eto3.setVisible(true);
        eto3.setDefaultNamedBean(((TripleTurnoutSignalHead) curS).getRed().getBean());
        ev4Border.setTitle(Bundle.getMessage("LabelLunarTurnoutNumber"));
        ev4Panel.setVisible(true);
        eto4.setVisible(true);
        eto4.setDefaultNamedBean(((QuadOutputSignalHead) curS).getLunar().getBean());
    } else if (className.equals("jmri.implementation.TripleTurnoutSignalHead")) {
        signalType.setText(tripleTurnout);
        eSystemNameLabel.setText(Bundle.getMessage("LabelSystemName"));
        eSysNameLabel.setText(curS.getSystemName());
        eUserNameLabel.setText(Bundle.getMessage("LabelUserName"));
        eUserName.setText(curS.getUserName());
        ev1Border.setTitle(Bundle.getMessage("LabelGreenTurnoutNumber"));
        ev1Panel.setVisible(true);
        eto1.setVisible(true);
        eto1.setDefaultNamedBean(((TripleTurnoutSignalHead) curS).getGreen().getBean());
        ev2Border.setTitle(Bundle.getMessage("LabelYellowTurnoutNumber"));
        ev2Panel.setVisible(true);
        eto2.setVisible(true);
        eto2.setDefaultNamedBean(((TripleTurnoutSignalHead) curS).getYellow().getBean());
        ev3Border.setTitle(Bundle.getMessage("LabelRedTurnoutNumber"));
        ev3Panel.setVisible(true);
        eto3.setVisible(true);
        eto3.setDefaultNamedBean(((TripleTurnoutSignalHead) curS).getRed().getBean());
    } else if (className.equals("jmri.implementation.TripleOutputSignalHead")) {
        signalType.setText(tripleOutput);
        eSystemNameLabel.setText(Bundle.getMessage("LabelSystemName"));
        eSysNameLabel.setText(curS.getSystemName());
        eUserNameLabel.setText(Bundle.getMessage("LabelUserName"));
        eUserName.setText(curS.getUserName());
        ev1Border.setTitle(Bundle.getMessage("LabelGreenTurnoutNumber"));
        ev1Panel.setVisible(true);
        eto1.setVisible(true);
        eto1.setDefaultNamedBean(((TripleOutputSignalHead) curS).getGreen().getBean());
        ev2Border.setTitle(Bundle.getMessage("LabelBlueTurnoutNumber"));
        ev2Panel.setVisible(true);
        eto2.setVisible(true);
        eto2.setDefaultNamedBean(((TripleOutputSignalHead) curS).getBlue().getBean());
        ev3Border.setTitle(Bundle.getMessage("LabelRedTurnoutNumber"));
        ev3Panel.setVisible(true);
        eto3.setVisible(true);
        eto3.setDefaultNamedBean(((TripleOutputSignalHead) curS).getRed().getBean());
    } else if (className.equals("jmri.implementation.DoubleTurnoutSignalHead")) {
        signalType.setText(doubleTurnout);
        eSystemNameLabel.setText(Bundle.getMessage("LabelSystemName"));
        eSysNameLabel.setText(curS.getSystemName());
        eUserNameLabel.setText(Bundle.getMessage("LabelUserName"));
        eUserName.setText(curS.getUserName());
        ev1Border.setTitle(Bundle.getMessage("LabelGreenTurnoutNumber"));
        ev1Panel.setVisible(true);
        eto1.setVisible(true);
        eto1.setDefaultNamedBean(((DoubleTurnoutSignalHead) curS).getGreen().getBean());
        ev2Border.setTitle(Bundle.getMessage("LabelRedTurnoutNumber"));
        ev2Panel.setVisible(true);
        eto2.setVisible(true);
        eto2.setDefaultNamedBean(((DoubleTurnoutSignalHead) curS).getRed().getBean());
    } else if (className.equals("jmri.implementation.SingleTurnoutSignalHead")) {
        signalType.setText(singleTurnout);
        eSystemNameLabel.setText(Bundle.getMessage("LabelSystemName"));
        eSysNameLabel.setText(curS.getSystemName());
        eUserNameLabel.setText(Bundle.getMessage("LabelUserName"));
        eUserName.setText(curS.getUserName());
        ev1Border.setTitle(Bundle.getMessage("LabelTurnoutNumber"));
        ev1Panel.setVisible(true);
        eto1.setVisible(true);
        eto1.setDefaultNamedBean(((SingleTurnoutSignalHead) curS).getOutput().getBean());
        ev2Border.setTitle(Bundle.getMessage("LabelTurnoutClosedAppearance"));
        ev2Panel.setVisible(true);
        es2aBox.setVisible(true);
        setSignalStateInBox(es2aBox, ((SingleTurnoutSignalHead) curS).getOnAppearance());
        ev3Border.setTitle(Bundle.getMessage("LabelTurnoutThrownAppearance"));
        ev3Panel.setVisible(true);
        es3aBox.setVisible(true);
        setSignalStateInBox(es3aBox, ((SingleTurnoutSignalHead) curS).getOffAppearance());
    } else if (className.equals("jmri.implementation.VirtualSignalHead")) {
        signalType.setText(virtualHead);
        eSystemNameLabel.setText(Bundle.getMessage("LabelSystemName"));
        eSysNameLabel.setText(curS.getSystemName());
        eUserNameLabel.setText(Bundle.getMessage("LabelUserName"));
        eUserName.setText(curS.getUserName());
    } else if (className.equals("jmri.implementation.LsDecSignalHead")) {
        // LDT LS-DEC
        signalType.setText(lsDec);
        eSystemNameLabel.setText(Bundle.getMessage("LabelSystemName"));
        eSysNameLabel.setText(curS.getSystemName());
        eUserNameLabel.setText(Bundle.getMessage("LabelUserName"));
        eUserName.setText(curS.getUserName());
        ev1Border.setTitle(Bundle.getMessage("LabelGreenTurnoutNumber"));
        ev1Panel.setVisible(true);
        eto1.setVisible(true);
        eto1.setDefaultNamedBean(((jmri.implementation.LsDecSignalHead) curS).getGreen().getBean());
        es1Box.setVisible(true);
        setTurnoutStateInBox(es1Box, ((jmri.implementation.LsDecSignalHead) curS).getGreenState(), turnoutStateValues);
        ev2Border.setTitle(Bundle.getMessage("LabelYellowTurnoutNumber"));
        ev2Panel.setVisible(true);
        eto2.setVisible(true);
        eto2.setDefaultNamedBean(((jmri.implementation.LsDecSignalHead) curS).getYellow().getBean());
        es2Box.setVisible(true);
        setTurnoutStateInBox(es2Box, ((jmri.implementation.LsDecSignalHead) curS).getYellowState(), turnoutStateValues);
        ev3Border.setTitle(Bundle.getMessage("LabelRedTurnoutNumber"));
        ev3Panel.setVisible(true);
        eto3.setVisible(true);
        eto3.setDefaultNamedBean(((jmri.implementation.LsDecSignalHead) curS).getRed().getBean());
        es3Box.setVisible(true);
        setTurnoutStateInBox(es3Box, ((jmri.implementation.LsDecSignalHead) curS).getRedState(), turnoutStateValues);
        ev4Border.setTitle(Bundle.getMessage("LabelFlashGreenTurnoutNumber"));
        ev4Panel.setVisible(true);
        eto4.setVisible(true);
        eto4.setDefaultNamedBean(((jmri.implementation.LsDecSignalHead) curS).getFlashGreen().getBean());
        es4Box.setVisible(true);
        setTurnoutStateInBox(es4Box, ((jmri.implementation.LsDecSignalHead) curS).getFlashGreenState(), turnoutStateValues);
        ev5Border.setTitle(Bundle.getMessage("LabelFlashYellowTurnoutNumber"));
        ev5Panel.setVisible(true);
        eto5.setVisible(true);
        eto5.setDefaultNamedBean(((jmri.implementation.LsDecSignalHead) curS).getFlashYellow().getBean());
        es5Box.setVisible(true);
        setTurnoutStateInBox(es5Box, ((jmri.implementation.LsDecSignalHead) curS).getFlashYellowState(), turnoutStateValues);
        ev6Border.setTitle(Bundle.getMessage("LabelFlashRedTurnoutNumber"));
        ev6Panel.setVisible(true);
        eto6.setVisible(true);
        eto6.setDefaultNamedBean(((jmri.implementation.LsDecSignalHead) curS).getFlashRed().getBean());
        es6Box.setVisible(true);
        setTurnoutStateInBox(es6Box, ((jmri.implementation.LsDecSignalHead) curS).getFlashRedState(), turnoutStateValues);
        ev7Border.setTitle(Bundle.getMessage("LabelDarkTurnoutNumber"));
        ev7Panel.setVisible(true);
        eto7.setVisible(true);
        eto7.setDefaultNamedBean(((jmri.implementation.LsDecSignalHead) curS).getDark().getBean());
        es7Box.setVisible(true);
        setTurnoutStateInBox(es7Box, ((jmri.implementation.LsDecSignalHead) curS).getDarkState(), turnoutStateValues);
    } else if (className.equals("jmri.implementation.SE8cSignalHead")) {
        handleSE8cEditSignal();
    } else if (className.equals("jmri.jmrix.grapevine.SerialSignalHead")) {
        signalType.setText(grapevine);
        eSystemNameLabel.setText(Bundle.getMessage("LabelSystemName"));
        eSysNameLabel.setText(curS.getSystemName());
        eUserNameLabel.setText(Bundle.getMessage("LabelUserName"));
        eUserName.setText(curS.getUserName());
    /*ev1Border.setTitle(Bundle.getMessage("LabelUserName"));
             ev1Panel.setVisible(true);
             eto1.setVisible(true);
             eto1.setText(curS.getUserName());*/
    } else if (className.equals("jmri.jmrix.acela.AcelaSignalHead")) {
        signalType.setText(acela);
        eSystemNameLabel.setText(Bundle.getMessage("LabelSystemName"));
        eSysNameLabel.setText(curS.getSystemName());
        eUserNameLabel.setText(Bundle.getMessage("LabelUserName"));
        eUserName.setText(curS.getUserName());
        /*ev1Border.setTitle(Bundle.getMessage("LabelUserName"));
             ev1Panel.setVisible(true);
             eto1.setVisible(true);
             eto1.setText(curS.getUserName());*/
        evtLabel.setText(Bundle.getMessage("LabelAspectType") + ":");
        etot.setVisible(false);
        AcelaNode tNode = AcelaAddress.getNodeFromSystemName(curS.getSystemName(), jmri.InstanceManager.getDefault(jmri.jmrix.acela.AcelaSystemConnectionMemo.class));
        if (tNode == null) {
            // node does not exist, ignore call
            log.error("Can't find new Acela Signal with name '" + curS.getSystemName());
            return;
        }
        int headnumber = Integer.parseInt(curS.getSystemName().substring(2, curS.getSystemName().length()));
        estBox.setVisible(true);
        setSignalheadTypeInBox(estBox, tNode.getOutputSignalHeadType(headnumber), signalheadTypeValues);
    } else if (className.equals("jmri.implementation.DccSignalHead")) {
        signalType.setText(dccSignalDecoder);
        eSystemNameLabel.setText(Bundle.getMessage("LabelSystemName"));
        eSysNameLabel.setText(curS.getSystemName());
        eUserNameLabel.setText(Bundle.getMessage("LabelUserName"));
        eUserName.setText(curS.getUserName());
        for (int i = 0; i < DccSignalHead.getDefaultValidStates().length; i++) {
            JSpinner tmp = dccAspectEdt[i];
            tmp.setValue(((DccSignalHead) curS).getOutputForAppearance(curS.getValidStates()[i]));
        //  tmp.setValue((Integer) DccSignalHead.getDefaultNumberForApperance(DccSignalHead.getDefaultValidStates()[i]))
        }
        dccOffSetAddressEdt.setVisible(true);
        dccOffSetAddressEdt.setSelected(((DccSignalHead) curS).useAddressOffSet());
        ev2Border.setTitle(Bundle.getMessage("LabelAspectNumbering"));
        ev2Panel.setVisible(true);
        dccSignalPanelEdt.setVisible(true);
    } else if (className.equals("jmri.implementation.MergSD2SignalHead")) {
        //Edit signal stuff to go here!
        signalType.setText(mergSignalDriver);
        eSystemNameLabel.setText(Bundle.getMessage("LabelSystemName"));
        eSysNameLabel.setText(curS.getSystemName());
        eUserNameLabel.setText(Bundle.getMessage("LabelUserName"));
        eUserName.setText(curS.getUserName());
        // same as line 1054
        ev1Border.setTitle(Bundle.getMessage("NumberOfAppearances"));
        ev1Panel.setVisible(true);
        setUkSignalAspectsFromBox(emsaBox, ((jmri.implementation.MergSD2SignalHead) curS).getAspects());
        eto1.setVisible(false);
        emsaBox.setVisible(true);
        //            emsaBox.setToolTipText(Bundle.getMessage("SignalHeadMergTooltip"));
        // same as line 1090
        ev2Border.setTitle(Bundle.getMessage("UseAs"));
        ev2Panel.setVisible(true);
        eto2.setVisible(false);
        emstBox.setVisible(true);
        if (((jmri.implementation.MergSD2SignalHead) curS).getHome()) {
            // "Home"
            setUkSignalType(emstBox, Bundle.getMessage("HomeSignal"));
        } else {
            //"Distant"
            setUkSignalType(emstBox, Bundle.getMessage("DistantSignal"));
        }
        //setUKSignalTypeFromBox(emstBox, ((jmri.implementation.MergSD2SignalHead)curS).getAspects());
        ev3Border.setTitle(Bundle.getMessage("InputNum", " 1 "));
        ev3Panel.setVisible(true);
        eto3.setVisible(true);
        eto3.setDefaultNamedBean(((jmri.implementation.MergSD2SignalHead) curS).getInput1().getBean());
        ev4Border.setTitle(Bundle.getMessage("InputNum", " 2 "));
        ev4Panel.setVisible(true);
        eto4.setVisible(true);
        if (((jmri.implementation.MergSD2SignalHead) curS).getInput2() != null) {
            eto4.setDefaultNamedBean(((jmri.implementation.MergSD2SignalHead) curS).getInput2().getBean());
        }
        ev5Border.setTitle(Bundle.getMessage("InputNum", " 3 "));
        ev5Panel.setVisible(true);
        eto5.setVisible(true);
        if (((jmri.implementation.MergSD2SignalHead) curS).getInput3() != null) {
            eto5.setDefaultNamedBean(((jmri.implementation.MergSD2SignalHead) curS).getInput3().getBean());
        }
        emsaBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                ukAspectChange(true);
            }
        });
        ukAspectChange(true);
    } else {
        log.error("Cannot edit SignalHead of unrecognized type: " + className);
    }
    // finish up
    editFrame.pack();
    editFrame.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) TripleTurnoutSignalHead(jmri.implementation.TripleTurnoutSignalHead) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) TripleOutputSignalHead(jmri.implementation.TripleOutputSignalHead) JSeparator(javax.swing.JSeparator) BorderLayout(java.awt.BorderLayout) BeanSelectCreatePanel(jmri.util.swing.BeanSelectCreatePanel) JScrollPane(javax.swing.JScrollPane) AcelaNode(jmri.jmrix.acela.AcelaNode) SingleTurnoutSignalHead(jmri.implementation.SingleTurnoutSignalHead) ActionListener(java.awt.event.ActionListener) JmriJFrame(jmri.util.JmriJFrame) QuadOutputSignalHead(jmri.implementation.QuadOutputSignalHead) JSpinner(javax.swing.JSpinner)

Example 3 with SingleTurnoutSignalHead

use of jmri.implementation.SingleTurnoutSignalHead in project JMRI by JMRI.

the class SingleTurnoutSignalHeadXml method store.

/**
     * Default implementation for storing the contents of a
     * SingleTurnoutSignalHead
     *
     * @param o Object to store, of type TripleTurnoutSignalHead
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    SingleTurnoutSignalHead p = (SingleTurnoutSignalHead) o;
    Element element = new Element("signalhead");
    element.setAttribute("class", this.getClass().getName());
    // include contents
    element.addContent(new Element("systemName").addContent(p.getSystemName()));
    storeCommon(p, element);
    Element el = new Element("appearance");
    el.setAttribute("defines", "thrown");
    el.addContent(getSignalColour(p.getOnAppearance()));
    element.addContent(el);
    el = new Element("appearance");
    el.setAttribute("defines", "closed");
    el.addContent(getSignalColour(p.getOffAppearance()));
    element.addContent(el);
    el = new Element("turnoutname");
    el.setAttribute("defines", "aspect");
    el.addContent(p.getOutput().getName());
    element.addContent(el);
    return element;
}
Also used : SingleTurnoutSignalHead(jmri.implementation.SingleTurnoutSignalHead) Element(org.jdom2.Element)

Example 4 with SingleTurnoutSignalHead

use of jmri.implementation.SingleTurnoutSignalHead in project JMRI by JMRI.

the class SingleTurnoutSignalHeadXml method load.

@Override
public boolean load(Element shared, Element perNode) {
    List<Element> l = shared.getChildren("turnoutname");
    if (l.size() == 0) {
        l = shared.getChildren("turnout");
    }
    NamedBeanHandle<Turnout> lit = loadTurnout(l.get(0));
    int off = loadAppearance(shared.getChildren("appearance"), "closed");
    int on = loadAppearance(shared.getChildren("appearance"), "thrown");
    // put it together
    String sys = getSystemName(shared);
    String uname = getUserName(shared);
    SignalHead h;
    if (uname == null) {
        h = new SingleTurnoutSignalHead(sys, lit, on, off);
    } else {
        h = new SingleTurnoutSignalHead(sys, uname, lit, on, off);
    }
    loadCommon(h, shared);
    InstanceManager.getDefault(jmri.SignalHeadManager.class).register(h);
    return true;
}
Also used : SingleTurnoutSignalHead(jmri.implementation.SingleTurnoutSignalHead) Element(org.jdom2.Element) SingleTurnoutSignalHead(jmri.implementation.SingleTurnoutSignalHead) SignalHead(jmri.SignalHead) Turnout(jmri.Turnout)

Aggregations

SingleTurnoutSignalHead (jmri.implementation.SingleTurnoutSignalHead)4 Turnout (jmri.Turnout)2 QuadOutputSignalHead (jmri.implementation.QuadOutputSignalHead)2 TripleOutputSignalHead (jmri.implementation.TripleOutputSignalHead)2 AcelaNode (jmri.jmrix.acela.AcelaNode)2 Element (org.jdom2.Element)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 BorderLayout (java.awt.BorderLayout)1 FlowLayout (java.awt.FlowLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 BoxLayout (javax.swing.BoxLayout)1 JButton (javax.swing.JButton)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JSeparator (javax.swing.JSeparator)1 JSpinner (javax.swing.JSpinner)1 SignalHead (jmri.SignalHead)1 DccSignalHead (jmri.implementation.DccSignalHead)1 TripleTurnoutSignalHead (jmri.implementation.TripleTurnoutSignalHead)1