Exemple #1
0
 /**
  * 展开 javascript 树的所有节点
  *
  * @param prefix js变量前缀,不能为空
  * @param w 输出对象,如jsp中的out
  * @throws IOException
  */
 public void outputExpand(String prefix, Writer w) throws IOException {
   if (this.subItems.size() > 0) w.write(prefix + ".expand();\n");
   for (int i = 0; i < this.subItems.size(); i++) {
     TreeObject l = (TreeObject) this.subItems.get(i);
     l.outputExpand(prefix + "_" + i, w);
   }
 }
Exemple #2
0
 public TreeObject addSubItems(int oid, String name) {
   TreeObject to = new TreeObject();
   to.setName(name);
   to.setOid(oid);
   to.setParent(this);
   to.setParentOid(this.getOid());
   this.subItems.add(to);
   return to;
 }
Exemple #3
0
 /**
  * 输出 javascript 树
  *
  * @param prefix js变量前缀,不能为空
  * @param w 输出对象,如jsp中的out
  * @param href 超链接,href中的/oid/会被替换为对象的oid属性
  * @param alwayClickable 始终可以点击
  * @throws IOException
  */
 public void output(String prefix, Writer w, String href, boolean alwayClickable)
     throws IOException {
   w.write("var " + prefix + " = new Ext.tree.TreeNode({\n" + "text: '" + getName() + "',\n");
   if (alwayClickable || isClickable())
     w.write("href: '" + href.replaceAll("/oid/", "" + getOid()) + "',\n");
   w.write("draggable:false" + "});\n");
   for (int i = 0; i < this.subItems.size(); i++) {
     TreeObject l = (TreeObject) this.subItems.get(i);
     l.output(prefix + "_" + i, w, href, alwayClickable);
     w.write(prefix + ".appendChild(" + prefix + "_" + i + ");\n");
   }
 };
Exemple #4
0
 public void addSubItems(TreeObject to) {
   to.setParent(this);
   to.setParentOid(this.getOid());
   this.subItems.add(to);
 }