Search in sources :

Example 1 with BeanSelectCreatePanel

use of jmri.util.swing.BeanSelectCreatePanel in project JMRI by JMRI.

the class SignalHeadTableAction method addPressed.

/**
     * Provide GUI for adding a new SignalHead.
     * <p>
     * Because there are multiple options, each of which requires different
     * inputs, we directly manipulate which parts of the GUI are displayed when
     * the selected type is changed.
     *
     * @param e name of the event heard
     */
@Override
protected void addPressed(ActionEvent e) {
    if (addFrame == null) {
        for (Object obj : jmri.InstanceManager.getList(jmri.CommandStation.class)) {
            jmri.CommandStation station = (jmri.CommandStation) obj;
            prefixBox.addItem(station.getUserName());
        }
        dccSignalPanel();
        to1 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        to2 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        to3 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        to4 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        to5 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        to6 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        to7 = new BeanSelectCreatePanel(InstanceManager.turnoutManagerInstance(), null);
        addFrame = new JmriJFrame(Bundle.getMessage("TitleAddSignalHead"), false, true);
        addFrame.addHelpMenu("package.jmri.jmrit.beantable.SignalAddEdit", true);
        addFrame.getContentPane().setLayout(new BorderLayout());
        JPanel panelHeader = new JPanel();
        panelHeader.setLayout(new BoxLayout(panelHeader, BoxLayout.Y_AXIS));
        panelHeader.add(typeBox = new JComboBox<String>(new String[] { acelaAspect, dccSignalDecoder, doubleTurnout, lsDec, mergSignalDriver, quadOutput, singleTurnout, se8c4Aspect, tripleTurnout, tripleOutput, virtualHead }));
        //If no DCC Comand station is found remove the DCC Signal Decoder option.
        if (prefixBox.getItemCount() == 0) {
            typeBox.removeItem(dccSignalDecoder);
        }
        List<jmri.jmrix.grapevine.GrapevineSystemConnectionMemo> memos = InstanceManager.getList(jmri.jmrix.grapevine.GrapevineSystemConnectionMemo.class);
        if (!memos.isEmpty()) {
            typeBox.addItem(grapevine);
        }
        typeBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                typeChanged();
            }
        });
        JPanel p = new JPanel();
        p.setLayout(new FlowLayout());
        p.add(prefixBoxLabel);
        p.add(prefixBox);
        panelHeader.add(p);
        p = new JPanel();
        p.setLayout(new FlowLayout());
        p.add(systemNameLabel);
        p.add(systemName);
        systemName.setToolTipText(Bundle.getMessage("SignalHeadSysNameTooltip"));
        p.add(dccOffSetAddress);
        dccOffSetAddress.setToolTipText(Bundle.getMessage("DccOffsetTooltip"));
        panelHeader.add(p);
        p = new JPanel();
        p.setLayout(new FlowLayout());
        p.add(userNameLabel);
        p.add(userName);
        userName.setToolTipText(Bundle.getMessage("SignalHeadUserNameTooltip"));
        panelHeader.add(p);
        addFrame.getContentPane().add(panelHeader, BorderLayout.PAGE_START);
        JPanel panelCentre = new JPanel();
        panelCentre.setLayout(new BoxLayout(panelCentre, BoxLayout.Y_AXIS));
        //typeBox.setSelectedIndex(7);
        //typeChanged();
        // create seven boxes for input information, and put into pane
        v1Panel = new JPanel();
        v1Panel.setLayout(new FlowLayout());
        v1Panel.add(ato1);
        v1Panel.add(to1);
        v1Panel.add(stateLabel1);
        v1Panel.add(s1Box);
        s1Box.setToolTipText(Bundle.getMessage("SignalHeadStateTooltip"));
        v1Panel.add(msaBox);
        v1Panel.setBorder(v1Border);
        panelCentre.add(v1Panel);
        v2Panel = new JPanel();
        v2Panel.setLayout(defaultFlow);
        v2Panel.add(to2);
        v2Panel.add(stateLabel2);
        v2Panel.add(s2Box);
        s2Box.setToolTipText(Bundle.getMessage("SignalHeadStateTooltip"));
        v2Panel.add(s2aBox);
        v2Panel.add(mstBox);
        v2Panel.add(dccSignalPanel);
        v2Panel.setBorder(v2Border);
        panelCentre.add(v2Panel);
        v3Panel = new JPanel();
        v3Panel.setLayout(defaultFlow);
        v3Panel.add(to3);
        v3Panel.add(stateLabel3);
        v3Panel.add(s3Box);
        s3Box.setToolTipText(Bundle.getMessage("SignalHeadStateTooltip"));
        v3Panel.add(s3aBox);
        v3Panel.setBorder(v3Border);
        panelCentre.add(v3Panel);
        v4Panel = new JPanel();
        v4Panel.setLayout(defaultFlow);
        v4Panel.add(to4);
        v4Panel.add(stateLabel4);
        v4Panel.add(s4Box);
        s4Box.setToolTipText(Bundle.getMessage("SignalHeadStateTooltip"));
        v4Panel.setBorder(v4Border);
        panelCentre.add(v4Panel);
        v5Panel = new JPanel();
        v5Panel.setLayout(defaultFlow);
        v5Panel.add(to5);
        v5Panel.add(stateLabel5);
        v5Panel.add(s5Box);
        s5Box.setToolTipText(Bundle.getMessage("SignalHeadStateTooltip"));
        v5Panel.setBorder(v5Border);
        panelCentre.add(v5Panel);
        v6Panel = new JPanel();
        v6Panel.setLayout(defaultFlow);
        v6Panel.add(to6);
        v6Panel.add(stateLabel6);
        v6Panel.add(s6Box);
        s6Box.setToolTipText(Bundle.getMessage("SignalHeadStateTooltip"));
        v6Panel.setBorder(v6Border);
        panelCentre.add(v6Panel);
        v7Panel = new JPanel();
        v7Panel.setLayout(defaultFlow);
        v7Panel.add(to7);
        v7Panel.add(stateLabel7);
        v7Panel.add(s7Box);
        s7Box.setToolTipText(Bundle.getMessage("SignalHeadStateTooltip"));
        v7Panel.setBorder(v7Border);
        panelCentre.add(v7Panel);
        p = new JPanel();
        p.setLayout(defaultFlow);
        p.add(vtLabel);
        p.add(stBox);
        panelCentre.add(p);
        JScrollPane scrollPane = new JScrollPane(panelCentre);
        addFrame.getContentPane().add(scrollPane, BorderLayout.CENTER);
        // buttons at bottom of panel
        JPanel panelBottom = new JPanel();
        panelBottom.setLayout(new FlowLayout(FlowLayout.TRAILING));
        // Cancel button
        JButton cancelNew = new JButton(Bundle.getMessage("ButtonCancel"));
        panelBottom.add(cancelNew);
        cancelNew.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                cancelNewPressed(e);
            }
        });
        //OK button
        JButton ok;
        panelBottom.add(ok = new JButton(Bundle.getMessage("ButtonCreate")));
        ok.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                okPressed(e);
            }
        });
        addFrame.getContentPane().add(panelBottom, BorderLayout.PAGE_END);
    } else {
        // clear older entries
        systemName.setText("");
        userName.setText("");
        to1.refresh();
        to2.refresh();
        to3.refresh();
        to4.refresh();
        to5.refresh();
        to6.refresh();
        to7.refresh();
    }
    // force GUI status consistent. Default set to Double Head type
    typeBox.setSelectedIndex(2);
    addFrame.pack();
    addFrame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) JmriJFrame(jmri.util.JmriJFrame) BeanSelectCreatePanel(jmri.util.swing.BeanSelectCreatePanel)

Example 2 with BeanSelectCreatePanel

use of jmri.util.swing.BeanSelectCreatePanel 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)

Aggregations

BorderLayout (java.awt.BorderLayout)2 FlowLayout (java.awt.FlowLayout)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 BoxLayout (javax.swing.BoxLayout)2 JButton (javax.swing.JButton)2 JPanel (javax.swing.JPanel)2 JScrollPane (javax.swing.JScrollPane)2 JmriJFrame (jmri.util.JmriJFrame)2 BeanSelectCreatePanel (jmri.util.swing.BeanSelectCreatePanel)2 JComboBox (javax.swing.JComboBox)1 JSeparator (javax.swing.JSeparator)1 JSpinner (javax.swing.JSpinner)1 QuadOutputSignalHead (jmri.implementation.QuadOutputSignalHead)1 SingleTurnoutSignalHead (jmri.implementation.SingleTurnoutSignalHead)1 TripleOutputSignalHead (jmri.implementation.TripleOutputSignalHead)1 TripleTurnoutSignalHead (jmri.implementation.TripleTurnoutSignalHead)1 AcelaNode (jmri.jmrix.acela.AcelaNode)1