01: /* ====================================================================
02: * Copyright (c) 1998 - 2003 David F. Glasser. All rights
03: * reserved.
04: *
05: * This file is part of the QueryForm Database Tool.
06: *
07: * The QueryForm Database Tool is free software; you can redistribute it
08: * and/or modify it under the terms of the GNU General Public License as
09: * published by the Free Software Foundation; either version 2 of the
10: * License, or (at your option) any later version.
11: *
12: * The QueryForm Database Tool is distributed in the hope that it will
13: * be useful, but WITHOUT ANY WARRANTY; without even the implied
14: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15: * See the GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with the QueryForm Database Tool; if not, write to:
19: *
20: * The Free Software Foundation, Inc.,
21: * 59 Temple Place, Suite 330
22: * Boston, MA 02111-1307 USA
23: *
24: * or visit http://www.gnu.org.
25: *
26: * ====================================================================
27: *
28: * This product includes software developed by the
29: * Apache Software Foundation (http://www.apache.org/).
30: *
31: * ====================================================================
32: */
33: package org.glasser.qform;
34:
35: import javax.swing.*;
36: import java.awt.*;
37: import org.glasser.sql.*;
38:
39: public class TableInfoListCellRenderer extends DefaultListCellRenderer {
40:
41: java.util.HashMap italicFontMap = new java.util.HashMap();
42:
43: public Component getListCellRendererComponent(JList list,
44: Object value, int index, boolean isSelected,
45: boolean cellHasFocus) {
46:
47: JLabel component = (JLabel) super .getListCellRendererComponent(
48: list, value, index, isSelected, cellHasFocus);
49:
50: if (value instanceof TableInfo) {
51: TableInfo ti = (TableInfo) value;
52: if ("VIEW".equals(ti.getTableType())) {
53: Font font = component.getFont();
54: Font viewFont = (Font) italicFontMap.get(font);
55: if (viewFont == null) {
56: viewFont = font.deriveFont(Font.ITALIC);
57: italicFontMap.put(font, viewFont);
58: }
59: component.setFont(viewFont);
60: }
61: }
62:
63: return component;
64:
65: }
66:
67: }
|