01: package jimm.datavision.gui;
02:
03: import jimm.datavision.source.Table;
04: import jimm.datavision.source.Column;
05: import javax.swing.tree.DefaultMutableTreeNode;
06: import java.util.Iterator;
07:
08: /**
09: * An internal table node for the {@link FieldPickerTree}.
10: *
11: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
12: */
13:
14: public class FPTableInfo {
15:
16: protected Table table;
17: protected Designer designer;
18: protected DefaultMutableTreeNode tableNode;
19:
20: FPTableInfo(Table table, Designer designer) {
21: this .table = table;
22: this .designer = designer;
23: }
24:
25: void setTableNode(DefaultMutableTreeNode tableNode) {
26: this .tableNode = tableNode;
27: }
28:
29: public String toString() {
30: return table.getName();
31: }
32:
33: public void loadColumns() {
34: if (tableNode == null)
35: return;
36:
37: // Remove table node's existing dummy child node.
38: tableNode.remove(0);
39:
40: // Add columns.
41: for (Iterator iter = table.columns(); iter.hasNext();) {
42: Column column = (Column) iter.next();
43: ColumnInfo info = new ColumnInfo(column, designer);
44: tableNode.add(new DefaultMutableTreeNode(info, false));
45: }
46:
47: // A signal that we have loaded the columns.
48: tableNode = null;
49: }
50:
51: }
|