01: package org.swingml.treetablebrowser.ext;
02:
03: import java.awt.*;
04: import java.util.*;
05: import java.util.List;
06:
07: import org.swingml.*;
08:
09: public class TreeTableBrowserNodeModel extends SwingMLModel {
10:
11: private List filteredTableData = new ArrayList();
12: private List treeTableDatas = new ArrayList();
13:
14: public TreeTableBrowserNodeModel(Container aContainer) {
15: super ();
16: }
17:
18: private List sorted() {
19: // apply filter
20: filteredTableData = new ArrayList();
21: for (int i = 0; i < treeTableDatas.size(); i++) {
22: Object obj = treeTableDatas.get(i);
23: if (obj instanceof TreeTableBrowserDataModel) {
24: TreeTableBrowserDataModel dm = (TreeTableBrowserDataModel) obj;
25: if (i == 0
26: && dm.getText().toLowerCase().indexOf("1") >= 0) {
27: filteredTableData.add(obj);
28: }
29: }
30: }
31: return treeTableDatas;
32: }
33:
34: public void addChild(Object aChild) {
35: TreeTableBrowserDataModel theTreeTableDataModel = (TreeTableBrowserDataModel) aChild;
36: treeTableDatas.add(theTreeTableDataModel);
37: }
38:
39: public List getTreeTableDatas() {
40: if (this .treeTableDatas == null) {
41: this .treeTableDatas = new ArrayList();
42: }
43: // return this.treeTableDatas;
44: //return filter();
45: return sorted();
46: }
47:
48: public void setTreeTableData(List aTreeTableDatas) {
49: this .treeTableDatas = aTreeTableDatas;
50: }
51:
52: public String toString() {
53: TreeTableBrowserDataModel theTreeTableDataModel = (TreeTableBrowserDataModel) getTreeTableDatas()
54: .get(0);
55: return theTreeTableDataModel.getText();
56: }
57:
58: public void updateColumn(int col, Object value) {
59: TreeTableBrowserDataModel dm = (TreeTableBrowserDataModel) getTreeTableDatas()
60: .get(col);
61: dm.setText(value == null ? "" : value.toString());
62: }
63: }
|