1 15 package org.apache.tapestry.workbench.tree.examples; 16 17 import java.util.Date ; 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 30 public abstract class SimpleTree extends BasePage 31 { 32 private ITreeDataModel treeDataModel; 33 34 private ITreeModel treeModel; 35 36 private Object 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 getCurrentTime() 72 { 73 return new Date (); 74 } 75 76 public ITreeModel getTreeModel() 77 { 78 if (treeModel == null) 79 { 80 init(); 81 } 82 return treeModel; 83 } 84 85 90 public Object getValue() 91 { 92 return value; 93 } 94 95 101 public void setValue(Object value) 102 { 103 this.value = value; 104 } 105 } | Popular Tags |