View Javadoc
1 package net.sf.flock.webapp.tree; 2 3 import net.sf.tapestry.IAsset; 4 import net.sf.tapestry.IMarkupWriter; 5 import net.sf.tapestry.IRequestCycle; 6 import net.sf.tapestry.RequestCycleException; 7 import net.sf.tapestry.html.Body; 8 9 public class XTree extends Tree { 10 11 private final static String[] ICONS = new String[] { 12 "rootIcon", 13 "openRootIcon", 14 "folderIcon", 15 "openFolderIcon", 16 "fileIcon", 17 "iIcon", 18 "lIcon", 19 "lMinusIcon", 20 "lPlusIcon", 21 "tIcon", 22 "tMinusIcon", 23 "tPlusIcon", 24 "blankIcon" 25 }; 26 27 /*** 28 * @see net.sf.tapestry.AbstractComponent#renderComponent(IMarkupWriter, IRequestCycle) 29 */ 30 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) throws RequestCycleException { 31 // get Body and contribute script asset 32 Body body = Body.get(cycle); 33 IAsset script = this.getAsset("xtreeScript"); 34 body.includeScript( script.buildURL(cycle) ); 35 36 writer.printRaw("<link rel='stylesheet' type='text/css' href='" + this.getAsset("xtreeStylesheet").buildURL(cycle) +"'/>"); 37 38 writer.begin("script"); 39 writer.attribute("language", "JavaScript"); 40 writer.print("if (document.getElementById) {\n"); 41 42 // generate tree config 43 writer.print("webFXTreeConfig = {\n"); 44 for (int i=0; i<ICONS.length; i++) { 45 String url = this.getAsset( ICONS[i] ).buildURL(cycle); 46 body.getPreloadedImageReference( url ); 47 writer.printRaw( ICONS[i] + ": '" + url + "',\n" ); 48 } 49 writer.print("defaultText : 'Tree Item',\n"); 50 writer.print("defaultAction : 'javascript:void(0);',\n"); 51 writer.print("defaultBehavior : 'classic'\n"); 52 writer.print("};\n"); 53 54 super.renderComponent(writer, cycle); 55 56 writer.print("document.write(t1); }"); 57 writer.end(); 58 } 59 60 /*** 61 * @see net.sf.flock.webapp.tree.Tree#renderCurrentNode(IMarkupWriter, IRequestCycle) 62 */ 63 protected void renderCurrentNode(IMarkupWriter writer, IRequestCycle cycle) throws RequestCycleException { 64 if (this.getDepth()==1) { 65 writer.print( "t1 = new WebFXTree('" + this.getValue().getId() + "');\n"); 66 } else { 67 writer.print( "t" + this.getDepth() +" = new WebFXTreeItem('" + this.getValue().getId() + "');\n"); 68 writer.print( "t" + (this.getDepth()-1)+".add( t" + this.getDepth() + " );\n" ); 69 } 70 } 71 72 }

This page was automatically generated by Maven