⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractskin.java

📁 jsp + xml实现treeview
💻 JAVA
字号:
/*
 * ====================================================================
 * The JSP Tree Software License, Version 1.1
 *
 * (this license is derived and fully compatible with the Apache Software
 * License - see http://www.apache.org/LICENSE.txt)
 *
 * Copyright (c) 2002-2005 jsptree.sourceforge.net . All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by
 *        jsptree.sourceforge.net (http://jsptree.sourceforge.net/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The name "JSP Tree" must not be used to endorse or promote
 *    products derived from this software without prior written permission.
 *    For written permission, please contact modano@users.sourceforge.net .
 *
 * 5. Products derived from this software may not be called "JSP Tree",
 *    nor may "JSP Tree" appear in their name, without prior written
 *    permission of jsptree.sourceforge.net.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 */

package net.sf.jsptree.skin;

import java.io.IOException;
import java.util.Iterator;
import java.util.Map;

import net.sf.jsptree.component.JSPTreeComponent;
import net.sf.jsptree.component.JSPTreeNode;
import net.sf.jsptree.template.NodeTemplate;
import net.sf.jsptree.tree.TreeNode;

/**
 * @author Vladislav Kamensky
 */
public abstract class AbstractSkin implements Skin {

    public static final String MENU_SKIN = net.sf.jsptree.skin.MenuTemplateSkin.class.getName();

    public static final String DEFAULT_SKIN = net.sf.jsptree.skin.DefaultTemplateSkin.class.getName();

    public static final String FOLDER_SKIN = net.sf.jsptree.skin.FolderTemplateSkin.class.getName();

    protected String getStateManagerURL(NodeInfo p_nodeInfo) {
        TreeNode treeNode = p_nodeInfo.getNode();
        JSPTreeComponent comp = p_nodeInfo.getComponent();

        StringBuffer a_buf = new StringBuffer();

        if (comp.getStateManagerAction() == null) {
            a_buf.append(comp.getRequestURI() + "?");
        } else {
            a_buf.append(comp.getStateManagerAction() + "?");
        }

        if (p_nodeInfo.isOpened()) {
            a_buf.append("cNode-" + comp.getName() + "=");
        } else {
            a_buf.append("oNode-" + comp.getName() + "=");
        }
        a_buf.append(((JSPTreeNode) treeNode.getData()).getId());
        return comp.encodeRedirectURL(a_buf.toString());
    }

    protected String getHref(NodeInfo nodeInfo) throws IOException {
        TreeNode treeNode = nodeInfo.getNode();
        JSPTreeComponent comp = nodeInfo.getComponent();
        JSPTreeNode jspNode = (JSPTreeNode) treeNode.getData();
        String a_href = jspNode.getHref();

        if (a_href != null) {
            if (jspNode.isContextRelative()) {
                if (a_href.startsWith("/")) {
                    if (a_href.indexOf("?") != -1) {
                        return (comp.getContextPath() + a_href + "&");
                    } else {
                        return (comp.getContextPath() + a_href + "?");
                    }
                } else {
                    return (comp.getRequestURI() + a_href + "&");
                }
            } else {
                return a_href;
            }
        } else {
            return (comp.getRequestURI() + "?");
        }
    }

    protected abstract NodeTemplate selectNodeTemplate(NodeInfo p_nodeInfo, JSPTreeComponent p_comp);

    protected void addTags(Map p_vals, Map p_tags) {
        Iterator entryIter = p_vals.entrySet().iterator();
        while (entryIter.hasNext()) {
            Map.Entry entry = (Map.Entry) entryIter.next();
            String a_name = (String) entry.getKey();
            String a_value = (String) entry.getValue();
            p_tags.put("${" + a_name + "}", a_value);
        }
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -