001: package com.opensymphony.webwork.views.jsp.ui;
002:
003: import java.util.ArrayList;
004: import java.util.HashMap;
005: import java.util.List;
006: import java.util.Map;
007:
008: /**
009: * Used by Tree Component Test. Copied from showcase.
010: */
011: public class Category {
012: private static Map catMap = new HashMap();
013:
014: static {
015: new Category(
016: 1,
017: "Root",
018: new Category[] {
019: new Category(
020: 2,
021: "Java",
022: new Category[] {
023: new Category(
024: 3,
025: "Web Frameworks",
026: new Category[] {
027: new Category(4,
028: "WebWork"),
029: new Category(5,
030: "Struts Action"),
031: new Category(6,
032: "Struts Shale"),
033: new Category(7,
034: "Stripes"),
035: new Category(8,
036: "Rife") }),
037: new Category(
038: 9,
039: "Persistence",
040: new Category[] {
041: new Category(
042: 10,
043: "iBatis"),
044: new Category(
045: 11,
046: "Hibernate"),
047: new Category(
048: 12,
049: "JDO"),
050: new Category(
051: 13,
052: "JDBC") }) }),
053: new Category(14, "JavaScript", new Category[] {
054: new Category(15, "Dojo"),
055: new Category(16, "Prototype"),
056: new Category(17, "Scriptaculous"),
057: new Category(18, "OpenRico"),
058: new Category(19, "DWR") }) });
059: }
060:
061: public static Category getById(long id) {
062: return (Category) catMap.get(new Long(id));
063: }
064:
065: private long id;
066: private String name;
067: private List children;
068: private boolean toggle;
069:
070: public Category(long id, String name) {
071: this (id, name, new Category[0]);
072: }
073:
074: public Category(long id, String name, Category[] children) {
075: this .id = id;
076: this .name = name;
077: this .children = new ArrayList();
078: for (int a = 0; a < children.length; a++) {
079: this .children.add(children[a]);
080: }
081:
082: catMap.put(new Long(id), this );
083: }
084:
085: public long getId() {
086: return id;
087: }
088:
089: public void setId(long id) {
090: this .id = id;
091: }
092:
093: public String getName() {
094: return name;
095: }
096:
097: public void setName(String name) {
098: this .name = name;
099: }
100:
101: public List getChildren() {
102: return children;
103: }
104:
105: public void setChildren(List children) {
106: this .children = children;
107: }
108:
109: public void toggle() {
110: toggle = !toggle;
111: }
112:
113: public boolean isToggle() {
114: return toggle;
115: }
116: }
|