23
23
import org.aspectj.bridge.IMessage.Kind;
26
* MessageHandler used by AjBrowser that displays ERROR messages with
27
* exceptions and ABORT messages in an error dialog. Other messages are
28
* displayed by the MessageHandlerPanel. By default INFO and WEAVEINFO
29
* messages are ignored.
26
* MessageHandler used by AjBrowser that displays ERROR messages with exceptions and ABORT messages in an error dialog. Other
27
* messages are displayed by the MessageHandlerPanel. By default INFO and WEAVEINFO messages are ignored.
31
29
public class BrowserMessageHandler implements IUIBuildMessageHandler {
33
private List ignoring;
34
private List messages;
31
private List<IMessage.Kind> ignoring;
32
private List<IMessage> messages;
36
34
public BrowserMessageHandler() {
37
ignoring = new ArrayList();
38
messages = new ArrayList();
35
ignoring = new ArrayList<IMessage.Kind>();
36
messages = new ArrayList<IMessage>();
39
37
ignore(IMessage.INFO);
40
38
ignore(IMessage.WEAVEINFO);
43
41
public boolean handleMessage(IMessage message) throws AbortException {
44
42
Kind messageKind = message.getKind();
45
43
if (isIgnoring(messageKind)) {
48
if (messageKind.equals(IMessage.ABORT)
49
|| (message.getThrown() != null) ) {
50
String stack = getStackTraceAsString(message.getThrown());
51
ErrorDialog errorDialog = new ErrorDialog(
52
Ajde.getDefault().getRootFrame(),
53
"AJDE Error", message.getThrown(), message.getMessage(), stack);
54
errorDialog.setVisible(true);
46
if (messageKind.equals(IMessage.ABORT) || (message.getThrown() != null)) {
47
String stack = getStackTraceAsString(message.getThrown());
48
ErrorDialog errorDialog = new ErrorDialog(Ajde.getDefault().getRootFrame(), "AJDE Error", message.getThrown(),
49
message.getMessage(), stack);
50
errorDialog.setVisible(true);
57
53
messages.add(message);
61
57
public void dontIgnore(Kind kind) {
63
ignoring.remove(kind);
59
ignoring.remove(kind);
67
63
public boolean isIgnoring(Kind kind) {
68
64
return ((null != kind) && (ignoring.contains(kind)));
71
67
public void ignore(Kind kind) {
72
if ((null != kind) && (!ignoring.contains(kind))) {
68
if ((null != kind) && (!ignoring.contains(kind))) {
77
public List getMessages() {
73
public List<IMessage> getMessages() {
81
private String getStackTraceAsString(Throwable t) {
82
StringWriter stringWriter = new StringWriter();
84
t.printStackTrace(new PrintWriter(stringWriter));
85
return stringWriter.getBuffer().toString();
87
return "<no stack trace available>";
77
private String getStackTraceAsString(Throwable t) {
78
StringWriter stringWriter = new StringWriter();
80
t.printStackTrace(new PrintWriter(stringWriter));
81
return stringWriter.getBuffer().toString();
83
return "<no stack trace available>";
90
86
public void reset() {