KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > examples > tree > TreeBacker


1 /*
2  * Copyright 2005 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.tree;
17
18 import org.apache.myfaces.custom.tree2.TreeNode;
19 import org.apache.myfaces.custom.tree2.TreeNodeBase;
20
21 /**
22  * Backer bean for use in example. Basically makes a TreeNode available.
23  *
24  * @author Sean Schofield
25  * @version $Revision: 1.1 $ $Date: 2005/03/24 16:47:11 $
26  */

27 public class TreeBacker
28 {
29     public TreeNode getTreeData()
30     {
31         TreeNode treeData = new TreeNodeBase("foo-folder", "Inbox", true);
32
33         // construct a set of fake data (normally your data would come from a database)
34

35         // populate Frank's portion of the tree
36
TreeNodeBase personNode = new TreeNodeBase("person", "Frank Foo", true);
37         personNode.getChildren().add(new TreeNodeBase("foo-folder", "Requires Foo", true));
38         TreeNodeBase folderNode = new TreeNodeBase("foo-folder", "Requires Foo Reviewer", true);
39         folderNode.getChildren().add(new TreeNodeBase("document", "X050001", false));
40         folderNode.getChildren().add(new TreeNodeBase("document", "X050002", false));
41         folderNode.getChildren().add(new TreeNodeBase("document", "X050003", false));
42         personNode.getChildren().add(folderNode);
43         personNode.getChildren().add(new TreeNodeBase("foo-folder", "Requires Foo Recommendation", true));
44         folderNode = new TreeNodeBase("foo-folder", "Requires Foo Approval", true);
45         folderNode.getChildren().add(new TreeNodeBase("document", "J050001", false));
46         folderNode.getChildren().add(new TreeNodeBase("document", "J050002", false));
47         folderNode.getChildren().add(new TreeNodeBase("document", "J050003", false));
48         folderNode.getChildren().add(new TreeNodeBase("document", "E050011", false));
49         folderNode.getChildren().add(new TreeNodeBase("document", "R050002", false));
50         folderNode.getChildren().add(new TreeNodeBase("document", "C050003", false));
51         personNode.getChildren().add(folderNode);
52         folderNode = new TreeNodeBase("bar-folder", "Requires Bar Processing", true);
53         folderNode.getChildren().add(new TreeNodeBase("document", "X050003", false));
54         folderNode.getChildren().add(new TreeNodeBase("document", "X050011", false));
55         folderNode.getChildren().add(new TreeNodeBase("document", "F050002", false));
56         folderNode.getChildren().add(new TreeNodeBase("document", "G050003", false));
57         personNode.getChildren().add(folderNode);
58         folderNode = new TreeNodeBase("bar-folder", "Requires Bar Approval", true);
59         folderNode.getChildren().add(new TreeNodeBase("document", "J050006", false));
60         folderNode.getChildren().add(new TreeNodeBase("document", "J050007", false));
61         personNode.getChildren().add(folderNode);
62
63         treeData.getChildren().add(personNode);
64
65         // populate Betty's portion of the tree
66
personNode = new TreeNodeBase("person", "Betty Bar", true);
67         personNode.getChildren().add(new TreeNodeBase("foo-folder", "Requires Foo", true));
68         folderNode = new TreeNodeBase("foo-folder", "Requires Foo Reviewer", true);
69         folderNode.getChildren().add(new TreeNodeBase("document", "X012000", false));
70         folderNode.getChildren().add(new TreeNodeBase("document", "X013000", false));
71         folderNode.getChildren().add(new TreeNodeBase("document", "X014000", false));
72         personNode.getChildren().add(folderNode);
73         folderNode = new TreeNodeBase("foo-folder", "Requires Foo Recommendation", true);
74         folderNode.getChildren().add(new TreeNodeBase("document", "J010026", false));
75         folderNode.getChildren().add(new TreeNodeBase("document", "J020002", false));
76         folderNode.getChildren().add(new TreeNodeBase("document", "J030103", false));
77         folderNode.getChildren().add(new TreeNodeBase("document", "E030214", false));
78         folderNode.getChildren().add(new TreeNodeBase("document", "R020444", false));
79         folderNode.getChildren().add(new TreeNodeBase("document", "C010000", false));
80         personNode.getChildren().add(folderNode);
81         personNode.getChildren().add(new TreeNodeBase("foo-folder", "Requires Foo Approval", true));
82         folderNode = new TreeNodeBase("bar-folder", "Requires Bar Processing", true);
83         folderNode.getChildren().add(new TreeNodeBase("document", "T052003", false));
84         folderNode.getChildren().add(new TreeNodeBase("document", "T020011", false));
85         personNode.getChildren().add(folderNode);
86         folderNode = new TreeNodeBase("bar-folder", "Requires Bar Approval", true);
87         folderNode.getChildren().add(new TreeNodeBase("document", "J010002", false));
88         folderNode.getChildren().add(new TreeNodeBase("document", "J030047", false));
89         folderNode.getChildren().add(new TreeNodeBase("document", "F030112", false));
90         personNode.getChildren().add(folderNode);
91
92         treeData.getChildren().add(personNode);
93
94         return treeData;
95     }
96
97     public TreeNode getSimpleTreeData()
98     {
99         TreeNode treeData = new TreeNodeBase("branch", "Inbox", true);
100
101         // construct a set of fake data (normally your data would come from a database)
102

103         // populate Frank's portion of the tree
104
TreeNodeBase branchNode = new TreeNodeBase("branch", "Frank Foo", true);
105         branchNode.getChildren().add(new TreeNodeBase("branch", "Requires Foo", true));
106         TreeNodeBase folderNode = new TreeNodeBase("branch", "Requires Foo Reviewer", true);
107         folderNode.getChildren().add(new TreeNodeBase("leaf", "X050001", false));
108         folderNode.getChildren().add(new TreeNodeBase("leaf", "X050002", false));
109         folderNode.getChildren().add(new TreeNodeBase("leaf", "X050003", false));
110         branchNode.getChildren().add(folderNode);
111         branchNode.getChildren().add(new TreeNodeBase("branch", "Requires Foo Recommendation", true));
112         folderNode = new TreeNodeBase("branch", "Requires Foo Approval", true);
113         folderNode.getChildren().add(new TreeNodeBase("leaf", "J050001", false));
114         folderNode.getChildren().add(new TreeNodeBase("leaf", "J050002", false));
115         folderNode.getChildren().add(new TreeNodeBase("leaf", "J050003", false));
116         folderNode.getChildren().add(new TreeNodeBase("leaf", "E050011", false));
117         folderNode.getChildren().add(new TreeNodeBase("leaf", "R050002", false));
118         folderNode.getChildren().add(new TreeNodeBase("leaf", "C050003", false));
119         branchNode.getChildren().add(folderNode);
120         folderNode = new TreeNodeBase("branch", "Requires Bar Processing", true);
121         folderNode.getChildren().add(new TreeNodeBase("leaf", "X050003", false));
122         folderNode.getChildren().add(new TreeNodeBase("leaf", "X050011", false));
123         folderNode.getChildren().add(new TreeNodeBase("leaf", "F050002", false));
124         folderNode.getChildren().add(new TreeNodeBase("leaf", "G050003", false));
125         branchNode.getChildren().add(folderNode);
126         folderNode = new TreeNodeBase("branch", "Requires Bar Approval", true);
127         folderNode.getChildren().add(new TreeNodeBase("leaf", "J050006", false));
128         folderNode.getChildren().add(new TreeNodeBase("leaf", "J050007", false));
129         branchNode.getChildren().add(folderNode);
130
131         treeData.getChildren().add(branchNode);
132
133         // populate Betty's portion of the tree
134
branchNode = new TreeNodeBase("branch", "Betty Bar", true);
135         branchNode.getChildren().add(new TreeNodeBase("branch", "Requires Foo", true));
136         folderNode = new TreeNodeBase("branch", "Requires Foo Reviewer", true);
137         folderNode.getChildren().add(new TreeNodeBase("leaf", "X012000", false));
138         folderNode.getChildren().add(new TreeNodeBase("leaf", "X013000", false));
139         folderNode.getChildren().add(new TreeNodeBase("leaf", "X014000", false));
140         branchNode.getChildren().add(folderNode);
141         folderNode = new TreeNodeBase("branch", "Requires Foo Recommendation", true);
142         folderNode.getChildren().add(new TreeNodeBase("leaf", "J010026", false));
143         folderNode.getChildren().add(new TreeNodeBase("leaf", "J020002", false));
144         folderNode.getChildren().add(new TreeNodeBase("leaf", "J030103", false));
145         folderNode.getChildren().add(new TreeNodeBase("leaf", "E030214", false));
146         folderNode.getChildren().add(new TreeNodeBase("leaf", "R020444", false));
147         folderNode.getChildren().add(new TreeNodeBase("leaf", "C010000", false));
148         branchNode.getChildren().add(folderNode);
149         branchNode.getChildren().add(new TreeNodeBase("branch", "Requires Foo Approval", true));
150         folderNode = new TreeNodeBase("branch", "Requires Bar Processing", true);
151         folderNode.getChildren().add(new TreeNodeBase("leaf", "T052003", false));
152         folderNode.getChildren().add(new TreeNodeBase("leaf", "T020011", false));
153         branchNode.getChildren().add(folderNode);
154         folderNode = new TreeNodeBase("branch", "Requires Bar Approval", true);
155         folderNode.getChildren().add(new TreeNodeBase("leaf", "J010002", false));
156         folderNode.getChildren().add(new TreeNodeBase("leaf", "J030047", false));
157         folderNode.getChildren().add(new TreeNodeBase("leaf", "F030112", false));
158         branchNode.getChildren().add(folderNode);
159
160         treeData.getChildren().add(branchNode);
161
162         return treeData;
163
164     }
165 }
166
Popular Tags