directoryview.java
来自「cwbbs 云网论坛源码」· Java 代码 · 共 1,085 行 · 第 1/4 页
JAVA
1,085 行
package cn.js.fan.module.cms;import java.util.*;import javax.servlet.http.*;import javax.servlet.jsp.*;import cn.js.fan.module.cms.plugin.*;import cn.js.fan.module.pvg.*;import cn.js.fan.util.*;import cn.js.fan.web.*;import org.apache.log4j.*;public class DirectoryView { public Logger logger; public Leaf rootLeaf; public Vector UprightLineNodes = new Vector(); HttpServletRequest request; public DirectoryView(Leaf rootLeaf) { this.rootLeaf = rootLeaf; logger = Logger.getLogger(Leaf.class.getName()); } public DirectoryView(HttpServletRequest request, Leaf rootLeaf) { this.rootLeaf = rootLeaf; this.request = request; } public void ListSimpleAjax(JspWriter out, String target, String link, String tableClass, String tableClassMouseOn, boolean isShowRoot) throws Exception { Privilege privilege = new Privilege(); ListTreeSimpleAjax(privilege, out, rootLeaf, true, target, link, tableClass, tableClassMouseOn, isShowRoot); } public void SelectSingleAjax(JspWriter out, String func, String tableClass, String tableClassMouseOn, boolean isShowRoot) throws Exception { Privilege privilege = new Privilege(); SelectTreeSingleAjax(privilege, out, rootLeaf, func, tableClass, tableClassMouseOn, isShowRoot); } void SelectTreeSingleAjax(Privilege privilege, JspWriter out, Leaf leaf, String func, String tableClass, String tableClassMouseOn, boolean isShowRoot) throws Exception { if (isShowRoot) ShowLeafSingleAjax(privilege, out, leaf, func, tableClass, tableClassMouseOn); Directory dir = new Directory(); Vector children = dir.getChildren(leaf.getCode()); int size = children.size(); if (size == 0) return; int i = 0; if (size > 0) out.print("<table id='childof" + leaf.getCode() + "' cellspacing=0 cellpadding=0 width='100%' align=center><tr><td>"); Iterator ri = children.iterator(); while (ri.hasNext()) { i++; Leaf childlf = (Leaf) ri.next(); ShowLeafSingleAjax(privilege, out, childlf, func, tableClass, tableClassMouseOn); } if (size > 0) out.print("</td></tr></table>"); } void ShowLeafSingleAjax(Privilege privilege, JspWriter out, Leaf leaf, String func, String tableClass, String tableClassMouseOn) throws Exception { String code = leaf.getCode(); String name = leaf.getName(); int layer = leaf.getLayer(); int childcount = leaf.getChildCount(); String tableid = leaf.getCode(); out.println("<table id=" + tableid + " name=" + tableid + " class='" + tableClass + "' cellspacing=0 cellpadding=0 width='100%' align=center onMouseOver=\"this.className='" + tableClassMouseOn + "'\" onMouseOut=\"this.className='" + tableClass + "'\" border=0>"); out.println(" <tbody><tr>"); out.println(" <td height='20' align=left nowrap>"); int padWidth = 0; for (int k = 1; k <= layer - 1; k++) { padWidth += 21; } if (childcount==0) padWidth += 16; out.print("<img src='' width=" + padWidth + " height=1>"); if (leaf.getCode().equals(rootLeaf.getCode())) { out.println("<img onClick=\"ShowChild(this, '" + tableid + "')\" src='images/i_puls-root.gif' align='absmiddle'><img src='images/folder_01.gif' align='absmiddle'>"); } else { if (childcount > 0) out.println("<img onClick=\"ShowChild(this, '" + tableid + "')\" src='images/i_plus.gif' align='absmiddle'><img src='' width=3px height=1><img src='images/folder_01.gif' align='absmiddle'>"); else out.println("<img src='images/folder_01.gif' align='absmiddle'>"); } if (leaf.getType()==Leaf.TYPE_COLUMN) { out.print( "<a href=\"javascript:" + func + "('" + code + "','" + name + "')\" class=\"column\">" + name + "</a>"); } else if (leaf.getType() == Leaf.TYPE_SUB_SITE) { out.print( "<a href=\"javascript:" + func + "('" + code + "','" + name + "')\" class=\"subsite\">" + name + "</a>"); } else { out.print( "<a href=\"javascript:" + func + "('" + code + "','" + name + "')\">" + name + "</a>"); } out.print(" </td>"); out.println(" </tr></tbody></table>"); LeafPriv lp = new LeafPriv(leaf.getCode()); if (!lp.canUserSeeWithAncestorNode(privilege.getUser(request))) { if (!leaf.getCode().equals("root")) { out.println("<script>\n"); out.println("tableid.style.display='none';\n"); out.println("</script>\n"); } } } void ListTreeSimpleAjax(Privilege privilege, JspWriter out, Leaf leaf, boolean isLastChild, String target, String link, String tableClass, String tableClassMouseOn, boolean isShowRoot) throws Exception { if (isShowRoot) ShowLeafSimpleAjax(privilege, out, leaf, isLastChild, target, link, tableClass, tableClassMouseOn); Directory dir = new Directory(); Vector children = dir.getChildren(leaf.getCode()); int size = children.size(); if (size == 0) return; int i = 0; if (size > 0) out.print("<table id='childof" + leaf.getCode() + "' cellspacing=0 cellpadding=0 width='100%' align=center><tr><td>"); Iterator ri = children.iterator(); while (ri.hasNext()) { i++; Leaf childlf = (Leaf) ri.next(); boolean isLastChild1 = true; if (size != i) isLastChild1 = false; ShowLeafSimpleAjax(privilege, out, childlf, isLastChild, target, link, tableClass, tableClassMouseOn); } if (size > 0) out.print("</td></tr></table>"); } public void ListSimple(JspWriter out, String target, String link, String tableClass, String tableClassMouseOn) throws Exception { Privilege privilege = new Privilege(); ListTreeSimple(privilege, out, rootLeaf, true, target, link, tableClass, tableClassMouseOn); } void ListTreeSimple(Privilege privilege, JspWriter out, Leaf leaf, boolean isLastChild, String target, String link, String tableClass, String tableClassMouseOn) throws Exception { ShowLeafSimple(privilege, out, leaf, isLastChild, target, link, tableClass, tableClassMouseOn); Directory dir = new Directory(); Vector children = dir.getChildren(leaf.getCode()); int size = children.size(); if (size == 0) return; int i = 0; if (size > 0) out.print("<table id='childoftable" + leaf.getCode() + "' cellspacing=0 cellpadding=0 width='100%' align=center><tr><td>"); Iterator ri = children.iterator(); while (ri.hasNext()) { i++; Leaf childlf = (Leaf) ri.next(); boolean isLastChild1 = true; if (size != i) isLastChild1 = false; ListTreeSimple(privilege, out, childlf, isLastChild1, target, link, tableClass, tableClassMouseOn); } if (size > 0) out.print("</td></tr></table>"); } void ShowLeafSimple(Privilege privilege, JspWriter out, Leaf leaf, boolean isLastChild, String target, String link, String tableClass, String tableClassMouseOn) throws Exception { String code = leaf.getCode(); String name = leaf.getName(); int layer = leaf.getLayer(); String description = leaf.getDescription(); if (!isLastChild) { Leaf brotherleaf = leaf.getBrother("down"); if (brotherleaf != null) { Vector r = new Vector(); leaf.getAllChild(r, leaf); int count = r.size(); if (count>0) { UprightLineNode uln = new UprightLineNode(layer, count); UprightLineNodes.addElement(uln); } } } int childcount = leaf.getChildCount(); String tableid = "table" + leaf.getCode(); out.println("<table id=" + tableid + " name=" + tableid + " class='" + tableClass + "' cellspacing=0 cellpadding=0 width='100%' align=center onMouseOver=\"this.className='" + tableClassMouseOn + "'\" onMouseOut=\"this.className='" + tableClass + "'\" border=0>"); out.println(" <tbody><tr>"); out.println(" <td height='13' align=left nowrap>"); for (int k = rootLeaf.getLayer(); k <= layer - 1; k++) { boolean isShowed = false; Iterator ir = UprightLineNodes.iterator(); while (ir.hasNext()) { UprightLineNode node = (UprightLineNode) ir.next(); if (node.getLayer() == k) { node.show(out, "images/i_plus-2.gif"); if (node.getCount() == 0) { UprightLineNodes.remove(node); } isShowed = true; break; } } if (!isShowed) out.println("<img src='' width=20 height=1>"); } if (leaf.getCode().equals(rootLeaf.getCode())) { out.println("<img onClick=\"ShowChild(this, '" + tableid + "')\" src='images/i_puls-root.gif' align='absmiddle'><img src='images/folder_01.gif' align='absmiddle'>"); } else { if (isLastChild) { if (childcount > 0) out.println("<img onClick=\"ShowChild(this, '" + tableid + "')\" src='images/i_plus2-2.gif' align='absmiddle'><img src='images/folder_01.gif' align='absmiddle'>"); else out.println("<img src='images/i_plus-2-3.gif' align='absmiddle'><img src='images/folder_01.gif' align='absmiddle'>");
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?