📄 directoryview.java
字号:
int count = r.size();
if (count>0) { // =0的也计入的话会在树底端的结点产生多余竖线
UprightLineNode uln = new UprightLineNode(layer, count);
// System.out.println(leaf.getCode() + " layer=" + layer +
// " count=" + count);
UprightLineNodes.addElement(uln);
}
}
}
int childcount = leaf.getChildCount();
// System.out.println(code + " childcount=" + childcount);
String tableid = "table" + leaf.getCode();
out.println("<table id=" + tableid + " name=" + tableid + " class='tbg1' cellspacing=0 cellpadding=0 width='100%' align=center onMouseOver=\"this.className='tbg1sel'\" onMouseOut=\"this.className='tbg1'\" border=0>");
out.println(" <tbody><tr>");
out.println(" <td width='85%' height='13' align=left nowrap>");
// for (int k = 1; k <= layer - 1; k++) {
for (int k = rootLeaf.getLayer(); k <= layer - 1; k++) { // 不用上一行,是因为上一行会产生多余的空格
boolean isShowed = false;
Iterator ir = UprightLineNodes.iterator();
while (ir.hasNext()) {
UprightLineNode node = (UprightLineNode) ir.next();
//如果在K层上存在一个竖线结点则画出
if (node.getLayer() == k) {
node.show(out, "images/i_plus-2.gif");
if (node.getCount() == 0) {
UprightLineNodes.remove(node);
//System.out.println("Remove " + node);
}
isShowed = true;
break;
}
}
if (!isShowed)
out.println("<img src='images/spacer.gif' 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'>");
} else { // 不是最后一个孩子结点
if (childcount > 0)
out.println("<img onClick=\"ShowChild(this, '" + tableid + "')\" src='images/i_plus2-1.gif' align='absmiddle'><img src='images/folder_01.gif' align='absmiddle'>");
else
out.println("<img src='images/i_plus-2-2.gif' align='absmiddle'><img src='images/folder_01.gif' align='absmiddle'>");
}
}
if (leaf.getType() == 2) {
out.print("<a href='#'>" + name +
"</a>");
} else if (leaf.getType() == 1)
out.print(
"<a href='#'>" + name + "</a>");
else if (leaf.getType() == 0) {
out.print(name);
}
out.print(" </td><td width='15%' align=right nowrap>");
if (!leaf.getCode().equals("root")) {
if (leaf.getIsHome())
out.print(SkinUtil.LoadString(request, "res.blog.DirectoryView", "info_home") + " ");
// out.print("<a href='dir_top.jsp?op=removecache&code=" + code +
// "'>清缓存</a> ");
if (leaf.getType() == leaf.TYPE_LIST)
out.print(SkinUtil.LoadString(request, "res.blog.DirectoryView", "info_type_list") + " ");
else
out.print(SkinUtil.LoadString(request, "res.blog.DirectoryView", "info_type_none") + " ");
// out.print(
// "<a target=_parent href='dir_priv_m.jsp?dirCode=" +
// StrUtil.UrlEncode(code, "utf-8") + "'>权限</a> ");
out.print(
"<a target=dirbottomFrame href='dir_bottom.jsp?parent_code=" +
StrUtil.UrlEncode(code, "utf-8") + "&parent_name=" +
StrUtil.UrlEncode(name, "utf-8") +
"&op=AddChild'>" + SkinUtil.LoadString(request, "res.blog.DirectoryView", "link_addchild") + "</a> ");
out.print(
"<a target='dirbottomFrame' href='dir_bottom.jsp?op=modify&code=" +
StrUtil.UrlEncode(code, "utf-8") + "&name=" +
StrUtil.UrlEncode(name, "utf-8") + "&description=" +
StrUtil.UrlEncode(description, "utf-8") + "'>" + SkinUtil.LoadString(request, "res.blog.DirectoryView", "link_modify") + "</a> ");
out.print(
"<a target=_self href=# onClick=\"if (window.confirm('" + SkinUtil.LoadString(request, "res.blog.DirectoryView", "confirm_del") + "')) window.location.href='dir_top.jsp?op=del&root_code=" + StrUtil.UrlEncode(rootLeaf.getCode()) + "&delcode=" +
StrUtil.UrlEncode(code, "utf-8") + "'\">" + SkinUtil.LoadString(request, "res.blog.DirectoryView", "link_del") + "</a> ");
out.print("<a href='dir_top.jsp?op=move&direction=up&root_code=" + StrUtil.UrlEncode(rootLeaf.getCode()) + "&code=" +
StrUtil.UrlEncode(code, "utf-8") + "'>" + SkinUtil.LoadString(request, "res.blog.DirectoryView", "link_move_up") + "</a> ");
out.print("<a href='dir_top.jsp?op=move&direction=down&root_code=" + StrUtil.UrlEncode(rootLeaf.getCode()) + "&code=" +
StrUtil.UrlEncode(code, "utf-8") + "'>" + SkinUtil.LoadString(request, "res.blog.DirectoryView", "link_move_down") + "</a> ");
// out.print("<a href='dir_top.jsp?root_code=" +
// StrUtil.UrlEncode(code, "utf-8") + "'>管理</a>");
}
out.println(" </td></tr></tbody></table>");
}
void ShowLeafAsOption(JspWriter out, Leaf leaf, int rootlayer)
throws Exception {
String code = leaf.getCode();
String name = leaf.getName();
int layer = leaf.getLayer();
String description = leaf.getDescription();
String blank = "";
int d = layer-rootlayer;
for (int i=0; i<d; i++) {
blank += " ";
}
if (leaf.getChildCount()>0) {
if (leaf.getType()==leaf.TYPE_LIST)
out.print("<option value='" + code + "' style='COLOR: #0005ff'>" + blank + "╋ " + name + "</option>");
else
out.print("<option value='not'>" + blank + "╋ " + name + "</option>");
}
else {
if (leaf.getType()==leaf.TYPE_LIST)
out.print("<option value=\"" + code + "\" style='COLOR: #0005ff'>" + blank + "├『" + name +
"』</option>");
else
out.print("<option value='not'>" + blank + "├『" + name +
"』</option>");
}
}
// 显示根结点为leaf的树
public void ShowDirectoryAsOptions(JspWriter out, Leaf leaf, int rootlayer) throws Exception {
ShowLeafAsOption(out, leaf, rootlayer);
Directory dir = new Directory();
Vector children = dir.getChildren(leaf.getCode());
int size = children.size();
if (size == 0)
return;
int i = 0;
Iterator ri = children.iterator();
while (ri.hasNext()) {
Leaf childlf = (Leaf) ri.next();
ShowDirectoryAsOptions(out, childlf, rootlayer);
}
}
/**
* 把列表或无内容显示为蓝色
* @param out JspWriter
* @param leaf Leaf
* @param rootlayer int
* @throws Exception
*/
void ShowLeafAsOptionWithCode(JspWriter out, Leaf leaf, int rootlayer)
throws Exception {
String code = leaf.getCode();
String name = leaf.getName();
int layer = leaf.getLayer();
String description = leaf.getDescription();
String blank = "";
int d = layer-rootlayer;
for (int i=0; i<d; i++) {
blank += " ";
}
// out.print("<option value='" + code + "'>" + blank + "╋ " + name + "</option>");
if (leaf.getChildCount()>0) {
if (leaf.getType()==leaf.TYPE_NONE)
out.print("<option value='" + code + "' style='COLOR: #0005ff'>" + blank + "╋ " + name + "</option>");
else
out.print("<option value='" + code + "' style='COLOR: #0005ff'>" + blank + "├『" + name + "』</option>");
}
else {
if (leaf.getType()==leaf.TYPE_LIST)
out.print("<option value=\"" + code + "\" style='COLOR: #0005ff'>" + blank + "├『" + name +
"』</option>");
else
out.print("<option value='" + code + "'>" + blank + "├『" + name +
"』</option>");
}
}
// 显示根结点为leaf的树,value中全为code
public void ShowDirectoryAsOptionsWithCode(JspWriter out, Leaf leaf, int rootlayer) throws Exception {
ShowLeafAsOptionWithCode(out, leaf, rootlayer);
Directory dir = new Directory();
Vector children = dir.getChildren(leaf.getCode());
int size = children.size();
if (size == 0)
return;
int i = 0;
Iterator ri = children.iterator();
while (ri.hasNext()) {
Leaf childlf = (Leaf) ri.next();
ShowDirectoryAsOptionsWithCode(out, childlf, rootlayer);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -