View Javadoc
1 package net.sf.flock.webapp.tree; 2 3 import java.util.Collection; 4 import java.util.Iterator; 5 6 import net.sf.tapestry.AbstractComponent; 7 import net.sf.tapestry.IBinding; 8 import net.sf.tapestry.IMarkupWriter; 9 import net.sf.tapestry.IRequestCycle; 10 import net.sf.tapestry.RequestCycleException; 11 import net.sf.flock.tree.ITreeNode; 12 13 public class Tree extends AbstractComponent { 14 15 private ITreeNode rootNode; 16 17 private int depth = 0; 18 private ITreeNode value; 19 private IBinding valueBinding; 20 21 22 public ITreeNode getRootNode() { 23 return rootNode; 24 } 25 26 public void setRootNode(ITreeNode rootNode) { 27 this.rootNode = rootNode; 28 } 29 30 31 public int getDepth() { 32 return depth; 33 } 34 35 public ITreeNode getValue() { 36 return this.value; 37 } 38 39 public IBinding getValueBinding() { 40 return valueBinding; 41 } 42 43 public void setValueBinding(IBinding valueBinding) { 44 this.valueBinding = valueBinding; 45 } 46 47 /*** 48 * @see net.sf.tapestry.AbstractComponent#renderComponent(IMarkupWriter, IRequestCycle) 49 */ 50 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) throws RequestCycleException { 51 this.enterChildren(writer, cycle); 52 this.renderNodes(writer, cycle, this.rootNode); 53 this.leaveChildren(writer, cycle); 54 } 55 56 protected void renderNodes(IMarkupWriter writer, IRequestCycle cycle, ITreeNode node) throws RequestCycleException { 57 this.depth++; 58 this.value = node; 59 if (this.valueBinding!=null) { 60 this.valueBinding.setObject(value); 61 } 62 63 this.enterNode(writer, cycle); 64 65 this.renderCurrentNode(writer, cycle); 66 67 Collection children = node.getChildren(); 68 if (children!=null) { 69 this.enterChildren(writer, cycle); 70 for (Iterator i=children.iterator(); i.hasNext(); ) { 71 this.renderNodes( writer, cycle, (ITreeNode)i.next() ); 72 } 73 this.leaveChildren(writer, cycle); 74 } 75 76 this.leaveNode(writer, cycle); 77 78 this.depth--; 79 } 80 81 82 protected void enterNode(IMarkupWriter writer, IRequestCycle cycle) throws RequestCycleException { 83 } 84 85 protected void leaveNode(IMarkupWriter writer, IRequestCycle cycle) throws RequestCycleException { 86 } 87 88 protected void enterChildren(IMarkupWriter writer, IRequestCycle cycle) throws RequestCycleException { 89 } 90 91 protected void leaveChildren(IMarkupWriter writer, IRequestCycle cycle) throws RequestCycleException { 92 } 93 94 protected void renderCurrentNode(IMarkupWriter writer, IRequestCycle cycle) throws RequestCycleException { 95 this.renderBody(writer, cycle); 96 } 97 98 }

This page was automatically generated by Maven