int tabIndex = this.getTabIndex(tabName);
if (tabIndex!=-1) {
// clear the result
Object reportObject = runTabbedPane.getClientProperty("TestCaseReportTable_" + tabName);
if (reportObject instanceof TestCaseReportTable) {
TestCaseReportTable reportTable = (TestCaseReportTable)reportObject;
reportTable.resetTable();
// listen to events
TestCaseReporter.addTestCaseReportTableListener(reportTable);
this.runTabbedPane.setSelectedIndex(tabIndex);
}
return;
}
// create a new tab
JTextArea nstackTrace = new JTextArea();
DefaultTableModel ntcReasonModel = new DefaultTableModel(new Object[]{"Line", "File", "Method", "."}, 0) {
@Override
public boolean isCellEditable(int rowIndex, int mColIndex) {
return false;
}
};
TestCaseReportTable ntcTable = new TestCaseReportTable(tabName, ntcReasonModel, nstackTrace, mTestCasePane);
TestCaseReporter.addTestCaseReportTableListener(ntcTable);
JTable ntcReasonTable = new JTable(ntcReasonModel) {
@Override
public String getToolTipText(MouseEvent e) {
Point p = e.getPoint();
int rowIndex = rowAtPoint(p);
int colIndex = columnAtPoint(p);
return convertObjectToToolTip(getValueAt(rowIndex, colIndex));
}
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
ntcReasonTable.getColumn("Line").setPreferredWidth(40);
ntcReasonTable.getColumn("Line").setMaxWidth(40);
ntcReasonTable.getColumn("File").setPreferredWidth(500);
ntcReasonTable.getColumn("File").setMaxWidth(750);
ntcReasonTable.getColumn("Method").setPreferredWidth(250);
ntcReasonTable.getColumn("Method").setMaxWidth(500);
ntcReasonTable.removeColumn(ntcReasonTable.getColumn("."));
ntcReasonTable.setColumnSelectionAllowed(false);
//tcReasonTable.getColumn("Failed Reason").setCellRenderer(new MultiLineCellRenderer());
try {
ntcReasonTable.setDefaultRenderer(Class.forName("java.lang.Object"), new TableReasonCellRenderer());
} catch (ClassNotFoundException ex) {
}
ntcReasonTable.setRowSelectionAllowed(false);
ntcReasonTable.setName("ntcReasonTable");
ntcReasonTable.addMouseListener(new TableMouseListener(ntcReasonTable));
nstackTrace.setRows(5);
// add runTabbed panel
JSplitPane resultMainpanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
JPanel reasonMainPanel = new JPanel(new BorderLayout());
JScrollPane reasonScrollPane = new JScrollPane(ntcReasonTable);
reasonScrollPane.setPreferredSize(new Dimension(100, 100));
JSplitPane reasonPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
reasonPanel.setResizeWeight(0.5);
reasonPanel.setDividerSize(4);
reasonPanel.setTopComponent(reasonScrollPane);
JPanel stackTracePanel = new JPanel(new BorderLayout());
JLabel stackTraceLabel = new JLabel("Stack trace:");
stackTracePanel.add(stackTraceLabel, BorderLayout.NORTH);
stackTracePanel.add(nstackTrace);
reasonPanel.setBottomComponent(new JScrollPane(stackTracePanel));
reasonMainPanel.add(reasonPanel, BorderLayout.CENTER);
resultMainpanel.setResizeWeight(0.5);
resultMainpanel.setTopComponent(new JScrollPane(ntcTable.getTable()));
resultMainpanel.setBottomComponent(reasonMainPanel);
runTabbedPane.putClientProperty("TestCaseReportTable_" + tabName, ntcTable);
runTabbedPane.addTab(tabName, resultMainpanel);
this.runTabbedPane.setSelectedIndex(this.runTabbedPane.getTabCount() -1);