KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > tools > ajbrowser > CompilerMessagesPanel


1
2 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3  *
4  * This file is part of the IDE support for the AspectJ(tm)
5  * programming language; see http://aspectj.org
6  *
7  * The contents of this file are subject to the Mozilla Public License
8  * Version 1.1 (the "License"); you may not use this file except in
9  * compliance with the License. You may obtain a copy of the License at
10  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is AspectJ.
18  *
19  * The Initial Developer of the Original Code is Xerox Corporation. Portions
20  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
21  * All Rights Reserved.
22  *
23  * Contributor(s):
24  */

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 JavaDoc;
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 /**
40  * Used to display a list of compiler messages that can be clicked in order
41  * to seek to their corresponding sourceline.
42  *
43  * @author Mik Kersten
44  */

45 public class CompilerMessagesPanel extends JPanel implements TaskListManager {
46     private JScrollPane jScrollPane1 = new JScrollPane();
47     //private JScrollPane jScrollPane2 = new JScrollPane();
48
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 JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc {
91         this.setLayout(borderLayout1);
92         this.add(jScrollPane1, BorderLayout.CENTER);
93         jScrollPane1.getViewport().add(list, null);
94     }
95 }
96
97
98
99
Popular Tags