KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > gui > dialog > view > InterfaceTableCellRenderer


1 /***
2  * FractalGUI: a graphical tool to edit Fractal component configurations.
3  * Copyright (C) 2003 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: fractal@objectweb.org
20  *
21  * Authors: Eric Bruneton, Patrice Fauvel
22  */

23
24 package org.objectweb.fractal.gui.dialog.view;
25
26 import org.objectweb.fractal.gui.Constants;
27 import org.objectweb.fractal.gui.model.Interface;
28
29 import java.awt.Color JavaDoc;
30
31 import javax.swing.JTable JavaDoc;
32 import javax.swing.table.DefaultTableCellRenderer JavaDoc;
33
34 /**
35  * A {@link javax.swing.table.TableCellRenderer} to draw interfaces with a
36  * color indicating their status.
37  */

38
39 public class InterfaceTableCellRenderer extends DefaultTableCellRenderer JavaDoc {
40
41   public java.awt.Component JavaDoc getTableCellRendererComponent (
42     final JTable JavaDoc table,
43     final Object JavaDoc value,
44     final boolean isSelected,
45     final boolean hasFocus,
46     final int row,
47     final int column)
48   {
49     super.getTableCellRendererComponent(
50       table, value, isSelected, hasFocus, row, column);
51     Interface itf = (Interface)table.getModel().getValueAt(row, -1);
52     long status = itf.getStatus();
53     if (itf.getMasterCollectionInterface() != null) {
54       setForeground(Color.gray);
55     } else if ((status & Interface.MANDATORY_INTERFACE_NOT_BOUND) != 0) {
56       setForeground(Constants.ERROR_COLOR);
57     } else if ((status & (Interface.NAME_MISSING)) != 0 && column == 0) {
58       setForeground(Constants.ERROR_COLOR);
59       setText("<empty>");
60     } else if ((status & (Interface.NAME_ALREADY_USED)) != 0 && column == 0) {
61       setForeground(Constants.ERROR_COLOR);
62     } else if ((status & (Interface.SIGNATURE_MISSING)) != 0 && column == 1) {
63       setForeground(Constants.ERROR_COLOR);
64       setText("<empty>");
65     } else if ((status & (Interface.SIGNATURE_CLASS_NOT_FOUND)) != 0
66                && column == 1)
67     {
68       setForeground(Constants.ERROR_COLOR);
69     } else {
70       setForeground(Color.black);
71     }
72     return this;
73   }
74 }
75
Popular Tags