From 3bc503e4539c492dd8f1d06f03a729d3171320ba Mon Sep 17 00:00:00 2001 From: wisberg Date: Wed, 30 Apr 2003 02:36:02 +0000 Subject: [PATCH] - using IMessage-based API's for displaying messages - if a source line message contains a throwable and the user double-clicks, this displays the error dialog that permits them to copy the trace. That should mean that multiple exceptions can be in the task list. --- .../ajbrowser/CompilerMessagesPanel.java | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/CompilerMessagesPanel.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/CompilerMessagesPanel.java index 61a808aab..5324e50bc 100644 --- a/ajbrowser/src/org/aspectj/tools/ajbrowser/CompilerMessagesPanel.java +++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/CompilerMessagesPanel.java @@ -30,6 +30,8 @@ import org.aspectj.ajde.ui.swing.CompilerMessage; import org.aspectj.ajde.ui.swing.CompilerMessagesCellRenderer; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.ISourceLocation; +import org.aspectj.bridge.Message; +import org.aspectj.bridge.IMessage.Kind; /** * Used to display a list of compiler messages that can be clicked in order @@ -59,7 +61,9 @@ public class CompilerMessagesPanel extends JPanel implements TaskListManager { int index = list.locationToIndex(e.getPoint()); if (listModel.getSize() >= index && index != -1) { CompilerMessage cm = (CompilerMessage)listModel.getElementAt(index); - Ajde.getDefault().getEditorManager().showSourceLine(cm.sourceLocation, true); + if ((null != cm) && (null != cm.message)) { + displayMessage(cm.message); + } } } } @@ -67,14 +71,35 @@ public class CompilerMessagesPanel extends JPanel implements TaskListManager { list.addMouseListener(mouseListener); list.setCellRenderer(new CompilerMessagesCellRenderer()); } + + public void addSourcelineTask( + String message, + ISourceLocation sourceLocation, + Kind kind) { + addSourcelineTask(new Message(message, kind, null, sourceLocation)); + } + + /** + * called when user double-clicks on a message. + */ + protected void displayMessage(IMessage message) { + ISourceLocation loc = message.getISourceLocation(); + Ajde.getDefault().getEditorManager().showSourceLine(loc, true); + // show dialog with stack trace if thrown + Throwable thrown = message.getThrown(); + if (null != thrown) { + Ajde.getDefault().getErrorHandler().handleError(message.getMessage(), thrown); + } + } - public void addSourcelineTask(String message, ISourceLocation sourceLocation, IMessage.Kind kind) { - listModel.addElement(new CompilerMessage(message, sourceLocation,kind)); + public void addSourcelineTask(IMessage message) { + listModel.addElement(new CompilerMessage(message)); BrowserManager.getDefault().showMessages(); } public void addProjectTask(String message, IMessage.Kind kind) { - listModel.addElement(new CompilerMessage(message,kind)); + IMessage m = new Message(message, kind, null, null); + listModel.addElement(new CompilerMessage(m)); BrowserManager.getDefault().showMessages(); } -- 2.39.5