KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > examples > listexample > TreeTable


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.examples.listexample;
17
18 import java.io.Serializable JavaDoc;
19
20 import org.apache.myfaces.custom.tree.DefaultMutableTreeNode;
21 import org.apache.myfaces.custom.tree.model.DefaultTreeModel;
22
23 /**
24  * <p>
25  * Bean holding the tree hierarchy.
26  * </p>
27  *
28  * @author <a HREF="mailto:dlestrat@apache.org">David Le Strat</a>
29  */

30 public class TreeTable implements Serializable JavaDoc
31 {
32     private DefaultTreeModel treeModel;
33
34     /**
35      * @param treeModel The treeModel.
36      */

37     public TreeTable(DefaultTreeModel treeModel)
38     {
39         this.treeModel = treeModel;
40     }
41
42     /**
43      * <p>
44      * Default constructor.
45      * </p>
46      */

47     public TreeTable()
48     {
49         DefaultMutableTreeNode root = new DefaultMutableTreeNode(new TreeItem(1, "XY", "9001", "XY 9001"));
50         DefaultMutableTreeNode a = new DefaultMutableTreeNode(new TreeItem(2, "A", "9001", "A 9001"));
51         root.insert(a);
52         DefaultMutableTreeNode b = new DefaultMutableTreeNode(new TreeItem(3, "B", "9001", "B 9001"));
53         root.insert(b);
54         DefaultMutableTreeNode c = new DefaultMutableTreeNode(new TreeItem(4, "C", "9001", "C 9001"));
55         root.insert(c);
56
57         DefaultMutableTreeNode node = new DefaultMutableTreeNode(new TreeItem(5, "a1", "9002", "a1 9002"));
58         a.insert(node);
59         node = new DefaultMutableTreeNode(new TreeItem(6, "a2", "9002", "a2 9002"));
60         a.insert(node);
61         node = new DefaultMutableTreeNode(new TreeItem(7, "a3", "9002", "a3 9002"));
62         a.insert(node);
63         node = new DefaultMutableTreeNode(new TreeItem(8, "b", "9002", "b 9002"));
64         b.insert(node);
65
66         a = node;
67         node = new DefaultMutableTreeNode(new TreeItem(9, "x1", "9003", "x1 9003"));
68         a.insert(node);
69         node = new DefaultMutableTreeNode(new TreeItem(9, "x2", "9003", "x2 9003"));
70         a.insert(node);
71         
72         this.treeModel = new DefaultTreeModel(root);
73     }
74
75     /**
76      * @return Returns the treeModel.
77      */

78     public DefaultTreeModel getTreeModel()
79     {
80         return treeModel;
81     }
82
83     /**
84      * @param treeModel The treeModel to set.
85      */

86     public void setTreeModel(DefaultTreeModel treeModel)
87     {
88         this.treeModel = treeModel;
89     }
90 }
91
Popular Tags