1 11 14 package org.eclipse.jdt.internal.junit.ui; 15 16 import org.eclipse.swt.SWT; 17 import org.eclipse.swt.events.DisposeEvent; 18 import org.eclipse.swt.events.DisposeListener; 19 import org.eclipse.swt.graphics.Image; 20 import org.eclipse.swt.widgets.Table; 21 import org.eclipse.swt.widgets.TableItem; 22 23 public class FailureTableDisplay implements ITraceDisplay { 24 private final Table fTable; 25 26 private final Image fExceptionIcon = TestRunnerViewPart 27 .createImage("obj16/exc_catch.gif"); 29 private final Image fStackIcon = TestRunnerViewPart 30 .createImage("obj16/stkfrm_obj.gif"); 32 public FailureTableDisplay(Table table) { 33 fTable = table; 34 fTable.getParent().addDisposeListener(new DisposeListener() { 35 public void widgetDisposed(DisposeEvent e) { 36 disposeIcons(); 37 } 38 }); 39 } 40 41 public void addTraceLine(int lineType, String label) { 42 TableItem tableItem = newTableItem(); 43 switch (lineType) { 44 case TextualTrace.LINE_TYPE_EXCEPTION: 45 tableItem.setImage(fExceptionIcon); 46 break; 47 case TextualTrace.LINE_TYPE_STACKFRAME: 48 tableItem.setImage(fStackIcon); 49 break; 50 case TextualTrace.LINE_TYPE_NORMAL: 51 default: 52 break; 53 } 54 tableItem.setText(label); 55 } 56 57 public Image getExceptionIcon() { 58 return fExceptionIcon; 59 } 60 61 public Image getStackIcon() { 62 return fStackIcon; 63 } 64 65 public Table getTable() { 66 return fTable; 67 } 68 69 private void disposeIcons() { 70 if (fExceptionIcon != null && !fExceptionIcon.isDisposed()) 71 fExceptionIcon.dispose(); 72 if (fStackIcon != null && !fStackIcon.isDisposed()) 73 fStackIcon.dispose(); 74 } 75 76 TableItem newTableItem() { 77 return new TableItem(fTable, SWT.NONE); 78 } 79 } 80 | Popular Tags |