01: /*
02: * Created on 06.08.2003
03: *
04: * To change the template for this generated file go to
05: * Window>Preferences>Java>Code Generation>Code and Comments
06: */
07: package org.columba.core.gui.plugin;
08:
09: import java.awt.Component;
10:
11: import javax.swing.JCheckBox;
12: import javax.swing.JLabel;
13: import javax.swing.JTable;
14: import javax.swing.SwingConstants;
15: import javax.swing.table.DefaultTableCellRenderer;
16:
17: /**
18: * @author frd
19: *
20: * To change the template for this generated type comment go to
21: * Window>Preferences>Java>Code Generation>Code and Comments
22: */
23:
24: public class EnabledRenderer extends DefaultTableCellRenderer {
25: JCheckBox checkBox = new JCheckBox();
26:
27: public EnabledRenderer() {
28: setHorizontalAlignment(SwingConstants.CENTER);
29: }
30:
31: /* (non-Javadoc)
32: * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
33: */
34: public Component getTableCellRendererComponent(JTable table,
35: Object value, boolean isSelected, boolean hasFocus,
36: int row, int column) {
37: PluginNode node = (PluginNode) value;
38:
39: if (node.isCategory()) {
40: // this node is category folder
41: // -> don't make it editable
42: return super .getTableCellRendererComponent(table, "",
43: isSelected, hasFocus, row, column);
44: } else {
45: boolean b = node.isEnabled();
46:
47: checkBox.setSelected(b);
48: checkBox.setHorizontalAlignment(JLabel.CENTER);
49:
50: if (isSelected) {
51: checkBox.setBackground(table.getSelectionBackground());
52: } else {
53: checkBox.setBackground(table.getBackground());
54: }
55:
56: return checkBox;
57: }
58: }
59: }
|