1 19 20 package org.netbeans.modules.apisupport.project; 21 22 import java.io.PrintWriter ; 23 import java.io.StringWriter ; 24 import java.util.Date ; 25 import junit.framework.Assert; 26 import org.netbeans.junit.NbTestCase; 27 import org.openide.ErrorManager; 28 29 33 public class ErrorManagerImpl extends ErrorManager { 34 35 static NbTestCase running; 36 37 private String prefix; 38 39 40 public ErrorManagerImpl() { 41 this("[em]"); 42 } 43 44 private ErrorManagerImpl(String p) { 45 this.prefix = p; 46 } 47 48 public static void registerCase(NbTestCase r) { 49 running = r; 50 } 51 52 public Throwable attachAnnotations(Throwable t, Annotation[] arr) { 53 return t; 54 } 55 56 public Annotation[] findAnnotations(Throwable t) { 57 return null; 58 } 59 60 public Throwable annotate(Throwable t, int severity, String message, String localizedMessage, Throwable stackTrace, Date date) { 61 return t; 62 } 63 64 public void notify(int severity, Throwable t) { 65 StringWriter w = new StringWriter (); 66 w.write(prefix); 67 w.write(' '); 68 t.printStackTrace(new PrintWriter (w)); 69 70 System.err.println(w.toString()); 71 72 if (running == null) { 73 return; 74 } 75 running.getLog().println(w.toString()); 76 } 77 78 public void log(int severity, String s) { 79 String msg = prefix + ' ' + s; 80 if (severity != INFORMATIONAL) { 81 System.err.println(msg); 82 } 83 84 if (running == null) { 85 return; 86 } 87 running.getLog().println(msg); 88 } 89 90 public ErrorManager getInstance(String name) { 91 return new ErrorManagerImpl(name); 92 } 93 94 } 95 | Popular Tags |