dirview.java
来自「一个用java编写的功能强大的OA系统」· Java 代码 · 共 283 行
JAVA
283 行
package com.redmoon.oa.fileark;import cn.js.fan.module.cms.DirectoryView;import cn.js.fan.module.cms.Leaf;import javax.servlet.jsp.JspWriter;import cn.js.fan.util.StrUtil;import java.util.Iterator;import java.util.Vector;import cn.js.fan.module.cms.UprightLineNode;import javax.servlet.http.HttpServletRequest;import com.redmoon.oa.pvg.Privilege;import cn.js.fan.module.cms.LeafPriv;import cn.js.fan.web.Global;import cn.js.fan.module.cms.Directory;public class DirView extends DirectoryView { String userName = ""; String FOLDER_IMG_CANSEE = "folder_cansee.gif"; String FOLDER_IMG_CANNOTSEE = "folder_cannotsee.gif"; String FOLDER_IMG_CANMODIFY = "folder_canmodify.gif"; public DirView(HttpServletRequest request, Leaf rootLeaf) { super(rootLeaf); Privilege privilege = new Privilege(); userName = privilege.getUser(request); } public String getFolderImg(Leaf leaf) { LeafPriv lp = new LeafPriv(leaf.getCode()); if (!lp.canUserSee(userName)) return FOLDER_IMG_CANNOTSEE; if (lp.canUserModify(userName)) return FOLDER_IMG_CANMODIFY; return FOLDER_IMG_CANSEE; } public void ListTreeSimple(JspWriter out, Leaf leaf, boolean isLastChild, String target, String link, String tableClass, String tableClassMouseOn) throws Exception { LeafPriv lp = new LeafPriv(leaf.getCode()); if (leaf.getIsHome()) { if (lp.canUserSee(userName)) ShowLeafSimple(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; if (childlf.getIsHome()) { if (lp.canUserSee(userName)) ListTreeSimple(out, childlf, isLastChild1, target, link, tableClass, tableClassMouseOn); } } if (size > 0) out.print("</td></tr></table>"); } public void ShowLeafSimple(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 folderImg = getFolderImg(leaf); 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/" + folderImg + "' 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/" + folderImg + "' align='absmiddle'>"); else out.println("<img src='images/i_plus-2-3.gif' align='absmiddle'><img src='images/" + folderImg + "' align='absmiddle'>"); } else { if (childcount > 0) out.println("<img onClick=\"ShowChild(this, '" + tableid + "')\" src='images/i_plus2-1.gif' align='absmiddle'><img src='images/" + folderImg + "' align='absmiddle'>"); else out.println("<img src='images/i_plus-2-2.gif' align='absmiddle'><img src='images/" + folderImg + "' align='absmiddle'>"); } } String linkstr = link; String targetstr = target; if (leaf.getType()==leaf.TYPE_LINK) { linkstr = leaf.getDescription(); if (!leaf.getTarget().equals("")) targetstr = leaf.getTarget(); } else linkstr += "?dir_code=" + StrUtil.UrlEncode(code); out.print( "<a target='" + targetstr + "' href='" + linkstr + "'>" + name + "</a>"); out.print(" </td>"); out.println(" </tr></tbody></table>"); } public void ListTreeFunc(JspWriter out, Leaf leaf, boolean isLastChild, String target, String func, String tableClass, String tableClassMouseOn) throws Exception { LeafPriv lp = new LeafPriv(leaf.getCode()); if (leaf.getIsHome() && leaf.getType()!=leaf.TYPE_LINK) { if (lp.canUserSee(userName)) ShowLeafFunc(out, leaf, isLastChild, target, 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='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; if (childlf.getIsHome() && childlf.getType()!=leaf.TYPE_LINK) { if (lp.canUserSee(userName)) ListTreeFunc(out, childlf, isLastChild1, target, func, tableClass, tableClassMouseOn); } } if (size > 0) out.print("</td></tr></table>"); } public void ShowLeafFunc(JspWriter out, Leaf leaf, boolean isLastChild, String target, String func, String tableClass, String tableClassMouseOn) throws Exception { String code = leaf.getCode(); String name = leaf.getName(); int layer = leaf.getLayer(); String folderImg = getFolderImg(leaf); 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='" + Global.getRootPath() + "/fileark/images/" + folderImg + "' 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='" + Global.getRootPath() + "/fileark/images/" + folderImg + "' align='absmiddle'>"); else out.println("<img src='images/i_plus-2-3.gif' align='absmiddle'><img src='" + Global.getRootPath() + "/fileark/images/" + folderImg + "' align='absmiddle'>"); } else { if (childcount > 0) out.println("<img onClick=\"ShowChild(this, '" + tableid + "')\" src='images/i_plus2-1.gif' align='absmiddle'><img src='" + Global.getRootPath() + "/fileark/images/" + folderImg + "' align='absmiddle'>"); else out.println("<img src='images/i_plus-2-2.gif' align='absmiddle'><img src='" + Global.getRootPath() + "/fileark/images/" + folderImg + "' align='absmiddle'>"); } } out.print( "<a target='" + target + "' href='#' onClick=\"" + func + "('" + code + "', '" + name + "')\">" + name + "</a>"); out.print(" </td>"); out.println(" </tr></tbody></table>"); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?