Search in sources :

Example 6 with JmriBeanComboBox

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

the class AddSignalMastPanel method checkSignalHeadUse.

boolean checkSignalHeadUse() {
    for (int i = 0; i < headList.size(); i++) {
        JmriBeanComboBox head = headList.get(i);
        NamedBean h = headList.get(i).getSelectedBean();
        for (int j = i; j < headList.size(); j++) {
            JmriBeanComboBox head2check = headList.get(j);
            if ((head2check != head) && (head2check.getSelectedBean() == h)) {
                if (!duplicateHeadAssigned(headList.get(i).getSelectedDisplayName())) {
                    return false;
                }
            }
        }
        if (includeUsed.isSelected()) {
            String isUsed = SignalHeadSignalMast.isHeadUsed((SignalHead) h);
            if ((isUsed != null) && (!headAssignedElseWhere(h.getDisplayName(), isUsed))) {
                return false;
            }
        }
    }
    return true;
}
Also used : JmriBeanComboBox(jmri.util.swing.JmriBeanComboBox) NamedBean(jmri.NamedBean)

Example 7 with JmriBeanComboBox

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

the class SignalGroupTableAction method addPressed.

/**
     * Respond to click on Add... button below Signal Group Table.
     * <p>
     * Create JPanel with options for configuration.
     * @param e Event from origin; null when called from Edit button in Signal Group Table row
     */
@Override
protected void addPressed(ActionEvent e) {
    if (inEditMode) {
        log.debug("Can not open another editing session for Signal Groups.");
        // add user warning that a 2nd session not allowed (cf. Logix)
        // Already editing a Signal Group, ask for completion of that edit first
        String workingTitle = _systemName.getText();
        if (workingTitle.isEmpty() || workingTitle == null) {
            workingTitle = Bundle.getMessage("NONE");
            _systemName.setText(workingTitle);
        }
        javax.swing.JOptionPane.showMessageDialog(addFrame, Bundle.getMessage("SigGroupEditBusyWarning", workingTitle), Bundle.getMessage("ErrorTitle"), javax.swing.JOptionPane.ERROR_MESSAGE);
        return;
    }
    inEditMode = true;
    _mastAspectsList = null;
    jmri.SignalHeadManager shm = InstanceManager.getDefault(jmri.SignalHeadManager.class);
    List<String> systemNameList = shm.getSystemNameList();
    _signalHeadsList = new ArrayList<SignalGroupSignalHead>(systemNameList.size());
    // create list of all available Single Output Signal Heads to choose from
    Iterator<String> iter = systemNameList.iterator();
    // int i = 1; // for debug of iter next
    while (iter.hasNext()) {
        String systemName = iter.next();
        SignalHead sh = shm.getBySystemName(systemName);
        // debug using i & sysnamelist.size
        if (sh != null) {
            if (sh.getClass().getName().contains("SingleTurnoutSignalHead")) {
                String userName = sh.getUserName();
                // add every single output signal head item to the list
                _signalHeadsList.add(new SignalGroupSignalHead(systemName, userName));
            } else {
                log.debug("Signal Head " + systemName + " is not a Single Output Controlled Signal Head");
            }
        } else {
            // this is not an error and the value of systemName mentioned is actually from the last head that was indeed loaded
            log.error("Failed to get signal head {} (SGTA)", systemName);
        }
    }
    // Set up Add/Edit Signal Group window
    if (addFrame == null) {
        // if it's not yet present, create addFrame
        mainSignalComboBox = new JmriBeanComboBox(jmri.InstanceManager.getDefault(jmri.SignalMastManager.class), null, JmriBeanComboBox.DisplayOptions.DISPLAYNAME);
        // causes NPE when user selects that 1st line, so do not respond to result null
        mainSignalComboBox.setFirstItemBlank(true);
        addFrame = new JmriJFrame(Bundle.getMessage("AddSignalGroup"), false, true);
        addFrame.addHelpMenu("package.jmri.jmrit.beantable.SignalGroupAddEdit", true);
        addFrame.setLocation(100, 30);
        addFrame.getContentPane().setLayout(new BoxLayout(addFrame.getContentPane(), BoxLayout.Y_AXIS));
        Container contentPane = addFrame.getContentPane();
        // add system name
        JPanel ps = new JPanel();
        ps.setLayout(new FlowLayout());
        ps.add(nameLabel);
        ps.add(_systemName);
        _systemName.setToolTipText(Bundle.getMessage("SignalGroupSysNameTooltip"));
        ps.add(fixedSystemName);
        fixedSystemName.setVisible(false);
        contentPane.add(ps);
        // add user name
        JPanel p = new JPanel();
        p.setLayout(new FlowLayout());
        p.add(userLabel);
        p.add(_userName);
        _userName.setToolTipText(Bundle.getMessage("SignalGroupUserNameTooltip"));
        contentPane.add(p);
        // add Signal Masts/Heads Display Choice
        JPanel py = new JPanel();
        py.add(new JLabel(Bundle.getMessage("Show")));
        selGroup = new ButtonGroup();
        allButton = new JRadioButton(Bundle.getMessage("All"), true);
        selGroup.add(allButton);
        py.add(allButton);
        allButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                // Setup for display of all Signal Masts & SingleTO Heads, if needed
                if (!showAll) {
                    showAll = true;
                    _SignalGroupHeadModel.fireTableDataChanged();
                    _AspectModel.fireTableDataChanged();
                }
            }
        });
        includedButton = new JRadioButton(Bundle.getMessage("Included"), false);
        selGroup.add(includedButton);
        py.add(includedButton);
        includedButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                // Setup for display of included Turnouts only, if needed
                if (showAll) {
                    showAll = false;
                    initializeIncludedList();
                    _SignalGroupHeadModel.fireTableDataChanged();
                    _AspectModel.fireTableDataChanged();
                }
            }
        });
        py.add(new JLabel("  " + Bundle.getMessage("_and_", Bundle.getMessage("LabelAspects"), Bundle.getMessage("SignalHeads"))));
        contentPane.add(py);
        // add main signal mast table
        JPanel p3 = new JPanel();
        p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
        JPanel p31 = new JPanel();
        p31.add(new JLabel(Bundle.getMessage("EnterMastAttached", Bundle.getMessage("BeanNameSignalMast"))));
        p3.add(p31);
        JPanel p32 = new JPanel();
        p32.add(new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("BeanNameSignalMast"))));
        // comboBox to pick a main Signal Mast
        p32.add(mainSignalComboBox);
        p3.add(p32);
        p3xsi = new JPanel();
        JPanel p3xsiSpace = new JPanel();
        p3xsiSpace.setLayout(new BoxLayout(p3xsiSpace, BoxLayout.Y_AXIS));
        p3xsiSpace.add(new JLabel(" "));
        p3xsi.add(p3xsiSpace);
        JPanel p31si = new JPanel();
        p31si.setLayout(new BoxLayout(p31si, BoxLayout.Y_AXIS));
        p31si.add(new JLabel(Bundle.getMessage("SelectAppearanceTrigger")));
        p3xsi.add(p31si);
        _AspectModel = new SignalMastAspectModel();
        JTable SignalMastAspectTable = new JTable(_AspectModel);
        TableRowSorter<SignalMastAspectModel> smaSorter = new TableRowSorter<>(_AspectModel);
        smaSorter.setComparator(SignalMastAspectModel.ASPECT_COLUMN, new SystemNameComparator());
        RowSorterUtil.setSortOrder(smaSorter, SignalMastAspectModel.ASPECT_COLUMN, SortOrder.ASCENDING);
        SignalMastAspectTable.setRowSorter(smaSorter);
        SignalMastAspectTable.setRowSelectionAllowed(false);
        SignalMastAspectTable.setPreferredScrollableViewportSize(new java.awt.Dimension(200, 80));
        TableColumnModel SignalMastAspectColumnModel = SignalMastAspectTable.getColumnModel();
        TableColumn includeColumnA = SignalMastAspectColumnModel.getColumn(SignalGroupTableAction.SignalMastAspectModel.INCLUDE_COLUMN);
        includeColumnA.setResizable(false);
        includeColumnA.setMinWidth(30);
        includeColumnA.setMaxWidth(60);
        @SuppressWarnings("static-access") TableColumn sNameColumnA = SignalMastAspectColumnModel.getColumn(_AspectModel.ASPECT_COLUMN);
        sNameColumnA.setResizable(true);
        sNameColumnA.setMinWidth(75);
        sNameColumnA.setMaxWidth(140);
        _SignalAppearanceScrollPane = new JScrollPane(SignalMastAspectTable);
        p3xsi.add(_SignalAppearanceScrollPane, BorderLayout.CENTER);
        p3.add(p3xsi);
        p3xsi.setVisible(true);
        // respond to comboBox selection
        mainSignalComboBox.addActionListener(new ActionListener() {

            //public void focusGained(FocusEvent e) {
            //}
            @Override
            public void actionPerformed(ActionEvent event) {
                if (mainSignalComboBox.getSelectedBean() == null) {
                    // ie. empty first row was selected or set
                    log.debug("Empty line in mainSignal comboBox");
                //setValidSignalMastAspects(); // clears the Aspect table
                } else {
                    if (curSignalGroup == null || mainSignalComboBox.getSelectedBean() != curSignalGroup.getSignalMast()) {
                        log.debug("comboBox closed, choice: {}", mainSignalComboBox.getSelectedItem());
                        // refresh table with signal mast aspects
                        setValidSignalMastAspects();
                    } else {
                        log.debug("Mast {} picked in mainSignal comboBox", mainSignalComboBox.getSelectedItem());
                    }
                }
            }
        });
        // complete this panel
        Border p3Border = BorderFactory.createEtchedBorder();
        p3.setBorder(p3Border);
        contentPane.add(p3);
        p2xsi = new JPanel();
        JPanel p2xsiSpace = new JPanel();
        p2xsiSpace.setLayout(new BoxLayout(p2xsiSpace, BoxLayout.Y_AXIS));
        p2xsiSpace.add(new JLabel("XXX"));
        p2xsi.add(p2xsiSpace);
        JPanel p21si = new JPanel();
        p21si.setLayout(new BoxLayout(p21si, BoxLayout.Y_AXIS));
        p21si.add(new JLabel(Bundle.getMessage("SelectInGroup", Bundle.getMessage("SignalHeads"))));
        p2xsi.add(p21si);
        _SignalGroupHeadModel = new SignalGroupSignalHeadModel();
        JTable SignalGroupHeadTable = new JTable(_SignalGroupHeadModel);
        TableRowSorter<SignalGroupSignalHeadModel> sgsSorter = new TableRowSorter<>(_SignalGroupHeadModel);
        sgsSorter.setComparator(SignalGroupSignalHeadModel.SNAME_COLUMN, new SystemNameComparator());
        RowSorterUtil.setSortOrder(sgsSorter, SignalGroupSignalHeadModel.SNAME_COLUMN, SortOrder.ASCENDING);
        SignalGroupHeadTable.setRowSorter(sgsSorter);
        SignalGroupHeadTable.setRowSelectionAllowed(false);
        SignalGroupHeadTable.setPreferredScrollableViewportSize(new java.awt.Dimension(480, 160));
        TableColumnModel SignalGroupSignalColumnModel = SignalGroupHeadTable.getColumnModel();
        TableColumn includeColumnSi = SignalGroupSignalColumnModel.getColumn(SignalGroupSignalHeadModel.INCLUDE_COLUMN);
        includeColumnSi.setResizable(false);
        includeColumnSi.setMinWidth(30);
        includeColumnSi.setMaxWidth(60);
        TableColumn sNameColumnSi = SignalGroupSignalColumnModel.getColumn(SignalGroupSignalHeadModel.SNAME_COLUMN);
        sNameColumnSi.setResizable(true);
        sNameColumnSi.setMinWidth(75);
        sNameColumnSi.setMaxWidth(95);
        TableColumn uNameColumnSi = SignalGroupSignalColumnModel.getColumn(SignalGroupSignalHeadModel.UNAME_COLUMN);
        uNameColumnSi.setResizable(true);
        uNameColumnSi.setMinWidth(100);
        uNameColumnSi.setMaxWidth(260);
        TableColumn stateOnColumnSi = SignalGroupSignalColumnModel.getColumn(// a 6 column table
        SignalGroupSignalHeadModel.STATE_ON_COLUMN);
        stateOnColumnSi.setResizable(false);
        // was 50
        stateOnColumnSi.setMinWidth(Bundle.getMessage("SignalHeadStateFlashingYellow").length());
        stateOnColumnSi.setMaxWidth(100);
        TableColumn stateOffColumnSi = SignalGroupSignalColumnModel.getColumn(SignalGroupSignalHeadModel.STATE_OFF_COLUMN);
        stateOffColumnSi.setResizable(false);
        stateOffColumnSi.setMinWidth(50);
        stateOffColumnSi.setMaxWidth(100);
        TableColumn editColumnSi = SignalGroupSignalColumnModel.getColumn(SignalGroupSignalHeadModel.EDIT_COLUMN);
        editColumnSi.setResizable(false);
        // was 50
        editColumnSi.setMinWidth(Bundle.getMessage("ButtonEdit").length());
        editColumnSi.setMaxWidth(100);
        JButton editButton = new JButton(Bundle.getMessage("ButtonEdit"));
        setColumnToHoldButton(SignalGroupHeadTable, SignalGroupSignalHeadModel.EDIT_COLUMN, editButton);
        _SignalGroupHeadScrollPane = new JScrollPane(SignalGroupHeadTable);
        p2xsi.add(_SignalGroupHeadScrollPane, BorderLayout.CENTER);
        // add tooltip to explain which head types are shown
        p2xsi.setToolTipText(Bundle.getMessage("SignalGroupHeadTableTooltip"));
        contentPane.add(p2xsi);
        p2xsi.setVisible(true);
        // add notes panel, may be empty (a dot on the screen)
        JPanel pa = new JPanel();
        pa.setLayout(new BoxLayout(pa, BoxLayout.Y_AXIS));
        Border pBorder = BorderFactory.createEtchedBorder();
        pa.setBorder(pBorder);
        contentPane.add(pa);
        // buttons at bottom of panel
        JPanel pb = new JPanel();
        pb.setLayout(new FlowLayout(FlowLayout.TRAILING));
        pb.add(cancelButton);
        cancelButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                cancelPressed(e);
            }
        });
        cancelButton.setVisible(true);
        pb.add(deleteButton);
        deleteButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                deletePressed(e);
            }
        });
        deleteButton.setToolTipText(Bundle.getMessage("DeleteSignalGroupInSystem"));
        // [Update] Signal Group button in Add/Edit SignalGroup pane
        pb.add(updateButton);
        updateButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                updatePressed(e, false, true);
            }
        });
        updateButton.setToolTipText(Bundle.getMessage("TooltipUpdate"));
        updateButton.setVisible(true);
        contentPane.add(pb);
        // pack and release space
        addFrame.pack();
        p2xsiSpace.setVisible(false);
    } else // set listener for window closing
    {
        mainSignalComboBox.setSelectedBean(null);
        // reset title for new group
        addFrame.setTitle(Bundle.getMessage("AddSignalGroup"));
    }
    addFrame.addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowClosing(java.awt.event.WindowEvent e) {
            // remind to save, if Signal Group was created or edited
            if (SignalGroupDirty) {
                InstanceManager.getDefault(jmri.UserPreferencesManager.class).showInfoMessage(Bundle.getMessage("ReminderTitle"), Bundle.getMessage("ReminderSaveString", Bundle.getMessage("SignalGroup")), "beantable.SignalGroupTableAction", // NOI18N
                "remindSignalGroup");
                SignalGroupDirty = false;
            }
            // hide first, could be gone by the time of the close event,
            if (addFrame != null) {
                addFrame.setVisible(false);
            }
            // so prevent NPE
            // release editing soon, as long as NPEs occor in the following methods
            inEditMode = false;
            finishUpdate();
            _SignalGroupHeadModel.dispose();
            _AspectModel.dispose();
        }
    });
    // display the pane
    addFrame.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JRadioButton(javax.swing.JRadioButton) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) SignalHead(jmri.SignalHead) TableColumnModel(javax.swing.table.TableColumnModel) JmriBeanComboBox(jmri.util.swing.JmriBeanComboBox) Container(java.awt.Container) TableRowSorter(javax.swing.table.TableRowSorter) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) TableColumn(javax.swing.table.TableColumn) ActionListener(java.awt.event.ActionListener) JmriJFrame(jmri.util.JmriJFrame) ButtonGroup(javax.swing.ButtonGroup) JTable(javax.swing.JTable) SystemNameComparator(jmri.util.SystemNameComparator) Border(javax.swing.border.Border)

Example 8 with JmriBeanComboBox

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

the class TurnoutEditAction method feedback.

BeanItemPanel feedback() {
    feedback = new BeanItemPanel();
    feedback.setName(Bundle.getMessage("Feedback"));
    modeBox = new JComboBox<String>(((Turnout) bean).getValidFeedbackNames());
    oldModeSelection = ((Turnout) bean).getFeedbackModeName();
    modeBox.setSelectedItem(oldModeSelection);
    modeBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateFeedbackOptions();
        }
    });
    feedback.addItem(new BeanEditItem(null, null, Bundle.getMessage("FeedbackToolTip")));
    feedback.addItem(new BeanEditItem(modeBox, Bundle.getMessage("FeedbackMode"), Bundle.getMessage("FeedbackModeToolTip")));
    sensorFeedBack1ComboBox = new JmriBeanComboBox(InstanceManager.sensorManagerInstance(), ((Turnout) bean).getFirstSensor(), JmriBeanComboBox.DisplayOptions.DISPLAYNAME);
    sensorFeedBack1ComboBox.setFirstItemBlank(true);
    feedback.addItem(new BeanEditItem(sensorFeedBack1ComboBox, Bundle.getMessage("FeedbackSensor1"), Bundle.getMessage("FeedbackSensorToolTip")));
    sensorFeedBack2ComboBox = new JmriBeanComboBox(InstanceManager.sensorManagerInstance(), ((Turnout) bean).getSecondSensor(), JmriBeanComboBox.DisplayOptions.DISPLAYNAME);
    sensorFeedBack2ComboBox.setFirstItemBlank(true);
    feedback.addItem(new BeanEditItem(sensorFeedBack2ComboBox, Bundle.getMessage("FeedbackSensor2"), Bundle.getMessage("FeedbackSensorToolTip")));
    String[] str = new String[] { "empty" };
    automationBox = new JComboBox<String>(str);
    feedback.addItem(new BeanEditItem(automationBox, Bundle.getMessage("TurnoutAutomation"), Bundle.getMessage("TurnoutAutomationToolTip")));
    oldAutomationSelection = ((Turnout) bean).getTurnoutOperation();
    if (oldAutomationSelection != null) {
        config = TurnoutOperationConfig.getConfigPanel(oldAutomationSelection);
    } else {
        config = TurnoutOperationConfig.getConfigPanel(new jmri.RawTurnoutOperation());
        config.setEnabled(false);
        for (Component j : config.getComponents()) {
            j.setEnabled(false);
        }
    }
    turnoutOperation.add(config);
    feedback.addItem(new BeanEditItem(turnoutOperation, Bundle.getMessage("FeedbackOperation"), Bundle.getMessage("FeedbackOperationToolTip")));
    feedback.addItem(new BeanEditItem(operationsName, Bundle.getMessage("FeedbackNameSet"), Bundle.getMessage("FeedbackNameSetToolTip")));
    feedback.setSaveItem(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Turnout t = (Turnout) bean;
            String modeName = (String) modeBox.getSelectedItem();
            t.setFeedbackMode(modeName);
            String newName = operationsName.getText();
            if (currentOperation != null && newName != null && !newName.equals("")) {
                if (!currentOperation.rename(newName)) {
                    JOptionPane.showMessageDialog(null, "This name '" + newName + "' is already in use", "Name already in use", JOptionPane.ERROR_MESSAGE);
                } else {
                    automationBox.addItem(newName);
                    automationBox.setSelectedItem(newName);
                }
                t.setTurnoutOperation(null);
                t.setTurnoutOperation(currentOperation);
            }
            config.endConfigure();
            switch(automationBox.getSelectedIndex()) {
                case // Off
                0:
                    t.setInhibitOperation(true);
                    t.setTurnoutOperation(null);
                    break;
                case // Default
                1:
                    t.setInhibitOperation(false);
                    t.setTurnoutOperation(null);
                    break;
                default:
                    // named operation
                    t.setInhibitOperation(false);
                    t.setTurnoutOperation(TurnoutOperationManager.getInstance().getOperation(((String) automationBox.getSelectedItem())));
                    break;
            }
            oldAutomationSelection = ((Turnout) bean).getTurnoutOperation();
            oldModeSelection = ((Turnout) bean).getFeedbackModeName();
            try {
                t.provideFirstFeedbackSensor(sensorFeedBack1ComboBox.getSelectedDisplayName());
            } catch (jmri.JmriException ex) {
                JOptionPane.showMessageDialog(null, ex.toString());
            }
            try {
                t.provideSecondFeedbackSensor(sensorFeedBack2ComboBox.getSelectedDisplayName());
            } catch (jmri.JmriException ex) {
                JOptionPane.showMessageDialog(null, ex.toString());
            }
            if (config.isEnabled()) {
            }
        }
    });
    feedback.setResetItem(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Turnout t = (Turnout) bean;
            sensorFeedBack1ComboBox.setSelectedBean(t.getFirstSensor());
            sensorFeedBack2ComboBox.setSelectedBean(t.getSecondSensor());
            automationBox.removeActionListener(automationSelectionListener);
            jmri.jmrit.beantable.TurnoutTableAction.updateAutomationBox(t, automationBox);
            automationBox.addActionListener(automationSelectionListener);
            t.setFeedbackMode(oldModeSelection);
            updateFeedbackOptions();
        }
    });
    bei.add(feedback);
    return feedback;
}
Also used : ActionEvent(java.awt.event.ActionEvent) JmriBeanComboBox(jmri.util.swing.JmriBeanComboBox) ActionListener(java.awt.event.ActionListener) Component(java.awt.Component) Turnout(jmri.Turnout) AbstractAction(javax.swing.AbstractAction)

Example 9 with JmriBeanComboBox

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

the class AddSignalMastPanel method refreshHeadComboBox.

protected void refreshHeadComboBox() {
    if (!Bundle.getMessage("HeadCtlMast").equals(signalMastDriver.getSelectedItem())) {
        return;
    }
    if (includeUsed.isSelected()) {
        alreadyUsed = new ArrayList<NamedBean>();
    } else {
        List<SignalHead> alreadyUsedHeads = SignalHeadSignalMast.getSignalHeadsUsed();
        alreadyUsed = new ArrayList<NamedBean>();
        for (SignalHead head : alreadyUsedHeads) {
            alreadyUsed.add(head);
        }
    }
    for (JmriBeanComboBox head : headList) {
        head.excludeItems(alreadyUsed);
    }
}
Also used : JmriBeanComboBox(jmri.util.swing.JmriBeanComboBox) NamedBean(jmri.NamedBean) SignalHead(jmri.SignalHead)

Example 10 with JmriBeanComboBox

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

the class AddSignalMastPanel method updateHeads.

void updateHeads() {
    if (!Bundle.getMessage("HeadCtlMast").equals(signalMastDriver.getSelectedItem())) {
        return;
    }
    if (mastBox.getSelectedItem() == null) {
        return;
    }
    int count = map.get(mastBox.getSelectedItem()).intValue();
    headList = new ArrayList<JmriBeanComboBox>(count);
    signalHeadPanel.removeAll();
    signalHeadPanel.setLayout(new jmri.util.javaworld.GridLayout2(count + 1, 1));
    for (int i = 0; i < count; i++) {
        JmriBeanComboBox head = new JmriBeanComboBox(InstanceManager.getDefault(jmri.SignalHeadManager.class));
        head.excludeItems(alreadyUsed);
        headList.add(head);
        signalHeadPanel.add(head);
    }
    signalHeadPanel.add(includeUsed);
}
Also used : JmriBeanComboBox(jmri.util.swing.JmriBeanComboBox)

Aggregations

JmriBeanComboBox (jmri.util.swing.JmriBeanComboBox)12 ActionEvent (java.awt.event.ActionEvent)8 ActionListener (java.awt.event.ActionListener)5 JButton (javax.swing.JButton)5 JLabel (javax.swing.JLabel)5 FlowLayout (java.awt.FlowLayout)4 BoxLayout (javax.swing.BoxLayout)4 JPanel (javax.swing.JPanel)4 JmriJFrame (jmri.util.JmriJFrame)4 Container (java.awt.Container)3 AbstractAction (javax.swing.AbstractAction)3 JTable (javax.swing.JTable)3 TableColumn (javax.swing.table.TableColumn)3 NamedBean (jmri.NamedBean)3 ButtonGroup (javax.swing.ButtonGroup)2 JComboBox (javax.swing.JComboBox)2 JRadioButton (javax.swing.JRadioButton)2 JRootPane (javax.swing.JRootPane)2 JScrollPane (javax.swing.JScrollPane)2 Border (javax.swing.border.Border)2