01: package net.sourceforge.squirrel_sql.client.gui.db;
02:
03: /*
04: * Copyright (C) 2001-2004 Henner Zeller
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: import java.awt.Component;
21:
22: import javax.swing.DefaultListCellRenderer;
23: import javax.swing.Icon;
24: import javax.swing.JList;
25:
26: import net.sourceforge.squirrel_sql.fw.sql.ISQLDriver;
27:
28: /**
29: * A cell renderer, that shows Drivers that could not be loaded with
30: * one icon and those can could be loaded with another icon.
31: *
32: * @author Henner Zeller
33: */
34: class DriverListCellRenderer extends DefaultListCellRenderer {
35: /** Icon for drivers that could be loaded. */
36: private final Icon OK_ICON;
37:
38: /** Icon for drivers that could not be loaded. */
39: private final Icon FAIL_ICON;
40:
41: public DriverListCellRenderer(Icon ok, Icon fail) {
42: OK_ICON = ok;
43: FAIL_ICON = fail;
44: }
45:
46: public Component getListCellRendererComponent(JList list,
47: Object value, int index, boolean isSelected,
48: boolean cellHasFocus) {
49: super .getListCellRendererComponent(list, value, index,
50: isSelected, cellHasFocus);
51: final ISQLDriver drv = (ISQLDriver) value;
52: if (drv == null || !drv.isJDBCDriverClassLoaded()) {
53: setIcon(FAIL_ICON);
54: } else {
55: setIcon(OK_ICON);
56: }
57: return this;
58: }
59: }
|