public FailureRunView(TestRunContext context) { fRunContext= context; fFailureList= new JList(fRunContext.getFailures()); fFailureList.setFont(new Font("Dialog", Font.PLAIN, 12)); fFailureList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fFailureList.setCellRenderer(new FailureListCellRenderer()); fFailureList.setVisibleRowCount(5); fFailureList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { testSelected(); } } ); }
public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { Component c= super.getListCellRendererComponent(list, value, modelIndex, isSelected, cellHasFocus); TestFailure failure= (TestFailure)value; String text= failure.failedTest().toString(); String msg= failure.exceptionMessage(); if (msg != null) text+= ":" + BaseTestRunner.truncate(msg); if (failure.isFailure()) { if (fFailureIcon != null) setIcon(fFailureIcon); } else { if (fErrorIcon != null) setIcon(fErrorIcon); } setText(text); setToolTipText(text); return c; } }
FailureListCellRenderer() { super(); loadIcons(); }