1 12 13 18 package com.openedit.webui.tree; 19 20 import java.util.Iterator ; 21 import java.util.List ; 22 23 28 public class WebTreeNodeTreeRenderer extends BaseTreeRenderer 29 { 30 protected boolean fieldFriendlyNames = false; 31 32 public WebTreeNodeTreeRenderer(WebTree inWebTree) 33 { 34 super( inWebTree ); 35 } 36 37 public boolean isFriendlyNames() 38 { 39 return fieldFriendlyNames; 40 } 41 42 public void setFriendlyNames(boolean inFriendlyNames) 43 { 44 fieldFriendlyNames = inFriendlyNames; 45 } 46 47 50 public String toName(Object inNode) 51 { 52 DefaultWebTreeNode node = (DefaultWebTreeNode)inNode; 53 String name = node.getName(); 54 if( isFriendlyNames()) 55 { 56 name = name.replace('_', ' '); 57 name = name.substring(0,1).toUpperCase() + name.substring(1); 58 59 int p = name.lastIndexOf('.'); 60 if ( p > 0 ) 61 { 62 name = name.substring(0,p); 63 } 64 } 65 return name; 66 } 67 68 71 public String toUrl(Object inNode) 72 { 73 DefaultWebTreeNode node = (DefaultWebTreeNode)inNode; 74 75 return node.getURL(); 76 } 77 78 81 public String toId(Object inNode) 82 { 83 DefaultWebTreeNode node = (DefaultWebTreeNode)inNode; 84 85 return node.getID(); 86 } 87 88 public void expandAll(Object inRoot) 89 { 90 expandNode(inRoot); 91 List children = getWebTree().getModel().getChildren(inRoot); 92 for (Iterator iterator = children.iterator(); iterator.hasNext();) 93 { 94 Object object = (Object ) iterator.next(); 95 expandAll(object); 96 } 97 } 98 99 } 100 | Popular Tags |