1 23 package org.objectweb.clif.scenario.util.isac.plugin.gui; 24 25 import java.util.Enumeration ; 26 import java.util.Hashtable ; 27 import java.util.Vector ; 28 29 import org.apache.log4j.Category; 30 import org.objectweb.clif.scenario.util.isac.plugin.ParameterDescription; 31 import org.objectweb.clif.scenario.util.isac.util.tree.Node; 32 import org.objectweb.clif.scenario.util.isac.util.tree.TreeManager; 33 34 40 public class ParametersWidgetsNode { 41 static Category cat = Category.getInstance(ParametersWidgetsNode.class 42 .getName()); 43 44 private WidgetDescription widget; 45 private ParametersWidgetsNode parent; 46 private Vector children; 47 48 54 public ParametersWidgetsNode(WidgetDescription wd) { 55 cat.debug("-> constructor"); 56 this.widget = wd; 57 this.parent = null; 58 this.children = new Vector (); 59 } 60 61 64 public ParametersWidgetsNode getParent() { 65 cat.debug("-> getParent"); 66 return parent; 67 } 68 72 public void setParent(ParametersWidgetsNode parent) { 73 cat.debug("-> setParent"); 74 this.parent = parent; 75 } 76 77 83 public void addChild(ParametersWidgetsNode child) { 84 cat.debug("-> addChild"); 85 this.children.add(child); 86 } 87 88 91 public Vector getChildren() { 92 cat.debug("-> getChildren"); 93 return children; 94 } 95 96 107 public static ParametersWidgetsNode createParametersWidgetsNode( 108 Enumeration parametersNames, String type, String plugin) { 109 cat.debug("-> createParametersWidgetsNode"); 110 ParametersWidgetsNode root = new ParametersWidgetsNode(null); 111 cat.warn("THE PWN CREATED IS TYPE : " + type); 113 cat.warn("THE PLUGIN OF THIS ACTION IS : " + plugin); 114 while (parametersNames.hasMoreElements()) { 115 116 ParameterDescription param = (ParameterDescription) parametersNames 117 .nextElement(); 118 cat.warn(" Parameter : " + param.getName()); 119 if (!param.getName().equals("id")) { 122 WidgetDescription desc = new WidgetDescription( 123 WidgetDescription.TEXT_FIELD, param.getName(),null, null); 124 root.addChild(new ParametersWidgetsNode(desc)); 126 } else { 127 if (Node.isPluginNode(type)) { 128 if (Node.USE.equals(type)) { 129 WidgetDescription desc = new WidgetDescription( 131 WidgetDescription.TEXT_FIELD, "id",null, null); 132 root.addChild(new ParametersWidgetsNode(desc)); 133 } else { 134 Vector ids = (TreeManager.getTreeManager(null)) 135 .getPluginObjectByName(plugin); 136 Hashtable params = new Hashtable (); 138 params.put("choices", ids); 140 WidgetDescription desc = new WidgetDescription( 141 WidgetDescription.COMBO, "id",null, params); 142 root.addChild(new ParametersWidgetsNode(desc)); 143 } 144 } else { 145 WidgetDescription desc = new WidgetDescription( 146 WidgetDescription.TEXT_FIELD, param.getName(),null, null); 147 root.addChild(new ParametersWidgetsNode(desc)); 149 } 150 } 151 } 152 return root; 153 } 154 155 158 public WidgetDescription getWidget() { 159 cat.debug("-> getWidget"); 160 return widget; 161 } 162 163 public String toString() { 164 String result = ""; 165 cat.debug("-> constructor"); 166 if (this.widget != null) 167 result = "Widget : \n" + this.widget.toString(); 168 if (this.children != null) { 169 result = result + "this ParametersWidgetsNode has " 170 + this.children.size() + " childrens;\n"; 171 for (int i = 0; i < children.size(); i++) { 172 result = result.concat(((ParametersWidgetsNode) this.children 173 .elementAt(i)).toString()); 174 } 175 } 176 return result; 177 } 178 } | Popular Tags |