1 6 package com.nightlabs.rcp.exceptionhandler.dialog; 7 8 import java.io.PrintWriter ; 9 import java.io.StringWriter ; 10 11 import org.eclipse.swt.SWT; 12 import org.eclipse.swt.layout.GridData; 13 import org.eclipse.swt.layout.GridLayout; 14 import org.eclipse.swt.widgets.Composite; 15 import org.eclipse.swt.widgets.Text; 16 17 20 public class ThrowableHandlerDetailArea extends Composite { 21 22 private Text textAreaStackTrace = null; 23 public ThrowableHandlerDetailArea(Composite parent, int style) { 24 super(parent, style); 25 initialize(); 26 } 27 private void initialize() { 28 GridData gridDataTextArea = new GridData(GridData.FILL_BOTH); 29 textAreaStackTrace = new Text(this, SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY); 30 this.setLayout(new GridLayout()); 31 gridDataTextArea.grabExcessHorizontalSpace = true; 32 gridDataTextArea.grabExcessVerticalSpace = true; 33 gridDataTextArea.verticalAlignment = org.eclipse.swt.layout.GridData.FILL; 34 textAreaStackTrace.setForeground(new org.eclipse.swt.graphics.Color(org.eclipse.swt.widgets.Display.getDefault(), 240, 0, 0)); 35 textAreaStackTrace.setLayoutData(gridDataTextArea); 36 this.setSize(new org.eclipse.swt.graphics.Point(426,200)); 37 } 38 39 private Throwable error = null; 40 public void setThrowable(Throwable err) { 41 this.error = err; 42 if (error != null) { 43 StringWriter sw = new StringWriter (); 44 PrintWriter pw = new PrintWriter (sw); 45 error.printStackTrace(pw); 46 textAreaStackTrace.setText(sw.toString()); 47 } 67 } 68 } 69 | Popular Tags |