KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > workbench > tree > examples > SimpleTree


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

15 package org.apache.tapestry.workbench.tree.examples;
16
17 import java.util.Date JavaDoc;
18
19 import org.apache.tapestry.contrib.tree.model.ITreeDataModel;
20 import org.apache.tapestry.contrib.tree.model.ITreeModel;
21 import org.apache.tapestry.contrib.tree.simple.SimpleTreeDataModel;
22 import org.apache.tapestry.contrib.tree.simple.SimpleTreeModel;
23 import org.apache.tapestry.html.BasePage;
24
25 /**
26  * Simple example page.
27  *
28  * @version $Revision: 1.6 $
29  */

30 public abstract class SimpleTree extends BasePage
31 {
32     private ITreeDataModel treeDataModel;
33
34     private ITreeModel treeModel;
35
36     private Object JavaDoc value;
37
38     public SimpleTree()
39     {
40     }
41
42     public void detach()
43     {
44         super.detach();
45         treeDataModel = null;
46         value = null;
47     }
48
49     public void init()
50     {
51         TestTreeNode objParent = new TestTreeNode("Parent");
52
53         TestTreeNode objChild1 = new TestTreeNode("Child1");
54         TestTreeNode objChild2 = new TestTreeNode("Child2");
55         TestTreeNode objChild3 = new TestTreeNode("Child3");
56
57         objParent.insert(objChild3);
58         objParent.insert(objChild2);
59         objParent.insert(objChild1);
60
61         TestTreeNode objChild31 = new TestTreeNode("Child31");
62         TestTreeNode objChild32 = new TestTreeNode("Child32");
63
64         objChild3.insert(objChild32);
65         objChild3.insert(objChild31);
66
67         treeDataModel = new SimpleTreeDataModel(objParent);
68         treeModel = new SimpleTreeModel(treeDataModel);
69     }
70
71     public Date JavaDoc getCurrentTime()
72     {
73         return new Date JavaDoc();
74     }
75
76     public ITreeModel getTreeModel()
77     {
78         if (treeModel == null)
79         {
80             init();
81         }
82         return treeModel;
83     }
84
85     /**
86      * Returns the value.
87      *
88      * @return Object
89      */

90     public Object JavaDoc getValue()
91     {
92         return value;
93     }
94
95     /**
96      * Sets the value.
97      *
98      * @param value
99      * The value to set
100      */

101     public void setValue(Object JavaDoc value)
102     {
103         this.value = value;
104     }
105 }
Popular Tags