~ubuntu-branches/ubuntu/wily/aspectj/wily-proposed

« back to all changes in this revision

Viewing changes to org.aspectj/modules/ajbrowser/src/org/aspectj/tools/ajbrowser/ui/BrowserMessageHandler.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2011-03-15 23:54:31 UTC
  • mfrom: (1.2.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20110315235431-iq2gxbsx08kpwuiw
* New upstream release.
* Updated Standards-Version to 3.9.1 (no changes needed).
* Fix local Javadoc links:
  - d/patches/07_javadoc_links.diff: Use locally installed
   javadoc packages and hyperlink with them.
  - d/control: Add B-D on default-java-doc and libasm3-java-doc.
* d/control: Drop B-D on itself (our new bootstrap infrastructure doesn't need
  that anymore).
* Split packages into :
  - aspectj: only contains CLI tools.
  - libaspectj-java: JAR librairies for /usr/share/java.
  - libaspectj-java-doc: 4 API's Javadoc.
  - aspectj-doc: Programming Guides and SDK Documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import org.aspectj.bridge.IMessage.Kind;
24
24
 
25
25
/**
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.
30
28
 */
31
29
public class BrowserMessageHandler implements IUIBuildMessageHandler {
32
30
 
33
 
        private List ignoring;
34
 
        private List messages;
35
 
        
 
31
        private List<IMessage.Kind> ignoring;
 
32
        private List<IMessage> messages;
 
33
 
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);
41
39
        }
42
 
        
 
40
 
43
41
        public boolean handleMessage(IMessage message) throws AbortException {
44
42
                Kind messageKind = message.getKind();
45
43
                if (isIgnoring(messageKind)) {
46
44
                        return true;
47
45
                }
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);
55
 
                return 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);
 
51
                        return true;
56
52
                }
57
53
                messages.add(message);
58
54
                return true;
59
55
        }
60
56
 
61
57
        public void dontIgnore(Kind kind) {
62
 
            if (null != kind) {
63
 
                ignoring.remove(kind);
64
 
            }
 
58
                if (null != kind) {
 
59
                        ignoring.remove(kind);
 
60
                }
65
61
        }
66
62
 
67
63
        public boolean isIgnoring(Kind kind) {
68
64
                return ((null != kind) && (ignoring.contains(kind)));
69
65
        }
70
 
        
 
66
 
71
67
        public void ignore(Kind kind) {
72
 
            if ((null != kind) && (!ignoring.contains(kind))) {
73
 
                ignoring.add(kind);
74
 
            }   
 
68
                if ((null != kind) && (!ignoring.contains(kind))) {
 
69
                        ignoring.add(kind);
 
70
                }
75
71
        }
76
 
        
77
 
        public List getMessages() {
 
72
 
 
73
        public List<IMessage> getMessages() {
78
74
                return messages;
79
75
        }
80
76
 
81
 
    private String getStackTraceAsString(Throwable t) {
82
 
        StringWriter stringWriter = new StringWriter();
83
 
        if (t != null) {
84
 
            t.printStackTrace(new PrintWriter(stringWriter));
85
 
            return stringWriter.getBuffer().toString();
86
 
        } 
87
 
        return "<no stack trace available>";
88
 
    }
 
77
        private String getStackTraceAsString(Throwable t) {
 
78
                StringWriter stringWriter = new StringWriter();
 
79
                if (t != null) {
 
80
                        t.printStackTrace(new PrintWriter(stringWriter));
 
81
                        return stringWriter.getBuffer().toString();
 
82
                }
 
83
                return "<no stack trace available>";
 
84
        }
89
85
 
90
86
        public void reset() {
91
87
                messages.clear();
92
88
        }
93
 
        
 
89
 
94
90
}