FileDocCategorySizeDatePackage
ResultsPanel.javaAPI DocGlassfish v2 API29974Fri May 04 22:33:26 BST 2007com.sun.enterprise.tools.verifier.gui

ResultsPanel

public class ResultsPanel extends JPanel implements com.sun.enterprise.tools.verifier.VerifierEventsListener

Fields Summary
JTable
table
DefaultTableModel
tableModel
JScrollPane
tableScrollPane
JScrollPane
textScrollPane
JTextArea
detailText
Vector
details
private static Vector
passResults
private static Vector
failResults
private static Vector
errorResults
private static Vector
warnResults
private static Vector
naResults
private static Vector
notImplementedResults
private static Vector
notRunResults
private static Vector
defaultResults
static com.sun.enterprise.util.LocalStringManagerImpl
smh
final String[]
columnNames
final String
errStr
final String
errStr1
Constructors Summary
public ResultsPanel()

 // NOI18N
    

      

        setLayout(new BorderLayout());
        setBorder(
                BorderFactory.createTitledBorder(
                        BorderFactory.createLineBorder(Color.black),
                        (smh.getLocalString(
                                "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".ResultsPanelLabel", // NOI18N
                                "Results: (Click on Item to show test Details below)")))); // NOI18N

        // 508 compliance
        this.getAccessibleContext().setAccessibleName(
                smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".panelName", // NOI18N
                        "Panel")); // NOI18N
        this.getAccessibleContext().setAccessibleDescription(
                smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".PanelDesc", // NOI18N
                        "This is a panel")); // NOI18N

        CheckMgr.addVerifierEventsListener(this);

        // set up result table
        tableModel = new DefaultTableModel(columnNames, 0);
        table = new JTable(tableModel);
        // 508 for JTable
        table.getAccessibleContext().setAccessibleName(
                smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".tableName", // NOI18N
                        "Table")); // NOI18N
        table.getAccessibleContext().setAccessibleDescription(
                smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ControlPanel" + // NOI18N
                ".tableDesc", // NOI18N
                        "This is a table of items")); // NOI18N
        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        tableScrollPane = new JScrollPane(table);
        // 508 for JScrollPane
        tableScrollPane.getAccessibleContext().setAccessibleName(
                smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".scrName1", // NOI18N
                        "Scroll Pane")); // NOI18N
        tableScrollPane.getAccessibleContext().setAccessibleDescription(
                smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ControlPanel" + // NOI18N
                ".scrDesc1", // NOI18N
                        "This is a scroll pane that helps to scroll the list")); // NOI18N
        sizeTableColumns();
        // make the cells uneditable
        JTextField field = new JTextField();
        // 508 for JTextField
        field.getAccessibleContext().setAccessibleName(
                smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".fielsName", // NOI18N
                        "Text Field")); // NOI18N
        field.getAccessibleContext().setAccessibleDescription(
                smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ControlPanel" + // NOI18N
                ".fieldDesc", // NOI18N
                        "This is a text field")); // NOI18N
        table.setDefaultEditor(Object.class, new DefaultCellEditor(field) {
            public boolean isCellEditable(EventObject anEvent) {
                return false;
            }
        });
        // add action listener to table to show details
        table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    if (table.getSelectionModel().isSelectedIndex(
                            e.getLastIndex())) {
                        setDetailText(
                                (String) details.elementAt(e.getLastIndex()));
                    } else if (table.getSelectionModel().isSelectedIndex(
                            e.getFirstIndex())) {
                        setDetailText(
                                (String) details.elementAt(e.getFirstIndex()));
                    }
                }
            }
        });

        // create detail text area
        detailText = new JTextArea(4, 50);
        // 508 for JTextArea
        detailText.getAccessibleContext().setAccessibleName(
                smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".areaName", // NOI18N
                        "Text Area")); // NOI18N
        detailText.getAccessibleContext().setAccessibleDescription(
                smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ControlPanel" + // NOI18N
                ".areaDesc", // NOI18N
                        "This is a text area")); // NOI18N
        detailText.setEditable(false);
        textScrollPane = new JScrollPane(detailText);
        // 508 for JScrollPane
        textScrollPane.getAccessibleContext().setAccessibleName(
                smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".scrName2", // NOI18N
                        "Scroll Pane")); // NOI18N
        textScrollPane.getAccessibleContext().setAccessibleDescription(
                smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ControlPanel" + // NOI18N
                ".scrDesc2", // NOI18N
                        "This is a scroll pane that helps to scroll the list")); // NOI18N
        textScrollPane.setBorder(
                BorderFactory.createTitledBorder(
                        BorderFactory.createEmptyBorder(),
                        (smh.getLocalString(
                                "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".DetailsPanelLabel", // NOI18N
                                "Details:")))); // NOI18N

        //add the components to the panel
        add("Center", tableScrollPane); // NOI18N
        add("South", textScrollPane); // NOI18N
	
        // Register a listener for the report level radio buttons.
        // to allow post-processing filtering
        RadioListener myListener = new RadioListener();
        ControlPanel.addRadioButtonListener((ActionListener) myListener);
    
Methods Summary
public voidaddDetailText(java.lang.String details)

        detailText.append(details);
    
voidaddError(java.util.logging.LogRecord r)

        saveErrorResultsForDisplay(r);
        details.add(r.getMessage() + "\n" + r.getThrown().getMessage()); // NOI18N
        // create a table row for this result
        Object[] row = {r.getLoggerName(), errStr, errStr1};
        tableModel.addRow(row);
        table.sizeColumnsToFit(0);
    
public voidallTestsFinished(java.util.EventObject e)

        // do nothing for now
    
public voidclearOldResults()

        passResults = new Vector<Result>();
        failResults = new Vector<Result>();
        errorResults = new Vector<LogRecord>();
        warnResults = new Vector<Result>();
        naResults = new Vector<Result>();
        notImplementedResults = new Vector<Result>();
        notRunResults = new Vector<Result>();
        defaultResults = new Vector<Result>();
    
public voidclearResults()

        //clear the table
        tableModel = new DefaultTableModel(columnNames, 0);
        table.setModel(tableModel);
        sizeTableColumns();
        //clear the detail text
        setDetailText("");
        //clear the details Vector
        details = new Vector<String>();
    
private java.util.VectorgetDefaultResultsForDisplay()

        return defaultResults;
    
private java.util.VectorgetErrorResultsForDisplay()

        return errorResults;
    
private java.util.VectorgetFailResultsForDisplay()

        return failResults;
    
private java.util.VectorgetNaResultsForDisplay()

        return naResults;
    
private java.util.VectorgetNotImplementedResultsForDisplay()

        return notImplementedResults;
    
private java.util.VectorgetNotRunResultsForDisplay()

        return notRunResults;
    
private java.util.VectorgetPassResultsForDisplay()

        return passResults;
    
private java.util.VectorgetWarnResultsForDisplay()

        return warnResults;
    
private voidsaveDefaultResultsForDisplay(com.sun.enterprise.tools.verifier.Result r)

        defaultResults.addElement(r);
    
private voidsaveErrorResultsForDisplay(java.util.logging.LogRecord r)

        errorResults.addElement(r);
    
private voidsaveFailResultsForDisplay(com.sun.enterprise.tools.verifier.Result r)

        failResults.addElement(r);
    
private voidsaveNaResultsForDisplay(com.sun.enterprise.tools.verifier.Result r)

        naResults.addElement(r);
    
private voidsaveNotImplementedResultsForDisplay(com.sun.enterprise.tools.verifier.Result r)

        notImplementedResults.addElement(r);
    
private voidsaveNotRunResultsForDisplay(com.sun.enterprise.tools.verifier.Result r)

        notRunResults.addElement(r);
    
private voidsavePassResultsForDisplay(com.sun.enterprise.tools.verifier.Result r)

        passResults.addElement(r);
    
private voidsaveWarnResultsForDisplay(com.sun.enterprise.tools.verifier.Result r)

        warnResults.addElement(r);
    
public voidsetDetailText(java.lang.String details)

        detailText.setText(details);
        JScrollBar scrollBar = textScrollPane.getVerticalScrollBar();
        if (scrollBar != null) {
            scrollBar.setValue(0);
        }
    
voidsizeTableColumns()

        table.getColumn(
                (smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".columnName1", // NOI18N
                        "Item"))) // NOI18N
                .setMinWidth(150);
        table.getColumn(
                (smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".columnName1", // NOI18N
                        "Item"))) // NOI18N
                .setMaxWidth(200);
        table.getColumn(
                (smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".columnName1", // NOI18N
                        "Item"))) // NOI18N
                .setPreferredWidth(180);
        table.getColumn(
                (smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".columnName2", // NOI18N
                        "Test Name"))) // NOI18N
                .setMinWidth(150);
        table.getColumn(
                (smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".columnName2", // NOI18N
                        "Test Name"))) // NOI18N
                .setPreferredWidth(180);
        table.getColumn(
                (smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".columnName3", // NOI18N
                        "Result"))) // NOI18N
                .setMinWidth(120);
        table.getColumn(
                (smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".columnName3", // NOI18N
                        "Result"))) // NOI18N
                .setMaxWidth(200);
        table.getColumn(
                (smh.getLocalString(
                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                ".columnName3", // NOI18N
                        "Result"))) // NOI18N
                .setPreferredWidth(160);
        table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        table.sizeColumnsToFit(0);
    
public voidtestFinished(java.util.EventObject evt)

        Result r = (Result) evt.getSource();
        StringBuffer s = new StringBuffer("Assertion:" + r.getAssertion() + "\n"); // NOI18N
        String status;
        switch (r.getStatus()) {
            case Result.PASSED:
                {
                    status =
                            (smh.getLocalString(
                                    "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                            ".Status_Passed", // NOI18N
                                    "Passed")); // NOI18N
                    savePassResultsForDisplay(r);
                    Enumeration e = r.getGoodDetails().elements();
                    while (e.hasMoreElements()) {
                        s.append((String) e.nextElement());
                        s.append("\n"); // NOI18N
                    }
                    break;
                }
            case Result.FAILED:
                {
                    status =
                            (smh.getLocalString(
                                    "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                            ".Status_Failed", // NOI18N
                                    "FAILED")); // NOI18N
                    saveFailResultsForDisplay(r);
                    Enumeration e = r.getErrorDetails().elements();
                    while (e.hasMoreElements()) {
                        s.append((String) e.nextElement());
                        s.append("\n"); // NOI18N
                    }
                    break;
                }
            case Result.WARNING:
                {
                    status =
                            (smh.getLocalString(
                                    "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                            ".Status_Warning", // NOI18N
                                    "WARNING")); // NOI18N
                    saveWarnResultsForDisplay(r);
                    Enumeration e = r.getWarningDetails().elements();
                    while (e.hasMoreElements()) {
                        s.append((String) e.nextElement());
                        s.append("\n"); // NOI18N
                    }
                    break;
                }
            case Result.NOT_APPLICABLE:
                {
                    status =
                            (smh.getLocalString(
                                    "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                            ".Status_NotApplicable", // NOI18N
                                    "Not Applicable")); // NOI18N
                    saveNaResultsForDisplay(r);
                    Enumeration e = r.getNaDetails().elements();
                    while (e.hasMoreElements()) {
                        s.append((String) e.nextElement());
                        s.append("\n"); // NOI18N
                    }
                    break;
                }
            case Result.NOT_IMPLEMENTED:
                {
                    status =
                            (smh.getLocalString(
                                    "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                            ".Status_NotImplemented", // NOI18N
                                    "Not Implemented")); // NOI18N
                    saveNotImplementedResultsForDisplay(r);
                    break;
                }
            case Result.NOT_RUN:
                {
                    status =
                            (smh.getLocalString(
                                    "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                            ".Status_NotRun", // NOI18N
                                    "Not Run")); // NOI18N
                    saveNotRunResultsForDisplay(r);
                    break;
                }
            default:
                {
                    status =
                            (smh.getLocalString(
                                    "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                            ".Status_Unknown", // NOI18N
                                    "Unknown")); // NOI18N
                    saveDefaultResultsForDisplay(r);
                    break;
                }
        }
        // create a table row for this result
        Object[] row = {r.getComponentName(), r.getTestName(), status};
        if (ControlPanel.getReportLevel() == VerifierConstants.FAIL &&
                r.getStatus() == Result.FAILED) {
            details.add(s.toString());
            tableModel.addRow(row);
        }

        if (ControlPanel.getReportLevel() == VerifierConstants.WARN &&
                (r.getStatus() == Result.FAILED ||
                r.getStatus() == Result.WARNING)) {
            details.add(s.toString());
            tableModel.addRow(row);
        }

        if (ControlPanel.getReportLevel() == VerifierConstants.ALL) {
            details.add(s.toString());
            tableModel.addRow(row);
        }
    
public voidupDateDisplay(int status)

        // update display approriately
        clearResults();
        if (status == VerifierConstants.ALL) {
            upDateDisplayAll();
        }
        if (status == VerifierConstants.FAIL) {
            upDateDisplayError();
            upDateDisplayFail();
        }
        if (status == VerifierConstants.WARN) {
            upDateDisplayError();
            upDateDisplayFail();
            upDateDisplayWarn();
        }
    
private voidupDateDisplayAll()

        upDateDisplayFail();
        upDateDisplayWarn();
        upDateDisplayPass();
        upDateDisplayNa();
        upDateDisplayNotImplemented();
        upDateDisplayNotRun();
        upDateDisplayDefault();
        upDateDisplayError();
    
private voidupDateDisplayDefault()

        updateTableRows(getDefaultResultsForDisplay());
    
private voidupDateDisplayError()

        Vector errors = getErrorResultsForDisplay();
        for (int i = 0; i < errors.size(); i++) {
            LogRecord r = (LogRecord) errors.elementAt(i);
            details.add(r.getMessage() + "\n" + r.getThrown().getMessage()); // NOI18N
            Object[] row = {r.getLoggerName(), errStr, errStr1};
            tableModel.addRow(row);
        }
        table.sizeColumnsToFit(0);
    
private voidupDateDisplayFail()

        updateTableRows(getFailResultsForDisplay());
    
private voidupDateDisplayNa()

        updateTableRows(getNaResultsForDisplay());
    
private voidupDateDisplayNotImplemented()

        updateTableRows(getNotImplementedResultsForDisplay());
    
private voidupDateDisplayNotRun()

        updateTableRows(getNotRunResultsForDisplay());
    
private voidupDateDisplayPass()

        updateTableRows(getPassResultsForDisplay());
    
private voidupDateDisplayWarn()

        updateTableRows(getWarnResultsForDisplay());
    
private voidupdateTableRows(java.util.Vector results)

        String status;
        // update display approriately
        for (int i = 0; i < results.size(); i++) {
            Result r = ((Result) results.elementAt(i));
            StringBuffer s = new StringBuffer(
                    "Assertion:" + r.getAssertion() + "\n"); // NOI18N
            switch (r.getStatus()) {
                case Result.PASSED:
                    {
                        status =
                                (smh.getLocalString(
                                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                                ".Status_Passed", // NOI18N
                                        "Passed")); // NOI18N
                        Enumeration e = r.getGoodDetails().elements();
                        while (e.hasMoreElements()) {
                            s.append((String) e.nextElement());
                            s.append("\n"); // NOI18N
                        }
                        break;
                    }
                case Result.FAILED:
                    {
                        status =
                                (smh.getLocalString(
                                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                                ".Status_Failed", // NOI18N
                                        "FAILED")); // NOI18N
                        Enumeration e = r.getErrorDetails().elements();
                        while (e.hasMoreElements()) {
                            s.append((String) e.nextElement());
                            s.append("\n"); // NOI18N
                        }
                        break;
                    }
                case Result.WARNING:
                    {
                        status =
                                (smh.getLocalString(
                                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                                ".Status_Warning", // NOI18N
                                        "WARNING")); // NOI18N
                        Enumeration e = r.getWarningDetails().elements();
                        while (e.hasMoreElements()) {
                            s.append((String) e.nextElement());
                            s.append("\n"); // NOI18N
                        }
                        break;
                    }
                case Result.NOT_APPLICABLE:
                    {
                        status =
                                (smh.getLocalString(
                                        "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                                ".Status_NotApplicable", // NOI18N
                                        "Not Applicable")); // NOI18N
                        Enumeration e = r.getNaDetails().elements();
                        while (e.hasMoreElements()) {
                            s.append((String) e.nextElement());
                            s.append("\n"); // NOI18N
                        }
                        break;
                    }
                case Result.NOT_IMPLEMENTED:
                    status =
                            (smh.getLocalString(
                                    "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                            ".Status_NotImplemented", // NOI18N
                                    "Not Implemented")); // NOI18N
                    break;
                case Result.NOT_RUN:
                    status =
                            (smh.getLocalString(
                                    "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                            ".Status_NotRun", // NOI18N
                                    "Not Run")); // NOI18N
                    break;
                default:
                    status =
                            (smh.getLocalString(
                                    "com.sun.enterprise.tools.verifier.gui.ResultsPanel" + // NOI18N
                            ".Status_Unknown", // NOI18N
                                    "Unknown")); // NOI18N
                    break;
            }
            details.add(s.toString());
            Object[] row = {r.getComponentName(), r.getTestName(), status};
            tableModel.addRow(row);
        }//for
        table.sizeColumnsToFit(0);