Example usage for javax.swing BoxLayout PAGE_AXIS

List of usage examples for javax.swing BoxLayout PAGE_AXIS

Introduction

In this page you can find the example usage for javax.swing BoxLayout PAGE_AXIS.

Prototype

int PAGE_AXIS

To view the source code for javax.swing BoxLayout PAGE_AXIS.

Click Source Link

Document

Specifies that components should be laid out in the direction that lines flow across a page as determined by the target container's ComponentOrientation property.

Usage

From source file:net.rptools.maptool.launcher.MapToolLauncher.java

private JPanel buildTroubleshootingPanel() {
    final JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    ActionListener levelChange = new ActionListener() {
        @Override//  w w  w. jav a  2  s.  c  om
        public void actionPerformed(ActionEvent e) {
            Level x = Level.parse(e.getActionCommand());
            if (Level.OFF.equals(x) || Level.INFO.equals(x) || Level.WARNING.equals(x)
                    || Level.SEVERE.equals(x))
                log.setLevel(x);
        }
    };
    JPanel logPanel = new JPanel();
    logPanel.setLayout(new GridLayout(0, 1));
    logPanel.setBorder(new TitledBorder(new LineBorder(Color.BLACK),
            CopiedFromOtherJars.getText("msg.logDetailPanel.border"))); //$NON-NLS-1$
    logPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    ButtonGroup logGroup = new ButtonGroup();
    for (Level type : new Level[] { Level.OFF, Level.INFO, Level.WARNING, Level.SEVERE }) {
        JRadioButton jrb = new JRadioButton(type.toString());
        jrb.setActionCommand(type.toString());
        jrb.addActionListener(levelChange);
        jrb.setBorder(
                BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), jrb.getBorder()));
        logPanel.add(jrb);
        logGroup.add(jrb);
        if (type == Level.WARNING) {
            jrb.setSelected(true);
            log.setLevel(type);
        }
    }
    jcbEnableAssertions.setAlignmentX(Component.LEFT_ALIGNMENT);
    jcbEnableAssertions.setText(CopiedFromOtherJars.getText("msg.info.enableAssertions")); //$NON-NLS-1$
    jcbEnableAssertions.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.enableAssertions")); //$NON-NLS-1$
    jcbEnableAssertions.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                if (!extraArgs.contains(ASSERTIONS_OPTION)) {
                    extraArgs = (ASSERTIONS_OPTION + " " + extraArgs); //$NON-NLS-1$
                }
            } else if (e.getStateChange() == ItemEvent.DESELECTED) {
                extraArgs = extraArgs.replace(ASSERTIONS_OPTION, ""); //$NON-NLS-1$
            }
            extraArgs = extraArgs.trim();
            jtfArgs.setText(extraArgs);
            updateCommand();
        }
    });
    p.add(logPanel, BorderLayout.NORTH);
    Box other = new Box(BoxLayout.PAGE_AXIS);
    other.add(jcbEnableAssertions);
    other.add(Box.createVerticalGlue());
    p.add(other, BorderLayout.CENTER);
    return p;
}

From source file:com.xilinx.kintex7.MainScreen.java

private JPanel testPanelItems() {
    JPanel panel1 = new JPanel();

    JPanel panel = new JPanel();

    panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    panel.add(new JLabel("Data Path-0:"));
    t1_o1 = new JCheckBox("Loopback");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t1_o1.setToolTipText("This loops back software generated traffic at DMA user interface");
    else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV)
        t1_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY");

    t1_o1.setSelected(true);/*from ww w.j av a 2 s . c  om*/
    t1_o1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                t1_o1.setSelected(true);
                return;
            }
            if (t1_o1.isSelected()) {
                // disable others
                test1_option = DriverInfo.ENABLE_LOOPBACK;
                t1_o2.setSelected(false);
                t1_o3.setSelected(false);
            } else {
                if (!t1_o2.isSelected() && !t1_o3.isSelected()) {
                    test1_option = DriverInfo.CHECKER;
                    t1_o2.setSelected(true);
                }
            }
        }
    });
    //b1.setSelected(true);
    t1_o2 = new JCheckBox("HW Checker");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t1_o2.setToolTipText(
                "This enables Checker in hardware at DMA user interface verifying traffic generated by software");
    t1_o2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t1_o2.isSelected()) {
                // disable others
                test1_option = DriverInfo.CHECKER;
                t1_o1.setSelected(false);
                if (t1_o3.isSelected())
                    test1_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t1_o3.isSelected())
                    test1_option = DriverInfo.GENERATOR;
                else {
                    test1_option = DriverInfo.ENABLE_LOOPBACK;
                    t1_o1.setSelected(true);
                }

            }
        }
    });
    t1_o3 = new JCheckBox("HW Generator");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t1_o3.setToolTipText("This enables traffic generator in hardware at the DMA user interface");
    t1_o3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t1_o3.isSelected()) {
                // disable others
                test1_option = DriverInfo.GENERATOR;
                t1_o1.setSelected(false);
                //t1_o2.setSelected(false);
                if (t1_o2.isSelected())
                    test1_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t1_o2.isSelected())
                    test1_option = DriverInfo.CHECKER;
                else {
                    test1_option = DriverInfo.ENABLE_LOOPBACK;
                    t1_o1.setSelected(true);
                }
            }
        }
    });
    //b3.setEnabled(false);
    JPanel ip = new JPanel();
    ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS));
    ip.add(t1_o1);
    ip.add(t1_o2);
    ip.add(t1_o3);
    panel.add(ip);
    panel.add(new JLabel("Packet Size (bytes):"));
    t1_psize = new JTextField("32768", 5);

    panel.add(t1_psize);
    startTest = new JButton("Start");
    startTest.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {

            //Check for led status and start the test
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                if (lstats.ddrCalib == LED_OFF && (lstats.phy0 == LED_ON && lstats.phy1 == LED_ON)) {
                    JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib == LED_OFF && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib == LED_ON && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }

            if (startTest.getText().equals("Start")) {
                int psize = 0;
                dataMismatch0 = errcnt0 = false;
                try {
                    psize = Integer.parseInt(t1_psize.getText());
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (psize < minpkt0 || psize > maxpkt0) {
                    JOptionPane.showMessageDialog(null,
                            "Packet size must be within " + minpkt0 + " to " + maxpkt0 + " bytes", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                di.startTest(0, test1_option, psize);
                // disable components
                t1_o1.setEnabled(false);
                t1_o2.setEnabled(false);
                t1_o3.setEnabled(false);
                t1_psize.setEnabled(false);
                startTest.setText("Stop");
                testStarted = true;
                updateLog("[Test Started for Data Path-0]", logStatus);
            } else if (startTest.getText().equals("Stop")) {
                startTest.setEnabled(false);
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            stopTest1();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                };
                worker.execute();
            }
        }
    });
    panel.add(startTest);
    if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) {
        t1_o1.setSelected(false);
        t1_o2.setSelected(false);
        t1_o3.setSelected(false);
        t1_o1.setEnabled(false);
        t1_o2.setEnabled(false);
        t1_o3.setEnabled(false);
        t1_psize.setEnabled(false);
        t1_psize.setText("");
        startTest.setEnabled(false);
    }
    panel1.add(panel);
    return panel1;
}

From source file:op.care.supervisor.PnlHandover.java

private List<Component> addFilters() {
    List<Component> list = new ArrayList<Component>();

    Pair<DateTime, DateTime> minmax = NReportTools.getMinMax();
    if (minmax != null) {
        final DefaultComboBoxModel yearModel = new DefaultComboBoxModel();
        for (int year = new LocalDate().getYear(); year >= minmax.getFirst().getYear(); year--) {
            yearModel.addElement(year);//from w ww.  j a v a  2 s  .  c  om
        }

        JPanel innerPanel = new JPanel();
        innerPanel.setOpaque(false);
        innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.PAGE_AXIS));
        txtSearch = new JXSearchField(SYSTools.xx("misc.msg.searchphrase"));
        txtSearch.setInstantSearchDelay(100000);
        txtSearch.setFont(SYSConst.ARIAL14);
        txtSearch.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (SYSTools.catchNull(txtSearch.getText()).trim().length() > 3) {
                    SYSFilesTools.print(NReportTools.getReportsAndHandoversAsHTML(
                            NReportTools.getNReports4Handover((Homes) cmbHomes.getSelectedItem(),
                                    txtSearch.getText().trim(),
                                    Integer.parseInt(yearModel.getSelectedItem().toString())),
                            txtSearch.getText().trim(),
                            Integer.parseInt(yearModel.getSelectedItem().toString())), false);
                }
            }
        });
        innerPanel.add(txtSearch);
        JButton btnSearchGeneralReports = GUITools
                .createHyperlinkButton("nursingrecords.handover.searchHandovers", null, null);
        btnSearchGeneralReports.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                List listHandovers = HandoversTools.getBy(
                        Integer.parseInt(yearModel.getSelectedItem().toString()),
                        (Homes) cmbHomes.getSelectedItem());
                SYSFilesTools.print(NReportTools.getReportsAndHandoversAsHTML(listHandovers, "",
                        Integer.parseInt(yearModel.getSelectedItem().toString())), false);
            }
        });
        innerPanel.add(btnSearchGeneralReports);
        yearCombo = new JXComboBox(yearModel);
        yearCombo.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                txtSearch.postActionEvent();
            }
        });

        JPanel myPanel = new JPanel();
        myPanel.setOpaque(false);
        myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.LINE_AXIS));
        myPanel.add(innerPanel);
        myPanel.add(yearCombo);
        list.add(myPanel);
    }

    cmbHomes = new JComboBox();
    cmbHomes.setFont(SYSConst.ARIAL14);
    HomesTools.setComboBox(cmbHomes);
    cmbHomes.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent itemEvent) {
            if (itemEvent.getStateChange() != ItemEvent.SELECTED)
                return;
            reloadDisplay();
        }
    });
    list.add(cmbHomes);

    tbResidentFirst = GUITools.getNiceToggleButton("nursingrecords.handover.residentFirst");
    SYSPropsTools.restoreState("nursingrecords.handover.tbResidentFirst", tbResidentFirst);
    tbResidentFirst.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            SYSPropsTools.storeState("nursingrecords.handover.tbResidentFirst", tbResidentFirst);
            reload();
        }
    });
    tbResidentFirst.setHorizontalAlignment(SwingConstants.LEFT);
    list.add(tbResidentFirst);

    return list;
}

From source file:com.xilinx.kintex7.MainScreen.java

private JPanel testPanelItems1() {
    JPanel panel = new JPanel();
    panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    /*panel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createTitledBorder("Test Parameters-1"),
                BorderFactory.createEmptyBorder()));*/
    float w = (float) ((float) width * 0.4);
    //panel.setPreferredSize(new Dimension((int)w, 100));
    panel.add(new JLabel("Data Path-1:"));
    t2_o1 = new JCheckBox("Loopback");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t2_o1.setToolTipText("This loops back software generated traffic at DMA user interface");
    else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV)
        t2_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY");

    t2_o1.setSelected(true);//ww w  . j  a v  a 2s  .  c o m
    t2_o1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                t2_o1.setSelected(true);
                return;
            }
            if (t2_o1.isSelected()) {
                // disable others
                test2_option = DriverInfo.ENABLE_LOOPBACK;
                t2_o2.setSelected(false);
                t2_o3.setSelected(false);
            } else {
                if (!t2_o2.isSelected() && !t2_o3.isSelected()) {
                    test2_option = DriverInfo.CHECKER;
                    t2_o2.setSelected(true);
                }
            }
        }
    });
    //b1.setSelected(true);
    t2_o2 = new JCheckBox("HW Checker");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t2_o2.setToolTipText(
                "This enables Checker in hardware at DMA user interface verifying traffic generated by software");
    t2_o2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t2_o2.isSelected()) {
                // disable others
                test2_option = DriverInfo.CHECKER;
                t2_o1.setSelected(false);
                //t2_o3.setSelected(false);
                if (t2_o3.isSelected())
                    test2_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t2_o3.isSelected())
                    test2_option = DriverInfo.GENERATOR;
                else {
                    test2_option = DriverInfo.ENABLE_LOOPBACK;
                    t2_o1.setSelected(true);
                }
            }
        }
    });
    //b2.setEnabled(false);
    t2_o3 = new JCheckBox("HW Generator");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t2_o3.setToolTipText("This enables traffic generator in hardware at the DMA user interface");
    t2_o3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t2_o3.isSelected()) {
                // disable others
                test2_option = DriverInfo.GENERATOR;
                t2_o1.setSelected(false);
                //t2_o2.setSelected(false);
                if (t2_o2.isSelected())
                    test2_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t2_o2.isSelected())
                    test2_option = DriverInfo.CHECKER;
                else {
                    test2_option = DriverInfo.ENABLE_LOOPBACK;
                    t2_o1.setSelected(true);
                }
            }
        }
    });
    //b3.setEnabled(false);
    JPanel ip = new JPanel();
    ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS));
    ip.add(t2_o1);
    ip.add(t2_o2);
    ip.add(t2_o3);
    panel.add(ip);
    panel.add(new JLabel("Packet Size (bytes):"));
    t2_psize = new JTextField("32768", 5);
    panel.add(t2_psize);
    stest = new JButton("Start");
    stest.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {

            //Check for led status and start the test
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                if (lstats.ddrCalib == LED_OFF && (lstats.phy0 == LED_ON && lstats.phy1 == LED_ON)) {
                    JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib == LED_OFF && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib == LED_ON && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
            if (stest.getText().equals("Start")) {
                int psize = 0;
                dataMismatch2 = errcnt1 = false;
                try {
                    psize = Integer.parseInt(t2_psize.getText());
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (psize < minpkt1 || psize > maxpkt1) {
                    JOptionPane.showMessageDialog(null,
                            "Packet size must be within " + minpkt1 + " to " + maxpkt1 + " bytes", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                di.startTest(1, test2_option, psize);
                t2_o1.setEnabled(false);
                t2_o2.setEnabled(false);
                t2_o3.setEnabled(false);
                t2_psize.setEnabled(false);
                stest.setText("Stop");
                testStarted1 = true;
                updateLog("[Test Started for Data Path-1]", logStatus);

            } else if (stest.getText().equals("Stop")) {
                // Disable button to avoid multiple clicks
                stest.setEnabled(false);
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            stopTest2();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                };
                worker.execute();
            }
        }
    });
    panel.add(stest);
    if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) {
        t2_o1.setSelected(false);
        t2_o2.setSelected(false);
        t2_o3.setSelected(false);
        t2_o1.setEnabled(false);
        t2_o2.setEnabled(false);
        t2_o3.setEnabled(false);
        t2_psize.setEnabled(false);
        t2_psize.setText("");
        stest.setEnabled(false);
    }
    return panel;
}

From source file:com.xilinx.virtex7.MainScreen.java

private JPanel testPanelItems() {
    //JPanel panel1 = new JPanel();

    JPanel panel = new JPanel();

    panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    panel.add(new JLabel("Data Path-0:"));
    t1_o1 = new JCheckBox("Loopback");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t1_o1.setToolTipText("This loops back software generated traffic in hardware");
    else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV)
        t1_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY");

    t1_o1.setSelected(true);/* w  w w.ja  va  2s. c  o  m*/
    t1_o1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                t1_o1.setSelected(true);
                return;
            }
            if (t1_o1.isSelected()) {
                // disable others
                test1_option = DriverInfo.ENABLE_LOOPBACK;
                t1_o2.setSelected(false);
                t1_o3.setSelected(false);
            } else {
                if (!t1_o2.isSelected() && !t1_o3.isSelected()) {
                    test1_option = DriverInfo.CHECKER;
                    t1_o2.setSelected(true);
                }
            }
        }
    });
    //b1.setSelected(true);
    t1_o2 = new JCheckBox("HW Checker");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t1_o2.setToolTipText("This enables Checker in hardware verifying traffic generated by software");
    t1_o2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t1_o2.isSelected()) {
                // disable others
                test1_option = DriverInfo.CHECKER;
                t1_o1.setSelected(false);
                //t1_o3.setSelected(false);
                if (t1_o3.isSelected())
                    test1_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t1_o3.isSelected())
                    test1_option = DriverInfo.GENERATOR;
                else {
                    test1_option = DriverInfo.ENABLE_LOOPBACK;
                    t1_o1.setSelected(true);
                }

            }
        }
    });
    //b2.setEnabled(false);
    t1_o3 = new JCheckBox("HW Generator");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t1_o3.setToolTipText("This enables traffic generator in hardware");
    t1_o3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t1_o3.isSelected()) {
                // disable others
                test1_option = DriverInfo.GENERATOR;
                t1_o1.setSelected(false);
                //t1_o2.setSelected(false);
                if (t1_o2.isSelected())
                    test1_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t1_o2.isSelected())
                    test1_option = DriverInfo.CHECKER;
                else {
                    test1_option = DriverInfo.ENABLE_LOOPBACK;
                    t1_o1.setSelected(true);
                }
            }
        }
    });
    //b3.setEnabled(false);
    JPanel ip = new JPanel();
    ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS));
    ip.add(t1_o1);
    ip.add(t1_o2);
    ip.add(t1_o3);
    panel.add(ip);
    panel.add(new JLabel("Packet Size (bytes):"));
    t1_psize = new JTextField("32768", 5);

    panel.add(t1_psize);
    startTest = new JButton("Start");
    startTest.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            //Check for led status and start the test
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy0 == LED_ON && lstats.phy1 == LED_ON)) {
                    JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_ON && lstats.ddrCalib2 == LED_ON
                        && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }

            if (startTest.getText().equals("Start")) {
                // checking condition for DDR3 SODIMM
                if (t1_o1.isSelected() && !(lstats.ddrCalib1 == LED_ON && lstats.ddrCalib2 == LED_ON)) {
                    if (lstats.ddrCalib1 == LED_OFF || lstats.ddrCalib2 == LED_OFF) {
                        JOptionPane.showMessageDialog(null,
                                "DDR3 SODIMM is not calibrated. Test cannot be started", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    return;
                } else if (t1_o2.isSelected() && (lstats.ddrCalib1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 SODIMM-A is not calibrated. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (t1_o3.isSelected() && (lstats.ddrCalib2 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 SODIMM-B is not calibrated. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                int psize = 0;
                dataMismatch0 = errcnt0 = false;
                try {
                    psize = Integer.parseInt(t1_psize.getText());
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (psize < minpkt0 || psize > maxpkt0) {
                    JOptionPane.showMessageDialog(null,
                            "Packet size must be within " + minpkt0 + " to " + maxpkt0 + " bytes", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                di.startTest(0, test1_option, psize);
                // disable components
                t1_o1.setEnabled(false);
                t1_o2.setEnabled(false);
                t1_o3.setEnabled(false);
                t1_psize.setEnabled(false);
                startTest.setText("Stop");
                testStarted = true;
                updateLog("[Test Started for Data Path-0]", logStatus);
            } else if (startTest.getText().equals("Stop")) {
                startTest.setEnabled(false);
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            stopTest1();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                };
                worker.execute();
            }
        }
    });
    panel.add(startTest);
    if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) {
        t1_o1.setSelected(false);
        t1_o2.setSelected(false);
        t1_o3.setSelected(false);
        t1_o1.setEnabled(false);
        t1_o2.setEnabled(false);
        t1_o3.setEnabled(false);
        t1_psize.setEnabled(false);
        t1_psize.setText("");
        startTest.setEnabled(false);
    }
    //panel1.add(panel);
    return panel;
}

From source file:op.controlling.PnlControlling.java

private java.util.List<Component> addFilters() {
    java.util.List<Component> list = new ArrayList<Component>();

    if (tabMain.getSelectedIndex() == TAB_QMSPLAN) {

        final JToggleButton tbClosedOnes2 = GUITools
                .getNiceToggleButton(SYSTools.xx("misc.filters.showclosed"));

        ArrayList<Commontags> listTags = CommontagsTools.getAllUsedInQMSPlans(true);
        if (!listTags.isEmpty()) {

            JPanel pnlTags = new JPanel();
            pnlTags.setLayout(new BoxLayout(pnlTags, BoxLayout.PAGE_AXIS));
            pnlTags.setOpaque(false);/*ww  w  .j  a  v  a  2s .c  o m*/

            final JButton btnReset = GUITools.createHyperlinkButton("misc.commands.resetFilter",
                    SYSConst.icon16tagPurpleDelete4, new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {

                            //                        init = true;
                            //                        tbClosedOnes2.setSelected(false);
                            //                        init = false;

                            //                        pnlQMSPlan.reload();
                            //
                            //                        pnlQMSPlan.cleanup();
                            //                        pnlQMSPlan = new PnlQMSPlan(null);
                            //                        tabMain.setComponentAt(TAB_QMSPLAN, pnlQMSPlan);

                            filterTag = null;
                            tbClosedOnes2.setSelected(false);

                        }
                    });
            pnlTags.add(btnReset, RiverLayout.LEFT);

            for (final Commontags commontag : listTags) {

                final JButton btnTag = GUITools.createHyperlinkButton(commontag.getText(),
                        SYSConst.icon16tagPurple, new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent e) {
                                //                            init = true;
                                //                            tbClosedOnes2.setSelected(true);
                                //                            init = false;
                                //
                                //                            pnlQMSPlan.cleanup();
                                //                            pnlQMSPlan = new PnlQMSPlan(null);
                                //                            tabMain.setComponentAt(TAB_QMSPLAN, pnlQMSPlan);
                                //                            //TODO: mark the filter when it is used. maybe a yellow background

                                filterTag = commontag;
                                tbClosedOnes2.setSelected(true);
                            }
                        });
                pnlTags.add(btnTag);

            }
            list.add(pnlTags);
        }

        tbClosedOnes2.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent itemEvent) {
                //                    if (init) return;
                pnlQMSPlan.reload(filterTag, itemEvent.getStateChange() == ItemEvent.SELECTED);
            }
        });
        list.add(tbClosedOnes2);
        tbClosedOnes2.setHorizontalAlignment(SwingConstants.LEFT);

    }

    return list;
}

From source file:com.xilinx.virtex7.MainScreen.java

private JPanel testPanelItems1() {
    JPanel panel = new JPanel();
    panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    /*panel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createTitledBorder("Test Parameters-1"),
                BorderFactory.createEmptyBorder()));*/
    float w = (float) ((float) width * 0.4);
    //panel.setPreferredSize(new Dimension((int)w, 100));
    panel.add(new JLabel("Data Path-1:"));
    t2_o1 = new JCheckBox("Loopback");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t2_o1.setToolTipText("This loops back software generated traffic at DMA user interface");
    else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV)
        t2_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY");

    t2_o1.setSelected(true);//from w w w. j  av  a  2  s . c o m
    t2_o1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                t2_o1.setSelected(true);
                return;
            }
            if (t2_o1.isSelected()) {
                // disable others
                test2_option = DriverInfo.ENABLE_LOOPBACK;
                t2_o2.setSelected(false);
                t2_o3.setSelected(false);
            } else {
                if (!t2_o2.isSelected() && !t2_o3.isSelected()) {
                    test2_option = DriverInfo.CHECKER;
                    t2_o2.setSelected(true);
                }
            }
        }
    });
    //b1.setSelected(true);
    t2_o2 = new JCheckBox("HW Checker");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t2_o2.setToolTipText(
                "This enables Checker in hardware at DMA user interface verifying traffic generated by software");
    t2_o2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t2_o2.isSelected()) {
                // disable others
                test2_option = DriverInfo.CHECKER;
                t2_o1.setSelected(false);
                //t2_o3.setSelected(false);
                if (t2_o3.isSelected())
                    test2_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t2_o3.isSelected())
                    test2_option = DriverInfo.GENERATOR;
                else {
                    test2_option = DriverInfo.ENABLE_LOOPBACK;
                    t2_o1.setSelected(true);
                }
            }
        }
    });
    //b2.setEnabled(false);
    t2_o3 = new JCheckBox("HW Generator");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t2_o3.setToolTipText("This enables traffic generator in hardware at the DMA user interface");
    t2_o3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t2_o3.isSelected()) {
                // disable others
                test2_option = DriverInfo.GENERATOR;
                t2_o1.setSelected(false);
                //t2_o2.setSelected(false);
                if (t2_o2.isSelected())
                    test2_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t2_o2.isSelected())
                    test2_option = DriverInfo.CHECKER;
                else {
                    test2_option = DriverInfo.ENABLE_LOOPBACK;
                    t2_o1.setSelected(true);
                }
            }
        }
    });
    //b3.setEnabled(false);
    JPanel ip = new JPanel();
    ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS));
    ip.add(t2_o1);
    ip.add(t2_o2);
    ip.add(t2_o3);
    panel.add(ip);
    panel.add(new JLabel("Packet Size (bytes):"));
    t2_psize = new JTextField("32768", 5);
    panel.add(t2_psize);
    stest = new JButton("Start");
    if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {

    } else
        stest.setEnabled(false);
    stest.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            //Check for led status and start the test
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy0 == LED_ON && lstats.phy1 == LED_ON)) {
                    JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_ON && lstats.ddrCalib2 == LED_ON
                        && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }

            if (stest.getText().equals("Start")) {
                int psize = 0;
                dataMismatch2 = errcnt1 = false;
                try {
                    psize = Integer.parseInt(t2_psize.getText());
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (psize < minpkt1 || psize > maxpkt1) {
                    JOptionPane.showMessageDialog(null,
                            "Packet size must be within " + minpkt1 + " to " + maxpkt1 + " bytes", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                di.startTest(1, test2_option, psize);
                t2_o1.setEnabled(false);
                t2_o2.setEnabled(false);
                t2_o3.setEnabled(false);
                t2_psize.setEnabled(false);
                stest.setText("Stop");
                testStarted1 = true;
                updateLog("[Test Started for Data Path-1]", logStatus);

            } else if (stest.getText().equals("Stop")) {
                // Disable button to avoid multiple clicks
                stest.setEnabled(false);
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            stopTest2();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                };
                worker.execute();
            }
        }
    });
    panel.add(stest);
    if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) {
        t2_o1.setSelected(false);
        t2_o2.setSelected(false);
        t2_o3.setSelected(false);
        t2_o1.setEnabled(false);
        t2_o2.setEnabled(false);
        t2_o3.setEnabled(false);
        t2_psize.setEnabled(false);
        t2_psize.setText("");
        stest.setEnabled(false);
    }
    return panel;
}

From source file:com.xilinx.virtex7.MainScreen.java

private JPanel testPanelItems2() {
    JPanel panel = new JPanel();
    panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    /*panel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createTitledBorder("Test Parameters-1"),
                BorderFactory.createEmptyBorder()));*/
    float w = (float) ((float) width * 0.4);
    //panel.setPreferredSize(new Dimension((int)w, 100));
    panel.add(new JLabel("Data Path-2:"));
    t3_o1 = new JCheckBox("Loopback");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t3_o1.setToolTipText("This loops back software generated traffic at DMA user interface");
    else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV)
        t3_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY");

    t3_o1.setSelected(true);//from ww w. j  ava2 s. co  m
    t3_o1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                t3_o1.setSelected(true);
                return;
            }
            if (t3_o1.isSelected()) {
                // disable others
                test3_option = DriverInfo.ENABLE_LOOPBACK;
                t3_o2.setSelected(false);
                t3_o3.setSelected(false);
            } else {
                if (!t3_o2.isSelected() && !t3_o3.isSelected()) {
                    test3_option = DriverInfo.CHECKER;
                    t3_o2.setSelected(true);
                }
            }
        }
    });
    //b1.setSelected(true);
    t3_o2 = new JCheckBox("HW Checker");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t3_o2.setToolTipText(
                "This enables Checker in hardware at DMA user interface verifying traffic generated by software");
    t3_o2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t3_o2.isSelected()) {
                // disable others
                test3_option = DriverInfo.CHECKER;
                t3_o1.setSelected(false);
                //t2_o3.setSelected(false);
                if (t3_o3.isSelected())
                    test3_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t3_o3.isSelected())
                    test3_option = DriverInfo.GENERATOR;
                else {
                    test3_option = DriverInfo.ENABLE_LOOPBACK;
                    t3_o1.setSelected(true);
                }
            }
        }
    });
    //b2.setEnabled(false);
    t3_o3 = new JCheckBox("HW Generator");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t3_o3.setToolTipText("This enables traffic generator in hardware at the DMA user interface");
    t3_o3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t3_o3.isSelected()) {
                // disable others
                test3_option = DriverInfo.GENERATOR;
                t3_o1.setSelected(false);
                //t2_o2.setSelected(false);
                if (t3_o2.isSelected())
                    test3_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t3_o2.isSelected())
                    test3_option = DriverInfo.CHECKER;
                else {
                    test3_option = DriverInfo.ENABLE_LOOPBACK;
                    t3_o1.setSelected(true);
                }
            }
        }
    });
    //b3.setEnabled(false);
    JPanel ip = new JPanel();
    ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS));
    ip.add(t3_o1);
    ip.add(t3_o2);
    ip.add(t3_o3);
    panel.add(ip);
    panel.add(new JLabel("Packet Size (bytes):"));
    t3_psize = new JTextField("32768", 5);
    panel.add(t3_psize);
    s3test = new JButton("Start");
    //s3test.setEnabled(false);
    s3test.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            //Check for led status and start the test
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy2 == LED_ON && lstats.phy3 == LED_ON)) {
                    JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy2 == LED_OFF || lstats.phy3 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_ON && lstats.ddrCalib2 == LED_ON
                        && (lstats.phy2 == LED_OFF || lstats.phy3 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }

            if (s3test.getText().equals("Start")) {
                int psize = 0;
                dataMismatch4 = errcnt2 = false;
                try {
                    psize = Integer.parseInt(t3_psize.getText());
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (psize < minpkt1 || psize > maxpkt1) {
                    JOptionPane.showMessageDialog(null,
                            "Packet size must be within " + minpkt1 + " to " + maxpkt1 + " bytes", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                di.startTest(2, test3_option, psize);
                t3_o1.setEnabled(false);
                t3_o2.setEnabled(false);
                t3_o3.setEnabled(false);
                t3_psize.setEnabled(false);
                s3test.setText("Stop");
                testStarted2 = true;
                updateLog("[Test Started for Data Path-2]", logStatus);

            } else if (s3test.getText().equals("Stop")) {
                // Disable button to avoid multiple clicks
                s3test.setEnabled(false);
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            stopTest3();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                };
                worker.execute();
            }
        }
    });
    panel.add(s3test);
    if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) {
        t3_o1.setSelected(false);
        t3_o2.setSelected(false);
        t3_o3.setSelected(false);
        t3_o1.setEnabled(false);
        t3_o2.setEnabled(false);
        t3_o3.setEnabled(false);
        t3_psize.setEnabled(false);
        t3_psize.setText("");
        s3test.setEnabled(false);
    }
    return panel;
}

From source file:com.xilinx.virtex7.MainScreen.java

private JPanel testPanelItems3() {
    JPanel panel = new JPanel();
    panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    /*panel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createTitledBorder("Test Parameters-1"),
                BorderFactory.createEmptyBorder()));*/
    float w = (float) ((float) width * 0.4);
    //panel.setPreferredSize(new Dimension((int)w, 100));
    panel.add(new JLabel("Data Path-3:"));
    t4_o1 = new JCheckBox("Loopback");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t4_o1.setToolTipText("This loops back software generated traffic at DMA user interface");
    else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV)
        t4_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY");

    t4_o1.setSelected(true);//from   www .j a  v  a 2s . c o  m
    t4_o1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                t4_o1.setSelected(true);
                return;
            }
            if (t4_o1.isSelected()) {
                // disable others
                test4_option = DriverInfo.ENABLE_LOOPBACK;
                t4_o2.setSelected(false);
                t4_o3.setSelected(false);
            } else {
                if (!t4_o2.isSelected() && !t4_o3.isSelected()) {
                    test4_option = DriverInfo.CHECKER;
                    t4_o2.setSelected(true);
                }
            }
        }
    });
    //b1.setSelected(true);
    t4_o2 = new JCheckBox("HW Checker");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t4_o2.setToolTipText(
                "This enables Checker in hardware at DMA user interface verifying traffic generated by software");
    t4_o2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t4_o2.isSelected()) {
                // disable others
                test4_option = DriverInfo.CHECKER;
                t4_o1.setSelected(false);
                //t2_o3.setSelected(false);
                if (t4_o3.isSelected())
                    test4_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t4_o3.isSelected())
                    test4_option = DriverInfo.GENERATOR;
                else {
                    test4_option = DriverInfo.ENABLE_LOOPBACK;
                    t4_o1.setSelected(true);
                }
            }
        }
    });
    //b2.setEnabled(false);
    t4_o3 = new JCheckBox("HW Generator");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t4_o3.setToolTipText("This enables traffic generator in hardware at the DMA user interface");
    t4_o3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t4_o3.isSelected()) {
                // disable others
                test4_option = DriverInfo.GENERATOR;
                t4_o1.setSelected(false);
                //t2_o2.setSelected(false);
                if (t4_o2.isSelected())
                    test4_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t4_o2.isSelected())
                    test4_option = DriverInfo.CHECKER;
                else {
                    test4_option = DriverInfo.ENABLE_LOOPBACK;
                    t4_o1.setSelected(true);
                }
            }
        }
    });
    //b3.setEnabled(false);
    JPanel ip = new JPanel();
    ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS));
    ip.add(t4_o1);
    ip.add(t4_o2);
    ip.add(t4_o3);
    panel.add(ip);
    panel.add(new JLabel("Packet Size (bytes):"));
    t4_psize = new JTextField("32768", 5);
    panel.add(t4_psize);
    s4test = new JButton("Start");
    if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {

    } else
        stest.setEnabled(false);
    s4test.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            //Check for led status and start the test
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy2 == LED_ON && lstats.phy3 == LED_ON)) {
                    JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy2 == LED_OFF || lstats.phy3 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_ON && lstats.ddrCalib2 == LED_ON
                        && (lstats.phy2 == LED_OFF || lstats.phy3 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }

            if (s4test.getText().equals("Start")) {
                int psize = 0;
                dataMismatch6 = errcnt3 = false;
                try {
                    psize = Integer.parseInt(t4_psize.getText());
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (psize < minpkt1 || psize > maxpkt1) {
                    JOptionPane.showMessageDialog(null,
                            "Packet size must be within " + minpkt1 + " to " + maxpkt1 + " bytes", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                di.startTest(3, test4_option, psize);
                t4_o1.setEnabled(false);
                t4_o2.setEnabled(false);
                t4_o3.setEnabled(false);
                t4_o2.setEnabled(false);
                t4_psize.setEnabled(false);
                s4test.setText("Stop");
                testStarted3 = true;
                updateLog("[Test Started for Data Path-3]", logStatus);

            } else if (s4test.getText().equals("Stop")) {
                // Disable button to avoid multiple clicks
                s4test.setEnabled(false);
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            stopTest4();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                };
                worker.execute();
            }
        }
    });
    panel.add(s4test);
    if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) {
        t4_o1.setSelected(false);
        t4_o2.setSelected(false);
        t4_o3.setSelected(false);
        t4_o1.setEnabled(false);
        t4_o2.setEnabled(false);
        t4_o3.setEnabled(false);
        t4_psize.setEnabled(false);
        t4_psize.setText("");
        s4test.setEnabled(false);
    }
    return panel;
}