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

📄 toolkit.java~189~

📁 封装了SQL、Socket、WAP、MIME等功能的通用组件
💻 JAVA~189~
字号:
package org.lazybug.skit;

import java.io.PrintWriter;
import java.io.FileOutputStream;
import org.lazybug.skit.table.KTable;
import org.lazybug.skit.menu.KMenu;

/**
 * <p>Title: Geniux</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author David Lau
 * @version 1.0
 */
public class Toolkit
{

    public static String insertJsFunction(String funcName)
    {
        return insertJsFunction(funcName, "");
    }

    public static String insertJsFunction(String funcName, String remark)
    {
        StringBuffer sb = new StringBuffer();
        if( funcName != null && funcName.length() > 0 )
        {
            if( remark != null )
                remark = funcName;

            String  alert = "请实现函数——"+remark+"!";
            if( funcName.equals("delete") )
            {
                funcName = funcName+"A";
                alert = "请不要使用"+funcName+"作为函数名称,因为与系统的关键字冲突!";
            }
            sb.append("\n/*函数:" + remark + "*/");
            sb.append("\nfunction "+funcName+"()");
            sb.append("\n{");
            sb.append("\n    alert('"+alert+"');");
            sb.append("\n}");
        }
        return sb.toString();
    }

    public static String insertButtonPicked(String func)
    {
        StringBuffer sb = new StringBuffer();
        sb.append("<img src='skin/metallic/picked/picked_right.gif' ");
        sb.append("onclick='"+func+"()' ");
        sb.append("onmouseover='this.src=\"skin/metallic/picked/picked_disabled_right.gif\";'");
        sb.append("onmouseout='this.src=\"skin/metallic/picked/picked_right.gif\";'>");
        return sb.toString();
    }

    public static String insertButtonPicked(KMenu menu)
    {
        StringBuffer sb = new StringBuffer();
        sb.append("<img src='skin/metallic/picked/picked_right.gif' ");
        sb.append("onclick='SKIT_SHOW_POPMENU(\""+menu.getId()+"\", \"show\", this);'");
        sb.append("onmouseover='this.src=\"skin/metallic/picked/picked_disabled_right.gif\";'");
        sb.append("onmouseout='this.src=\"skin/metallic/picked/picked_right.gif\";'>");
        return sb.toString();
    }

    public static String insertCellLink(String href, String name, String style)
    {
        if( style != null && style.length() > 0 )
        {
            return "<a style='" + style + "' href='" + href + "' >" + name + "</a>";
        }
        else
        {
            return "<a href='" + href + "' >" + name + "</a>";
        }
    }

    public static String insertCellInput(Object value, String style, int width)
    {
        if( width < 120 )
        {
            return "<p style='"+style+"'>"+value+"</p>";
        }

        if( style == null || style.length() == 0 )
        {
            style = "width:"+(width - 20)+"px";
        }
        else
        {
            style += ";width:"+(width - 20)+"px";
        }
        return "<input type='text' class='skit_cell_input' style='"+style+"' readOnly='true' value=\""+value+"\">";
    }

    public static void createTableJspFile(KTable table, String path, String name)
    {
        try
        {
            String filename = path + name + ".jsp";
            PrintWriter writer = new PrintWriter(new FileOutputStream(filename));
            writer.println("<%@page contentType='text/html;charset=gb2312'%>");
            writer.println("<html>");
            writer.println("<head>");
            writer.println("<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>");
            writer.println("<style type='text/css'>");
            writer.println("body {overflow:hidden; margin-top:0px; margin-left:0px; margin-bottom:0px; margin-right:0px }");
            writer.println("<%@ include file=\"css/skit_table.css\"%>");
            writer.println("<%@ include file=\"css/skit_menu.css\"%>");
            writer.println("</style>");
            writer.println("<script language='javascript' src='script/skit_table.js'></script>");
            writer.println("<script language='javascript' src='script/skit_menu.js'></script>");
            writer.println("</head>");
            writer.println("<body>");
            writer.println("<div style='height:200px;border:1px solid blue'>");
            writer.println(table);
            writer.println("</div>");
            writer.println("</body>");
            writer.println("</html>");

            writer.println("<SCRIPT LANGUAGE='JavaScript'>");
            writer.println("<!--");
            /*初始化View表格排序*/
            writer.println("function SKIT_TABLE_VIEW_INIT()");
            writer.println("{");
            writer.println("    _SKIT_TABLE_HEAD_ARRAY.push(document.getElementById('"+table.getId()+"tb'));");
            writer.println("    _SKIT_TABLE_VIEW_ARRAY.push(document.getElementById('"+table.getId()+"body'));");
            writer.println("}");
            writer.println("//-->");
            writer.println("</SCRIPT>");
            writer.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public static void createTreeJspFile(Tree tree, String path, String name)
    {
        try
        {
            String filename = path + name + ".jsp";
            PrintWriter writer = new PrintWriter(new FileOutputStream(filename));
            writer.println("<%@page contentType='text/html;charset=gb2312'%>");
            writer.println("<html>");
            writer.println("<head>");
            writer.println("<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>");
            writer.println("<style type='text/css'>");
            writer.println("body {overflow:hidden; margin-top:0px; margin-left:0px; margin-bottom:0px; margin-right:0px }");
            writer.println("<%@ include file=\"css/skit_tree.css\"%>");
            writer.println("<%@ include file=\"css/skit_actions.css\"%>");
            writer.println("<%@ include file=\"css/skit_menu.css\"%>");
            writer.println("</style>");
            writer.println("<script language='javascript' src='script/skit_button.js'></script>");
            writer.println("<script language='javascript' src='script/skit_tree.js'></script>");
            writer.println("</head>");
            writer.println("<body onResize='SKIT_RESIZE_TREE()'>");
            writer.println(tree);
            writer.println("</body>");
            writer.println("</html>");

            writer.println("<SCRIPT LANGUAGE='JavaScript'>");
            writer.println("<!--");
            writer.println("SKIT_RESIZE_TREE();");
            writer.println(tree.getScriptTag());
            writer.println("//-->");
            writer.println("</SCRIPT>");
            writer.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public static void testCreateTree()
    {
/*        Tree tree = new Tree();
        Action action = new Action();
        action.addComponent(new ActionItem("不知火", "m1"));
        action.addComponent(new ActionItem("铁凤", "m2"));
        tree.addComponent(new TreeItem("介绍", "#", action));

        action = new Action();
        action.addComponent(new ActionItem("兰风", "m3"));
        PopupMenu popMenu = new PopupMenu();
        popMenu.addComponent(new MenuItem("功能1", "a1"));
        popMenu.addComponent(new MenuItem("功能2", "a2"));
        popMenu.addComponent(new MenuItem("功能3", "a3"));
        popMenu.addComponent(new MenuItem("功能4", "a4"));
        action.addComponent(new ActionItem("铁脚", popMenu));
        tree.addComponent(new TreeItem("登录", "#", action));

        tree.addComponent(new TreeItem("在线支持"));

        Component item = tree.addComponent(new TreeItem("日志"));
        Component subItem = item.addComponent(new TreeItem("系统"));
        subItem.addComponent(new TreeItem("设备"));
        subItem.addComponent(new TreeItem("告警"));
        item.addComponent(new TreeItem("应用"));


        createTreeJspFile(tree, "D:/work/project/mste/tomcat/webapps/mste/", "menu_example6");*/
    }

    public static void testCreateTable()
    {
        /*String colNames[] = new String[]{
            null,"列1","列2"};
        KTable table = new KTable(colNames);
        table.setColWidth(0, 26);
        table.setColWidth(1, 100);
        table.setColWidth(2, 120);
        createTableJspFile(
            table, "D:/work/project/mste/tomcat/webapps/mste/", "table_example2");*/
    }

    public static void main(String args[])
    {
        testCreateTable();
    }
}

⌨️ 快捷键说明

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