KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > ajde > ui > swing > CompilerMessagesCellRenderer


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.ajde.ui.swing;
27    
28 import javax.swing.*;
29 import java.awt.*;
30 import java.awt.event.*;
31 import org.aspectj.asm.*;
32 import org.aspectj.ajde.Ajde;
33
34 /**
35  * @author Mik Kersten
36  */

37 public class CompilerMessagesCellRenderer extends JLabel implements ListCellRenderer {
38
39     public Component getListCellRendererComponent(
40         JList list,
41         Object JavaDoc value,
42         int index,
43         boolean isSelected,
44         boolean cellHasFocus) {
45             if (value != null) {
46                 setText(value.toString());
47             } else {
48                 setText("");
49             }
50             StructureMessage.Kind kind = ((CompilerMessage)value).kind;
51             if (kind.equals(StructureMessage.Kind.WARNING)) {
52                 setIcon(AjdeUIManager.getDefault().getIconRegistry().getWarningIcon());
53             } else if (kind.equals(StructureMessage.Kind.INFO)) {
54                 setIcon(null);
55             } else {
56                 setIcon(AjdeUIManager.getDefault().getIconRegistry().getErrorIcon());
57             }
58             if (isSelected) {
59                 setBackground(list.getSelectionBackground());
60                 setForeground(list.getSelectionForeground());
61             } else {
62                 setBackground(list.getBackground());
63                 setForeground(list.getForeground());
64             }
65             setEnabled(list.isEnabled());
66             setFont(list.getFont());
67             setOpaque(true);
68             return this;
69     }
70 }
Popular Tags