dangsn
2024-12-26 4e9ff2ce6a830bb2340d7c8612c72eea0c5a553e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.vci.client.framework.rightConfig.modelConfig;
 
import java.awt.Component;
 
import javax.swing.JTree;
import javax.swing.ToolTipManager;
import javax.swing.tree.DefaultTreeCellRenderer;
 
import com.vci.client.framework.rightConfig.functiontree.FunctionHelper;
import com.vci.client.framework.rightConfig.object.FuncOperationObject;
import com.vci.client.framework.rightConfig.object.FunctionObject;
import com.vci.client.framework.rightConfig.object.OperateObject;
import com.vci.client.ui.swing.VCISwingUtil;
import com.vci.client.ui.tree.VCIBaseTreeNode;
 
/**
 * 构建权限模块树
 * 
 * @author 刘迪 2011-05-31
 */
public class ModuleTreeCellRenderer extends DefaultTreeCellRenderer {
 
    /**
     * 
     */
    private static final long serialVersionUID = 8393197719527584042L;
    
 
    public ModuleTreeCellRenderer() {
    }
 
    public Component getTreeCellRendererComponent(JTree tree, Object value,
            boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
        super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
        
        try {
            ToolTipManager.sharedInstance().registerComponent(tree);
            VCIBaseTreeNode node = (VCIBaseTreeNode) value;
            String icon = "";
            
            if(node == null || (node != null && node.getObj() == null)) {
                icon = "formsection.gif";
            } else {
                Object obj = node.getObj();
                String sc = obj.getClass().getSimpleName();
                
                if (obj instanceof String) {
                    if (obj.equals("root")) {
                        icon = "house.png";
                    } else if (obj.equals(("business"))) {
                        icon = "businessModule.png";
                    } else if (obj.equals(("system"))) {
                        icon = "sysModule.png";
                    } else if (obj.equals(("sysConfNode"))) {
                        icon = "options.png";
                    } else if (obj.equals(("sysConfClsfNode"))) {
                        icon = "folder_page.png";
                    } else if (obj.equals(("sysMonitorNode"))) {
                        icon = "sysmonitor.png";
                    } else if (obj.equals(("operateNode"))) {
                        icon = "codevalue.gif";
                    } else if (obj.equals(("sysOptionNode"))) {
                        icon = "options.png";
                    }
                } else if(obj instanceof FunctionObject ){
                    FunctionObject func = (FunctionObject)obj;
//                    icon = func.getImage();
//                    if(icon.trim().length() == 0){
                    
                    icon = "folder_brick.png";
                    switch (func.getFuncType()) {
                    case 0:
                    case 1:
                        icon = "folder_brick.png";
                        break;
                    case 2:
                        icon = "function.png";
                        break;
                    }
                } else if(obj instanceof FuncOperationObject || node.getObj() instanceof OperateObject){
                    icon = "cmd.png";
                } else if (sc.equals("BtmItem")){
                    icon = "object.png";
                } else if (sc.equals("PLUILayout")){
                    icon = "application_form_add.png";
                } else if (sc.equals("PLTabPage")){
                    icon = "folder_page.gif";
                } else if (sc.equals("PLPageDefination")){
                    icon = "tables.gif";
                } else if (sc.equals("PLTabButton")){
                    icon = "formsection.gif";
                }else {
                    icon = "formsection.gif";
                }
            }
            if(node != null && node.isRoot()){
                icon = "house.png";
            }
            setIcon(VCISwingUtil.createImageIcon(icon));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return this;
    }
}