01: package org.swingml.tablebrowser.ext;
02:
03: import java.util.*;
04:
05: import javax.swing.*;
06: import javax.swing.table.*;
07:
08: import org.swingml.model.TableColumnModel;
09:
10: /**
11: * @author Crosslogic
12: */
13: public class TableBrowserCellLabelDecorator {
14:
15: public TableBrowserCellLabelDecorator(TableBrowserComponent aTable) {
16: super ();
17: TableBrowserModel theTableModel = (TableBrowserModel) aTable
18: .getModel();
19: Iterator theColumns = theTableModel.getColumns().iterator();
20: TableColumnModel theColumn = null;
21: while (theColumns.hasNext()) {
22: theColumn = (TableColumnModel) theColumns.next();
23: TableCellRenderer originalRenderer = aTable
24: .getDefaultRenderer(theColumn.getType().getClass());
25: TableCellEditor originalEditor = aTable
26: .getDefaultEditor(theColumn.getType().getClass());
27: if (originalRenderer instanceof JLabel) {
28: Class clazz = theColumn.getType().getClass();
29: if (clazz == JButton.class) {
30: aTable.setDefaultRenderer(theColumn.getType()
31: .getClass(), new IconComponentCellEditor());
32: } else {
33: aTable.setDefaultRenderer(theColumn.getType()
34: .getClass(),
35: new TableBrowserCellLabelRenderer(
36: originalRenderer));
37: aTable.setDefaultEditor(theColumn.getType()
38: .getClass(),
39: new TableBrowserCellLabelEditor(
40: originalEditor));
41: }
42: }
43: }
44: }
45: }
|