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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
package com.vci.client.framework.rightConfig.modelConfig;
 
import java.awt.BorderLayout;
 
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.event.TreeExpansionEvent;
import javax.swing.event.TreeExpansionListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreePath;
 
import com.vci.client.LogonApplication;
import com.vci.client.common.TransmitTreeObject;
import com.vci.client.framework.appConfig.AppConfigCategoryPanel;
import com.vci.client.framework.appConfig.AppConfigDetailPanel;
import com.vci.client.framework.appConfig.AppConfigModulePanel;
import com.vci.client.framework.delegate.FuncOperationClientDelegate;
import com.vci.client.framework.delegate.FunctionClientDelegate;
import com.vci.client.framework.delegate.OperateClientDelegate;
import com.vci.client.framework.rightConfig.functiontree.FuncOperatePanel;
import com.vci.client.framework.rightConfig.functiontree.ModelManagementPanel;
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.framework.rightConfig.operate.OperateMangePanel;
import com.vci.client.framework.scaffold.AbstractTabbedMainPanel;
import com.vci.client.framework.scaffold.GenericMenuBar;
import com.vci.client.framework.specialrole.SpecialRoleClientObject;
import com.vci.client.framework.specialrole.ModuleInterface.IModuleShow;
import com.vci.client.framework.systemConfig.SystemMonitorPanel;
import com.vci.client.logon.base.BaseMenuBar;
import com.vci.client.ui.exception.VCIException;
import com.vci.client.ui.locale.LocaleDisplay;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.client.ui.tree.VCIBaseTree;
import com.vci.client.ui.tree.VCIBaseTreeModel;
import com.vci.client.ui.tree.VCIBaseTreeNode;
 
/**
 *权限模块管理
 * 
 */
public class ModuleConfigMainPanel extends AbstractTabbedMainPanel implements IModuleShow{
 
    private static final long serialVersionUID = 1L;
    private JSplitPane jspoperateTypeMainPanel; // 把Panel分成左右两部分
    private JScrollPane jTabbedPaneDetail;// jTabbedPaneDetail右边显示的JScrollPane
    private JScrollPane leftPanel = new JScrollPane();
    private TransmitTreeObject transmitTreeObject = new TransmitTreeObject();// 存储树信息
    private VCIBaseTree tree;
    private VCIBaseTreeModel treeModel;
    private VCIBaseTreeNode modelConstructionTree;
    private VCIBaseTreeNode systemConstructionTree;
    private VCIBaseTreeNode operateTypeNode;
 
    private String logonUserId = "",logonRoleId;
    private String moduleName = "";
    private String iconName,moduleShowInfo ;
    private VCIBaseTreeNode sysConfNode;//系统配置项节点
    private VCIBaseTreeNode sysConfClsfNode;//系统配置项分类节点
    private VCIBaseTreeNode sysMonitorNode;//系统运行情况节点
    private VCIBaseTreeNode sysOptionNode;//系统配置
    
    private SpecialRoleClientObject specialRoleObject = new SpecialRoleClientObject();
    public SpecialRoleClientObject getSpecialRoleObject() {
        return specialRoleObject;
    }
 
    public void setSpecialRoleObject(SpecialRoleClientObject specialRoleObject) {
        this.specialRoleObject = specialRoleObject;
    }
 
    public ModuleConfigMainPanel() {
        init();
    }
 
    public void init() {
        jTabbedPaneDetail = new JScrollPane();
        jspoperateTypeMainPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftPanel, jTabbedPaneDetail);
        jspoperateTypeMainPanel.setDividerSize(6);
        jspoperateTypeMainPanel.setContinuousLayout(true);
        jspoperateTypeMainPanel.setOneTouchExpandable(true);
        jspoperateTypeMainPanel.setDividerLocation(200);
        this.setLayout(new BorderLayout());
        this.add(jspoperateTypeMainPanel, BorderLayout.CENTER);
        initLeftPanel();
    }
    
 
    public void setModuleShowInfo(String moduleShowInfo) {
        this.moduleShowInfo = moduleShowInfo;
    }
 
    public void setIconName(String iconName) {
        this.iconName = iconName;
    }
 
    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }
 
    public String getLogonUserId() {
        return logonUserId;
    }
 
    public void setLogonUserId(String logonUserId) {
        this.logonUserId = logonUserId;
    }
 
    public String getLogonRoleId() {
        return logonRoleId;
    }
 
    public void setLogonRoleId(String logonRoleId) {
        this.logonRoleId = logonRoleId;
    }
 
    /***
     * 初始化树
     * 
     */
    private void initLeftPanel() {
        final VCIBaseTreeNode rootNode = new VCIBaseTreeNode(
                LocaleDisplay.getI18nString("rmip.framework.moudelConfig.file", "RMIPFramework", getLocale()), "root");
        treeModel = new VCIBaseTreeModel(rootNode);
        initTree(rootNode, "root");
        tree = new VCIBaseTree(treeModel, new ModuleTreeCellRenderer());
        tree.addTreeSelectionListener(new TreeSelectionListener() {
            public void valueChanged(TreeSelectionEvent e) {
                moduleConfigTree_valueChanged(e);
            }
        });
        // 展开事件
        tree.addTreeExpansionListener(new TreeExpansionListener() {
            public void treeExpanded(TreeExpansionEvent event) {
                TreePath path = event.getPath();
                VCIBaseTreeNode selectNode = (VCIBaseTreeNode) path.getLastPathComponent();
                Object object = selectNode.getObj();
                FunctionClientDelegate funcDel = new FunctionClientDelegate(LogonApplication.getUserEntityObject());
                if (!selectNode.isExpand()) {
                    selectNode.setExpand(true);
                    if (object instanceof FunctionObject || object.equals("business") || object.equals("system")) {
                        String parentId = "";
                        if(object instanceof FunctionObject){
                            parentId = ((FunctionObject) object).getId();
                            try {
                                /**判断该模块下子对象是模块还是操作,0表示无子节点,1表示是模块,2表示是操作**/
                                int childType = funcDel.checkChildObject(parentId);
                                if(childType == 2){
                                    FuncOperationObject[] funcOperations = new FuncOperationClientDelegate().getFuncOperationByModuleId(parentId, "", false);
                                    for(FuncOperationObject obj:funcOperations){
                                        VCIBaseTreeNode node = new VCIBaseTreeNode(obj.getOperAlias(), obj);
                                        selectNode.add(node);
                                        node.setLeaf(true);
                                    }
                                }else if(childType == 1){
                                    FunctionObject[] funcObjs = funcDel.getModuleListByParentId(parentId, true);
                                    for(FunctionObject obj :funcObjs){
                                        VCIBaseTreeNode node = new VCIBaseTreeNode(obj.getName(), obj);
                                        selectNode.add(node);
                                        if(funcDel.checkChildObject(obj.getId()) == 0 ){
                                            node.setLeaf(true);
                                        }
                                    }
                                }
                            } catch (VCIException e) {
                                e.printStackTrace();
                                VCIOptionPane.showError(LogonApplication.frame,LocaleDisplay.getI18nString(e, "RMIPFramework", getLocale()));
                            }
                        } else {
                            parentId = object.toString();
                            try {
                                FunctionObject[] funcObjs = funcDel.getModuleListByParentId(parentId, true);
                                for(FunctionObject obj :funcObjs){
                                    VCIBaseTreeNode node = new VCIBaseTreeNode(obj.getName(), obj);
                                    selectNode.add(node);
                                    if(funcDel.checkChildObject(obj.getId()) == 0){
                                        node.setLeaf(true);
                                    }
                                }
                            } catch (VCIException e) {
                                e.printStackTrace();
                                VCIOptionPane.showError(LogonApplication.frame,LocaleDisplay.getI18nString(e, "RMIPFramework", getLocale()));
                            }
                        }
                        
                    } else if (object.equals("operateNode")) {
                        //加载所有操作
                        try {
                            OperateObject[] operateObjs = new OperateClientDelegate(LogonApplication.getUserEntityObject()).getOperateTreeList("");
                            for(OperateObject obj :operateObjs){
                                VCIBaseTreeNode node = new VCIBaseTreeNode(obj.getName(), obj);
                                node.setLeaf(true);
                                selectNode.add(node);
                            }
                        } catch (VCIException e) {
                            e.printStackTrace();
                            VCIOptionPane.showError(LogonApplication.frame,LocaleDisplay.getI18nString(e, "RMIPFramework", getLocale()));
                        }
                    }
                    treeModel.reload(selectNode);
                }
            }
 
            public void treeCollapsed(TreeExpansionEvent event) {
            }
 
        });
        leftPanel.getViewport().add(tree);
    }
 
    private void initTree(VCIBaseTreeNode rootNode, String puid) {
        // 管理功能定义
        systemConstructionTree = new VCIBaseTreeNode(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.systemFunctionModel",
                "RMIPFramework", getLocale()), "system");
        
        // 业务功能定义
        modelConstructionTree = new VCIBaseTreeNode(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.businessFunctionModel",
                "RMIPFramework", getLocale()), "business");
        
        // 操作定义
        operateTypeNode = new VCIBaseTreeNode(LocaleDisplay.getI18nString("rmip.framework.operateType.operateTypeModel.file",
                "RMIPFramework", getLocale()), "operateNode");
        
        // 配置管理模块
        sysConfNode = new VCIBaseTreeNode(LocaleDisplay.getI18nString("rmip.framework.sysConfNode.sysConfModel",
                "RMIPFramework", getLocale()), "sysConfNode");
        sysConfNode.setLeaf(true);
        
        // 配置分类管理
        sysConfClsfNode = new VCIBaseTreeNode(LocaleDisplay.getI18nString("rmip.framework.sysConfNode.sysConfClsfModel",
                "RMIPFramework", getLocale()), "sysConfClsfNode");
        sysConfClsfNode.setLeaf(true);
 
        
        // 配置管理
        sysOptionNode = new VCIBaseTreeNode("系统配置", "sysOptionNode");
        sysOptionNode.setLeaf(true);
 
        
        rootNode.add(systemConstructionTree);
        rootNode.add(modelConstructionTree);
        rootNode.add(operateTypeNode);
//        rootNode.add(sysConfClsfNode);
//        rootNode.add(sysConfNode);
        rootNode.add(sysOptionNode);
        
        sysMonitorNode = new VCIBaseTreeNode(LocaleDisplay.getI18nString("rmip.framework.sysConfNode.sysMonitor",
                "RMIPFramework", getLocale()), "sysMonitorNode");
        sysMonitorNode.setLeaf(true);        
        rootNode.add(sysMonitorNode);
    }
 
 
    private void moduleConfigTree_valueChanged(TreeSelectionEvent e) {
        TreePath treePath = e.getPath();
        VCIBaseTreeNode selectNode = (VCIBaseTreeNode) treePath
                .getLastPathComponent();
        transmitTreeObject.setCurrentTreeNode(selectNode);
        transmitTreeObject.setTree(tree);
        transmitTreeObject.setTreeModel(treeModel);
 
        Object object = selectNode.getObj();
        JPanel newPanel = new JPanel();
        if (object instanceof OperateObject|| object.equals("operateNode")) {
            newPanel = new OperateMangePanel(object,transmitTreeObject);
        }
        else if (object.equals("business") || object.equals("system") || object instanceof FunctionObject) {
            newPanel = new ModelManagementPanel(object,transmitTreeObject, this);
        }
        else if (object instanceof FuncOperationObject){
            newPanel = new FuncOperatePanel((FuncOperationObject)object,transmitTreeObject);
        }
//        else if (object.equals("sysConfClsfNode")) {
//            newPanel = new AppConfigCategoryPanel(null);
//        }
//        else if (object.equals("sysConfNode")) {
//            newPanel = new AppConfigDetailPanel();
//        }
        else if (object.equals("sysMonitorNode")) {
            newPanel = new SystemMonitorPanel();            
        }
        else if (object.equals("sysOptionNode")) {
            newPanel = new AppConfigModulePanel();            
        }
        else {
            jspoperateTypeMainPanel.setRightComponent(newPanel);
        }
 
        jspoperateTypeMainPanel.setRightComponent(newPanel);
        int location = jspoperateTypeMainPanel.getDividerLocation();
        jspoperateTypeMainPanel.setDividerLocation(location);
    }
 
    
    BaseMenuBar specialMenuBar = null; 
    public BaseMenuBar getSpecialMenuBar(){
        if(specialMenuBar == null){
            specialMenuBar = new GenericMenuBar(LogonApplication.frame);
        }
        return specialMenuBar;
    }
 
    @Override
    public String getUserID() {
        return logonUserId;
    }
 
    @Override
    public JPanel getModuleComponent() {
        return this;
    }
 
    @Override
    public String getModuleName() {
        return moduleName;
    }
 
    @Override
    public String getIconName() {
        return iconName;
    }
 
    @Override
    public String getModuleShowInfo() {
        return moduleShowInfo;
    }
 
    @Override
    public String getRoleID() {
        return logonRoleId;
    }
    //导入数据后重新刷新树
    public void reloadFunctionTreeNode() {
        int count = modelConstructionTree.getChildCount();
        for (int i = count - 1; i >= 0; i--) {
            treeModel.removeNodeFromParent((VCIBaseTreeNode)modelConstructionTree.getChildAt(i));
        }
        modelConstructionTree.setExpand(false);
        modelConstructionTree.setLeaf(false);
        treeModel.nodeChanged(modelConstructionTree);
        treeModel.reload(modelConstructionTree.getParent());
    }
}