Search in sources :

Example 1 with GridLayout2

use of jmri.util.javaworld.GridLayout2 in project JMRI by JMRI.

the class ManagerDefaultsConfigPane method reloadConnections.

void reloadConnections(List<SystemConnectionMemo> connList) {
    log.debug(" reloadConnections");
    ManagerDefaultSelector manager = InstanceManager.getDefault(ManagerDefaultSelector.class);
    matrix.setLayout(new GridLayout2(connList.size() + 1, manager.knownManagers.length + 1));
    matrix.add(new JLabel(""));
    for (ManagerDefaultSelector.Item item : manager.knownManagers) {
        matrix.add(new JLabel(item.typeName));
    }
    groups = new ButtonGroup[manager.knownManagers.length];
    for (int i = 0; i < manager.knownManagers.length; i++) {
        groups[i] = new ButtonGroup();
    }
    boolean[] selected = new boolean[manager.knownManagers.length];
    for (int x = 0; x < connList.size(); x++) {
        // up to down
        jmri.jmrix.SystemConnectionMemo memo = connList.get(x);
        String name = memo.getUserName();
        matrix.add(new JLabel(name));
        int i = 0;
        for (ManagerDefaultSelector.Item item : manager.knownManagers) {
            // left to right
            if (memo.provides(item.managerClass)) {
                JRadioButton r = new SelectionButton(name, item.managerClass, this);
                matrix.add(r);
                groups[i].add(r);
                if (!selected[i] && manager.getDefault(item.managerClass) == null) {
                    r.setSelected(true);
                    selected[i] = true;
                }
            } else {
                // leave a blank
                JRadioButton r = new JRadioButton();
                r.setEnabled(false);
                matrix.add(r);
            }
            //we need to increment 'i' as we are going onto the next group even if we added a blank button
            i++;
        }
    }
    revalidate();
}
Also used : ManagerDefaultSelector(jmri.managers.ManagerDefaultSelector) JRadioButton(javax.swing.JRadioButton) GridLayout2(jmri.util.javaworld.GridLayout2) ButtonGroup(javax.swing.ButtonGroup) SystemConnectionMemo(jmri.jmrix.SystemConnectionMemo) JLabel(javax.swing.JLabel)

Example 2 with GridLayout2

use of jmri.util.javaworld.GridLayout2 in project JMRI by JMRI.

the class OpenLcbCanSendPane method initComponents.

@Override
public void initComponents(CanSystemConnectionMemo memo) {
    super.initComponents(memo);
    iface = memo.get(OlcbInterface.class);
    actions = new ClientActions(iface);
    tc = memo.getTrafficController();
    tc.addCanListener(this);
    connection = memo.get(org.openlcb.Connection.class);
    srcNodeID = memo.get(org.openlcb.NodeID.class);
    aliasMap = memo.get(org.openlcb.can.AliasMap.class);
    // register request for notification
    Connection.ConnectionListener cl = new Connection.ConnectionListener() {

        @Override
        public void connectionActive(Connection c) {
            log.debug("connection active");
            // load the alias field
            srcAliasField.setText(Integer.toHexString(aliasMap.getAlias(srcNodeID)));
        }
    };
    connection.registerStartNotification(cl);
    mcs = memo.get(MemoryConfigurationService.class);
    store = memo.get(MimicNodeStore.class);
    nodeSelector = new NodeSelector(store);
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    // handle single-packet part
    {
        JPanel pane1 = new JPanel();
        pane1.setLayout(new BoxLayout(pane1, BoxLayout.Y_AXIS));
        jLabel1.setText("Single Frame:  (Raw input format is [123] 12 34 56) ");
        jLabel1.setVisible(true);
        sendButton.setText("Send");
        sendButton.setVisible(true);
        sendButton.setToolTipText("Send frame");
        packetTextField.setToolTipText("Frame as hex pairs, e.g. 82 7D; standard header in (), extended in []");
        pane1.add(jLabel1);
        pane1.add(packetTextField);
        pane1.add(sendButton);
        pane1.add(Box.createVerticalGlue());
        sendButton.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                sendButtonActionPerformed(e);
            }
        });
        add(pane1);
    }
    add(new JSeparator());
    // Configure the sequence
    add(new JLabel("Send sequence of frames:"));
    JPanel pane2 = new JPanel();
    pane2.setLayout(new GridLayout2(MAXSEQUENCE + 2, 4));
    pane2.add(new JLabel(""));
    pane2.add(new JLabel("Send"));
    pane2.add(new JLabel("packet"));
    pane2.add(new JLabel("wait (msec)"));
    for (int i = 0; i < MAXSEQUENCE; i++) {
        pane2.add(new JLabel(Integer.toString(i + 1)));
        mUseField[i] = new JCheckBox();
        mPacketField[i] = new JTextField(10);
        mDelayField[i] = new JTextField(10);
        pane2.add(mUseField[i]);
        pane2.add(mPacketField[i]);
        pane2.add(mDelayField[i]);
    }
    // starts a new row in layout
    pane2.add(mRunButton);
    add(pane2);
    mRunButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            runButtonActionPerformed(e);
        }
    });
    // special packet forms
    add(new JSeparator());
    add(new JLabel("Send special frame:"));
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    pane2.add(new JLabel("Src Node alias:"));
    pane2.add(srcAliasField);
    add(pane2);
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    JButton b;
    b = new JButton("Send CIM");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendCimPerformed(e);
        }
    });
    pane2.add(b);
    // send OpenLCB messages
    add(new JSeparator());
    add(addLineLabel("Send OpenLCB global message:"));
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    b = new JButton("Send Verify Nodes Global");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendVerifyNodeGlobal(e);
        }
    });
    pane2.add(b);
    b = new JButton("Send Verify Node Global with NodeID");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendVerifyNodeGlobalID(e);
        }
    });
    pane2.add(b);
    add(new JSeparator());
    add(addLineLabel("Send OpenLCB event message:"));
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    b = new JButton("Send Request Consumers");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendReqConsumers(e);
        }
    });
    pane2.add(b);
    b = new JButton("Send Request Producers");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendReqProducers(e);
        }
    });
    pane2.add(b);
    b = new JButton("Send Event Produced");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendEventPerformed(e);
        }
    });
    pane2.add(b);
    pane2.add(new JLabel("Event ID (8 bytes):"));
    pane2.add(sendEventField);
    add(new JSeparator());
    add(addLineLabel("Send OpenLCB addressed message to:", nodeSelector));
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    b = new JButton("Send Request Events");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendRequestEvents(e);
        }
    });
    pane2.add(b);
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    b = new JButton("Send Datagram");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendDatagramPerformed(e);
        }
    });
    pane2.add(b);
    pane2.add(new JLabel("Contents: "));
    pane2.add(datagramContentsField);
    b = new JButton("Send Datagram Reply");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            sendDatagramReply(e);
        }
    });
    pane2.add(b);
    // send OpenLCB Configuration message
    add(new JSeparator());
    add(addLineLabel("Send OpenLCB Configuration Command:"));
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    pane2.add(new JLabel("Memory Address: "));
    pane2.add(configAddressField);
    pane2.add(new JLabel("Address Space: "));
    pane2.add(addrSpace);
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    pane2.add(new JLabel("Byte Count: "));
    pane2.add(configNumberField);
    b = new JButton("Read");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            readPerformed(e);
        }
    });
    pane2.add(b);
    pane2.add(new JLabel("Data: "));
    pane2.add(readDataField);
    pane2 = new JPanel();
    pane2.setLayout(new FlowLayout());
    add(pane2);
    b = new JButton("Write");
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            writePerformed(e);
        }
    });
    pane2.add(b);
    pane2.add(new JLabel("Data: "));
    // NOI18N
    writeDataField.setText("00 00");
    pane2.add(writeDataField);
    b = new JButton("Open CDI Config Tool");
    add(b);
    b.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            openCdiPane();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) AliasMap(org.openlcb.can.AliasMap) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) NodeID(org.openlcb.NodeID) MimicNodeStore(org.openlcb.MimicNodeStore) GridLayout2(jmri.util.javaworld.GridLayout2) Connection(org.openlcb.Connection) JLabel(javax.swing.JLabel) OlcbInterface(org.openlcb.OlcbInterface) JCheckBox(javax.swing.JCheckBox) MemoryConfigurationService(org.openlcb.implementations.MemoryConfigurationService) NodeSelector(org.openlcb.swing.NodeSelector) ClientActions(jmri.jmrix.openlcb.swing.ClientActions)

Aggregations

JLabel (javax.swing.JLabel)2 GridLayout2 (jmri.util.javaworld.GridLayout2)2 FlowLayout (java.awt.FlowLayout)1 BoxLayout (javax.swing.BoxLayout)1 ButtonGroup (javax.swing.ButtonGroup)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JPanel (javax.swing.JPanel)1 JRadioButton (javax.swing.JRadioButton)1 JSeparator (javax.swing.JSeparator)1 JTextField (javax.swing.JTextField)1 SystemConnectionMemo (jmri.jmrix.SystemConnectionMemo)1 ClientActions (jmri.jmrix.openlcb.swing.ClientActions)1 ManagerDefaultSelector (jmri.managers.ManagerDefaultSelector)1 Connection (org.openlcb.Connection)1 MimicNodeStore (org.openlcb.MimicNodeStore)1 NodeID (org.openlcb.NodeID)1 OlcbInterface (org.openlcb.OlcbInterface)1 AliasMap (org.openlcb.can.AliasMap)1 MemoryConfigurationService (org.openlcb.implementations.MemoryConfigurationService)1