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: public class TableBrowserCellIconDecorator {
11:
12: public TableBrowserCellIconDecorator(TableBrowserComponent aTable) {
13: super ();
14: TableBrowserModel theTableModel = (TableBrowserModel) aTable
15: .getModel();
16: Iterator theColumns = theTableModel.getColumns().iterator();
17: TableColumnModel theColumn = null;
18: while (theColumns.hasNext()) {
19: theColumn = (TableColumnModel) theColumns.next();
20: TableCellRenderer originalRenderer = aTable
21: .getDefaultRenderer(theColumn.getType().getClass());
22: if (!(originalRenderer instanceof TableBrowserCellIconRenderer)) {
23: Class clazz = theColumn.getType().getClass();
24: if (clazz == JButton.class) {
25: aTable.setDefaultRenderer(theColumn.getType()
26: .getClass(), new IconComponentCellEditor());
27: } else {
28: aTable.setDefaultRenderer(theColumn.getType()
29: .getClass(),
30: new TableBrowserCellIconRenderer(
31: originalRenderer));
32: }
33: }
34: }
35: }
36: }
|