1 2 25 26 package org.aspectj.tools.ajbrowser; 27 28 import javax.swing.*; 29 import java.awt.*; 30 import java.awt.event.*; 31 import javax.swing.text.StyledDocument ; 32 import org.aspectj.asm.*; 33 import org.aspectj.compiler.base.ast.ThisExpr; 34 import org.aspectj.ajde.*; 35 import org.aspectj.ajde.TaskListManager; 36 import org.aspectj.ajde.Ajde; 37 import org.aspectj.ajde.ui.swing.*; 38 39 45 public class CompilerMessagesPanel extends JPanel implements TaskListManager { 46 private JScrollPane jScrollPane1 = new JScrollPane(); 47 private JList list = new JList(); 49 private DefaultListModel listModel = new DefaultListModel(); 50 private BorderLayout borderLayout1 = new BorderLayout(); 51 52 public CompilerMessagesPanel() { 53 try { 54 jbInit(); 55 } 56 catch(Exception e) { 57 e.printStackTrace(); 58 } 59 list.setModel(listModel); 60 61 MouseListener mouseListener = new MouseAdapter() { 62 public void mouseClicked(MouseEvent e) { 63 if (e.getClickCount() >= 1) { 64 int index = list.locationToIndex(e.getPoint()); 65 if (listModel.getSize() >= index && index != -1) { 66 CompilerMessage cm = (CompilerMessage)listModel.getElementAt(index); 67 Ajde.getDefault().getEditorManager().showSourceLine(cm.sourceLocation, true); 68 } 69 } 70 } 71 }; 72 list.addMouseListener(mouseListener); 73 list.setCellRenderer(new CompilerMessagesCellRenderer()); 74 } 75 76 public void addSourcelineTask(String message, SourceLocation sourceLocation, StructureMessage.Kind kind) { 77 listModel.addElement(new CompilerMessage(message, sourceLocation,kind)); 78 BrowserManager.getDefault().showMessages(); 79 } 80 81 public void addProjectTask(String message, StructureMessage.Kind kind) { 82 listModel.addElement(new CompilerMessage(message,kind)); 83 BrowserManager.getDefault().showMessages(); 84 } 85 86 public void clearTasks() { 87 listModel.clear(); 88 } 89 90 private void jbInit() throws Exception { 91 this.setLayout(borderLayout1); 92 this.add(jScrollPane1, BorderLayout.CENTER); 93 jScrollPane1.getViewport().add(list, null); 94 } 95 } 96 97 98 99 | Popular Tags |