01: package org.swingml.treetablebrowser.ext;
02:
03: import java.awt.*;
04:
05: import javax.swing.*;
06: import javax.swing.table.*;
07:
08: import org.swingml.*;
09: import org.swingml.component.*;
10: import org.swingml.model.*;
11: import org.swingml.model.TableColumnModel;
12:
13: public class TreeTableBrowserColumnModel extends TableColumnModel {
14:
15: private int sortDirection = 0;
16: private int sortOrder = 0;
17:
18: public TreeTableBrowserColumnModel(Container aContainer) {
19: super ();
20: }
21:
22: public void addChild(Object aChild) {
23: if (aChild instanceof SwingMLModel) {
24: setCellEditorModel((SwingMLModel) aChild);
25: }
26: }
27:
28: public TableCellEditor getCustomEditor() {
29: if (getCellEditor() == null) {
30: if (getCellEditorModel() != null) {
31: SwingMLModel theCellEditorModel = getCellEditorModel();
32: if (theCellEditorModel instanceof JComboBoxModel) {
33: JComboBoxModel m = (JComboBoxModel) theCellEditorModel;
34: setCellEditor(new DefaultCellEditor(
35: new JComboBoxComponent(m)));
36: } else if (theCellEditorModel instanceof JFormattedTextFieldModel) {
37: JFormattedTextFieldModel m = (JFormattedTextFieldModel) theCellEditorModel;
38: setCellEditor(new DefaultCellEditor(
39: new JFormattedTextFieldComponent(m)));
40: }
41: }
42: }
43: return getCellEditor();
44: }
45:
46: /**
47: * Returns the sortDirection.
48: * @return int
49: */
50: public int getSortDirection() {
51: return sortDirection;
52: }
53:
54: /**
55: * Returns the sortOrder.
56: * @return int
57: */
58: public int getSortOrder() {
59: return sortOrder;
60: }
61:
62: /**
63: * Sets the sortDirection.
64: * @param aDirection The sortDirection to set
65: */
66: public void setSortDirection(int aDirection) {
67: this .sortDirection = aDirection;
68: }
69:
70: /**
71: * Sets the sortOrder.
72: * @param anOrder The sortOrder to set
73: */
74: public void setSortOrder(int anOrder) {
75: this.sortOrder = anOrder;
76: }
77: }
|