1 4 package org.oddjob.webapp.struts.forms; 5 6 import java.io.Serializable ; 7 import java.util.ArrayList ; 8 import java.util.Collection ; 9 import java.util.HashMap ; 10 import java.util.Map ; 11 12 16 public class TreeNodeBean implements Serializable { 17 private static final long serialVersionUID = 20051229; 18 19 private transient TreeNodeBeanBuilder builder; 20 21 22 private String refId; 23 24 25 private transient String nodeName; 26 27 28 private Map childCollection; 29 30 31 private boolean showChildren; 32 33 34 private int depth; 35 36 37 private transient String iconId; 38 39 private boolean hasChildren; 40 41 public void setTreeNodeBeanBuilder(TreeNodeBeanBuilder builder){ 42 this.builder = builder; 43 } 44 45 48 public Collection getChildCollection() { 49 if (childCollection == null) { 50 return null; 51 } 52 return new ArrayList (childCollection.values()); 53 } 54 55 void setChildMap(Map childMap) { 56 this.childCollection = childMap; 57 } 58 59 Map getChildMap() { 60 return childCollection; 61 } 62 63 68 public String getNodeName() { 69 return nodeName; 70 } 71 72 77 public void setNodeName(String nodeName) { 78 this.nodeName = nodeName; 79 } 80 81 84 public int getDepth() { 85 return depth; 86 } 87 88 93 public void setDepth(int depth) { 94 this.depth = depth; 95 } 96 97 102 public int getNodeIndent() { 103 return 20 * depth; 104 } 105 106 112 public boolean getShowChildren() { 113 return this.showChildren; 114 } 115 116 121 public boolean getHasChildren() { 122 return hasChildren; 123 } 124 125 public void setHasChildren(boolean hasChildren) { 126 this.hasChildren = hasChildren; 127 if (!hasChildren) { 128 showChildren = false; 129 } 130 } 131 132 137 public TreeNodeBean getExpand() { 138 showChildren = true; 139 if (childCollection == null) { 140 childCollection = builder.buildChildren(this); 143 } 144 return this; 145 } 146 147 150 public TreeNodeBean getCollapse() { 151 showChildren = false; 152 childCollection = null; 153 return this; 154 } 155 156 161 public void setX(int i) { 162 } 163 164 169 public void setY(int i) { 170 } 171 172 173 public String getRefId() { 174 return refId; 175 } 176 177 public void setRefId(String refId) { 178 this.refId = refId; 179 } 180 181 public void setIconId(String iconId) { 182 this.iconId = iconId; 183 } 184 185 public String getIconId() { 186 return iconId; 187 } 188 189 public Map getRequest() { 190 Map map = new HashMap (); 191 map.put("refId", refId); 192 return map; 193 } 194 195 public Map getIconIdRequest() { 196 Map map = new HashMap (); 197 map.put("iconId", iconId); 198 return map; 199 } 200 } | Popular Tags |