1 23 24 package org.infoglue.cms.plugins.opentree; 25 26 import java.util.Iterator ; 27 import java.util.List ; 28 29 import javax.swing.tree.DefaultMutableTreeNode ; 30 31 public class CMSNode extends DefaultMutableTreeNode 32 { 33 private Controller controller = null; 34 private Integer id = null; 35 private String name = null; 36 private boolean isBranch = false; 37 38 private boolean areChildrenDefined = false; 39 40 41 public CMSNode(Controller controller, boolean isBranch) 42 { 43 this.controller = controller; 44 this.isBranch = isBranch; 45 } 46 47 public Integer getId() 48 { 49 return this.id; 50 } 51 52 public void setId(Integer id) 53 { 54 this.id = id; 55 } 56 57 public void setName(String name) 58 { 59 this.name = name; 60 } 61 62 public String getName() 63 { 64 return this.name; 65 } 66 67 public String toString() 68 { 69 return this.name; 70 } 71 72 public int getChildCount() 73 { 74 if (!areChildrenDefined) 76 defineChildNodes(); 77 return (super.getChildCount()); 78 } 79 80 private void defineChildNodes() 81 { 82 areChildrenDefined = true; 83 this.removeAllChildren(); 85 List childNodes = controller.getChildNodes(this.id); 87 Iterator iterator = childNodes.iterator(); 88 while(iterator.hasNext()) 89 { 90 add((CMSNode)iterator.next()); 91 } 92 } 93 94 public void setAreChildrenDefined(boolean areChildrenDefined) 95 { 96 this.areChildrenDefined = areChildrenDefined; 97 getChildCount(); 98 } 99 100 public boolean isLeaf() 101 { 102 return !this.isBranch; 103 } 104 } | Popular Tags |