Package org.tree.entity

Examples of org.tree.entity.TreeNode


    if (nodes == null || nodes.size() == 0) {
      return null;
    }
    html.append("<ul>");
    for (int i = 0; nodes != null && i < nodes.size(); i++) {
      TreeNode treeNode = nodes.get(i);

      // htmlsrc
      html.append("<li");
     
      if (this.isLeaf(tree,treeNode)) {// 叶子
        if(i == nodes.size() -1){//last
          this.prepareAttribute(html, "class","last");
        }
      } else {// 父节点
        if(i == nodes.size() -1){//last
          this.prepareAttribute(html, "class","closed lastclosed");
        }else{
          this.prepareAttribute(html, "class","closed");
        }
        this.prepareAttribute(html, TreeService.TREE_PARENTID_VAR,tree.getId());
      }

      // params
      Map<String, Object> allParam = new HashMap<String, Object>();
      if (parameters != null) {
        allParam.putAll(parameters);
      }
      Map<String, String> treeNodeParameters = treeNode.getParameters();
      if (treeNodeParameters != null) {
        allParam.putAll(treeNodeParameters);
      }
      allParam.remove(TreeService.TREE_ID_VAR);
      allParam.remove(TreeService.TREE_PARENTID_VAR);
      prepareParameters(html, allParam);

      // url
      if (treeNode.getUrl() != null) {
        this.prepareAttribute(html, "url", treeNode.getUrl());
      }

      // otherAttributes
      Map<String, String> attributes = treeNode.getAttributes();
      if (attributes != null) {
        Iterator<String> attributeKeys = treeNode.getAttributes()
            .keySet().iterator();
        while (attributeKeys.hasNext()) {
          String att = attributeKeys.next();
          prepareAttribute(html, att, treeNode.getAttributes().get(
              att));
        }
      }
      // end otherAttributes
     
      // end <li>
      html.append(" >");
     
      // span
      if (this.isLeaf(tree,treeNode)) {
        html.append("<span class='file'>");
      }else{
        if(i == nodes.size() -1){//last folder
          html.append("<div class='hit closed-hit lastclosed-hit' onclick='$att(this);'></div>");
        }else{
          html.append("<div class='hit closed-hit' onclick='$att(this);'></div>");
        }
        html.append("<span class='folder' onclick='$att(this);'>");
      }
      // a
      html.append("<a href='javascript:void(0);' onclick='$atc(this)'>");
      html.append(StringEscapeUtils.escapeHtml(treeNode.getText()));
      html.append("</a>");
      html.append("</span>");
      //end  </li>
      html.append("</li>");
View Full Code Here


//              +","+svnDirEntry.getKind()//类型,参考SVNNodeKind.FILE,SVNNodeKind.DIR
//              +","+svnDirEntry.getRevision()//版本
//              +","+svnDirEntry.getAuthor()//作者
//              +","+svnDirEntry.getSize()//如果kind是SVNNodeKind.FILE时返回文件的大小
//              +","+svnDirEntry.getDate());//日期
           TreeNode treeNode = new TreeNode(svnDirEntry.getName());
           treeNode.setLeaf(SVNNodeKind.FILE.equals(svnDirEntry.getKind()));//叶子?
           treeNode.addParamete("pj", pj);
           if(path.endsWith("/")){
             treeNode.addParamete("path", path+StringUtils.replace(svnDirEntry.getName(), "&", AND));
           }else{
             treeNode.addParamete("path", path+"/"+StringUtils.replace(svnDirEntry.getName(), "&", AND));
           }
           results.add(treeNode);
      }
      Collections.sort(results);// 排序
    } catch (Exception e) {
        LOG.error(e.getMessage());
      e.printStackTrace();
     
        results.clear();
        TreeNode errorNode = new TreeNode(e.getMessage());
        errorNode.setLeaf(true);
        results.add(errorNode);
        return results;
    }
   
      return results;
View Full Code Here

TOP

Related Classes of org.tree.entity.TreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.