01: // ResourceCellRenderer.java
02: // $Id: ResourceCellRenderer.java,v 1.6 2000/08/16 21:37:30 ylafon Exp $
03: // (c) COPYRIGHT MIT, INRIA and Keio, 1999.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05: package org.w3c.jigadmin.editors;
06:
07: import javax.swing.JPanel;
08: import javax.swing.JLabel;
09: import javax.swing.ListCellRenderer;
10: import javax.swing.ImageIcon;
11: import javax.swing.JList;
12: import javax.swing.JScrollPane;
13:
14: import java.awt.GridLayout;
15: import java.awt.Component;
16: import java.awt.Color;
17:
18: import org.w3c.jigadmin.widgets.Icons;
19:
20: import org.w3c.tools.widgets.Utilities;
21:
22: public class ResourceCellRenderer extends JLabel implements
23: ListCellRenderer {
24:
25: public ResourceCellRenderer() {
26: setOpaque(true);
27: setFont(Utilities.defaultFont);
28: }
29:
30: // This is the only method defined by ListCellRenderer. We just
31: // reconfigure the Jlabel each time we're called.
32:
33: public Component getListCellRendererComponent(JList list,
34: Object value, int index, boolean isSelected,
35: boolean cellHasFocus) {
36: String s = value.toString();
37: setText(s);
38:
39: if (value instanceof ResourceCell) {
40: ResourceCell cell = (ResourceCell) value;
41: if (cell.isContainer() || cell.isIndexer())
42: setIcon(Icons.dirIcon);
43: else if (cell.isFrame())
44: setIcon(Icons.frameIcon);
45: else if (cell.isFilter())
46: setIcon(Icons.filterIcon);
47: else if (cell.isMetaDataFrame())
48: setIcon(Icons.metaDataIcon);
49: else
50: setIcon(Icons.resIcon);
51: }
52: setBackground(isSelected ? Color.blue : Color.white);
53: setForeground(isSelected ? Color.white : Color.black);
54: return this;
55: }
56: }
|