wangting
2024-12-26 fa261e8c1220b31af54e8167e4de9c3320b1af27
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
package com.vci.client.framework.systemConfig;
 
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.TreeNode;
import javax.swing.tree.TreePath;
 
import com.vci.client.LogonApplication;
import com.vci.client.common.TransmitTreeObject;
import com.vci.client.framework.delegate.PvolumeClientDelegate;
//import com.vci.client.framework.scaffold.TabbedMainPanelAdapter;
import com.vci.client.framework.systemConfig.object.AttributeObject;
import com.vci.client.framework.systemConfig.object.SpecialCharClsfObject;
import com.vci.client.framework.systemConfig.volumn.object.PvolumeObject;
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.swing.components.VCIJPanel;
import com.vci.client.ui.tree.VCIBaseTree;
import com.vci.client.ui.tree.VCIBaseTreeModel;
import com.vci.client.ui.tree.VCIBaseTreeNode;
 
public class SysConfigPanel extends VCIJPanel { // TabbedMainPanelAdapter {
 
    /**************************** 国际化信息 **********************************/
    // 系统配置管理
    private String SYSCONFIGMODULE = LocaleDisplay.getI18nString("rmip.framework.systemConfigModule", "RMIPFramework",
            getLocale());
    // 特殊字符
    private String SPECIALCHAR = LocaleDisplay.getI18nString("rmip.framework.sysconfig.specialChar", "RMIPFramework",
            getLocale());
    // 属性管理
    private String ATTRMANAGEMENT = LocaleDisplay.getI18nString("rmip.framework.sysconfig.attrManagement",
            "RMIPFramework", getLocale());
    // 可用字符集
    private String CHARACTERSET = LocaleDisplay.getI18nString("rmip.code.sysconfig.characterSet", "RMIPCode",
            getLocale());
    // 不可用字符集
    private String NOCHARACTERSET = LocaleDisplay.getI18nString("rmip.code.sysconfig.nocharacterSet", "RMIPCode",
            getLocale());
    // 补位字符
    private String COVERCHARACTER = LocaleDisplay.getI18nString("rmip.code.sysconfig.coverCharacter", "RMIPCode",
            getLocale());
    // 分隔符
    private String SEPCHARACTER = LocaleDisplay.getI18nString("rmip.code.sysconfig.sepCharacter", "RMIPCode",
            getLocale());
    // 单位
    private String UNIT = LocaleDisplay.getI18nString("rmip.framework.sysconfig.unit", "RMIPFramework", getLocale());
    // 日期格式
    private String DATEFORMAT = LocaleDisplay.getI18nString("rmip.code.sysconfig.dateformat", "RMIPCode", getLocale());
    // 卷管理
    private String VOLUMN = LocaleDisplay.getI18nString("rmip.code.sysconfig.volumn", "RMIPRm", getLocale());
 
    private static final long serialVersionUID = -527263842809747743L;
    private VCIBaseTreeModel treeModel = null;
    private VCIBaseTree sysConfigTree = null;
    JSplitPane jspConfigPanel; // 把Panel分成左右两部分
    JScrollPane jTabbedPaneDetail;// jTabbedPaneDetail右边显示的JScrollPane
    private JScrollPane leftPanel = new JScrollPane();
    private TransmitTreeObject transmitTreeObject = new TransmitTreeObject();
    JPanel rightPanel = null;
 
    public SysConfigPanel() {
        init();
    }
 
    public void init() {
        jTabbedPaneDetail = new JScrollPane();
        jspConfigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, jTabbedPaneDetail);
        jspConfigPanel.setDividerSize(10);
        jspConfigPanel.setContinuousLayout(true);
        jspConfigPanel.setOneTouchExpandable(true);
        jspConfigPanel.setDividerLocation(200);
        this.setLayout(new BorderLayout());
        this.add(jspConfigPanel, BorderLayout.CENTER);
        initLeftPanel();
    }
 
    /***
     * 初始化数
     *
     */
    private void initLeftPanel() {
        VCIBaseTreeNode rootNode = new VCIBaseTreeNode(SYSCONFIGMODULE, "root");
        treeModel = new VCIBaseTreeModel(rootNode);
        initTree(rootNode, "root");
        sysConfigTree = new VCIBaseTree(treeModel, new SysConfigTreeCellRenderer());
        sysConfigTree.addTreeSelectionListener(new TreeSelectionListener() {
            public void valueChanged(TreeSelectionEvent e) {
//                    sysConfigTree_valueChanged(e);
            }
        });
        sysConfigTree.addTreeExpansionListener(new TreeExpansionListener() {
            public void treeCollapsed(TreeExpansionEvent tse) {
 
            }
 
            public void treeExpanded(TreeExpansionEvent tse) {
                TreePath path = tse.getPath();
                VCIBaseTreeNode treeNode = (VCIBaseTreeNode) path.getLastPathComponent();
                TreeNode[] treeNodes = treeNode.getPath();
                if (!treeNode.isExpand()) {
                    if (treeNode.getObj() instanceof SpecialCharClsfObject) {
                        if (treeNodes.length < 2) {
                            return;
                        }
                        initSpecialCharacter(treeNode, ((SpecialCharClsfObject) treeNode.getObj()).getId());
                    }
 
                    if (treeNode.getObj() instanceof PvolumeObject) {
                        if (treeNodes.length < 1) {
                            return;
                        }
                        PvolumeObject obj = (PvolumeObject) treeNode.getObj();
                        if ("root".equals(obj.getId())) {
                            initPvolume(treeNode, ((PvolumeObject) treeNode.getObj()).getId());
                        }
 
                    }
 
                    treeNode.setExpand(true);
                }
            }
        });
        transmitTreeObject.setTreeModel(treeModel);
        transmitTreeObject.setTree(sysConfigTree);
        leftPanel.getViewport().add(sysConfigTree);
    }
 
    /**
     * 
     * 
     * @param rootNode
     * @param puid
     */
 
    private void initTree(VCIBaseTreeNode rootNode, String puid) {
        // 用于检查权限
//           boolean res = true;
//           
//           res = RightControlUtil.getTreeNodeInfoByRole(getClass().getName()+".separator");
//           //分隔符
//           if(res){
        VCIBaseTreeNode sepCharacter = new VCIBaseTreeNode(SEPCHARACTER, "separator");
        rootNode.add(sepCharacter);
//           }
//           
//           res = RightControlUtil.getTreeNodeInfoByRole(getClass().getName()+".charset");
//           //可用字符集
//           if(res){
        VCIBaseTreeNode characterSet = new VCIBaseTreeNode(CHARACTERSET, "charset");
        rootNode.add(characterSet);
//           }
//           res = RightControlUtil.getTreeNodeInfoByRole(getClass().getName()+".nocharset");
//           //不可用字符集
//           if(res){
        VCIBaseTreeNode nocharacterSet = new VCIBaseTreeNode(NOCHARACTERSET, "nocharset");
        rootNode.add(nocharacterSet);
//           }
//           
//           VCIBaseTreeNode folwWay = new VCIBaseTreeNode("流水方式","flowType");
//           rootNode.add(folwWay);
//           
//           res = RightControlUtil.getTreeNodeInfoByRole(getClass().getName()+".dateFormat");
//           //日期格式
//           if(res){
        VCIBaseTreeNode dateForm = new VCIBaseTreeNode(DATEFORMAT, "dateFormat");
        rootNode.add(dateForm);
//           }
//           
//           res = RightControlUtil.getTreeNodeInfoByRole(getClass().getName()+".unit");
//           //单元
//           if(res){
        VCIBaseTreeNode unit = new VCIBaseTreeNode(UNIT, "unit");
        rootNode.add(unit);
//           }
////           
//           res = RightControlUtil.getTreeNodeInfoByRole(getClass().getName()+".fillerChar");
//           //补位字符
//           if(res){
        VCIBaseTreeNode coverCharacter = new VCIBaseTreeNode(COVERCHARACTER, "fillerChar");
        rootNode.add(coverCharacter);
//           }
//           
//           res = RightControlUtil.getTreeNodeInfoByRole(getClass().getName()+".specialChar");
//           //特殊字符
//           if(res){
        SpecialCharClsfObject specialCharClsfInfo = new SpecialCharClsfObject();
        specialCharClsfInfo.setId("root");
        VCIBaseTreeNode specialCharacter = new VCIBaseTreeNode(SPECIALCHAR, specialCharClsfInfo);
        rootNode.add(specialCharacter);
//           }
//           
//           res = RightControlUtil.getTreeNodeInfoByRole(getClass().getName()+".attribute");
//           //属性管理
//           if(res){
        AttributeObject attributeObject = new AttributeObject();
        VCIBaseTreeNode attribute = new VCIBaseTreeNode(ATTRMANAGEMENT, attributeObject);
        rootNode.add(attribute);
//           }
//           
//           res = RightControlUtil.getTreeNodeInfoByRole(getClass().getName()+".pvolume");
//           //卷服务
//           if(res){
        PvolumeObject pvolume = new PvolumeObject();
        pvolume.setId("root");
        VCIBaseTreeNode pvolumeNode = new VCIBaseTreeNode(VOLUMN, pvolume);
        rootNode.add(pvolumeNode);
    }
 
    private boolean initSpecialCharacter(VCIBaseTreeNode specialCharacter, String parentId) {
        boolean rs = true;
//            try {
//                SpecialCharClsfObject[] specialCharClsfObject = new SystemCfgClientDelegate(LogonApplication.frame.getUserEntityObject()).fetchSpecialCharClsf(parentId);
//                
//                int len = specialCharClsfObject.length;
//                for (int i = 0; i < len; i++) {
//                    VCIBaseTreeNode node = new VCIBaseTreeNode(specialCharClsfObject[i].getName(),specialCharClsfObject[i]);
//                    treeModel.insertNodeInto(node, specialCharacter, specialCharacter.getChildCount());
//                }
//                
//            } catch (VCIError re) {
//                VCIOptionPane.showError(LogonApplication.frame, LocaleDisplay.getI18nString(String.valueOf(re.code), "RMIPFramework", getLocale()));
//                rs = false;
//            }
        return rs;
    }
 
    private boolean initPvolume(VCIBaseTreeNode pvolumnObj, String parentId) {
        boolean rs = true;
        try {
            PvolumeObject[] pvolumnObject = new PvolumeClientDelegate(LogonApplication.getUserEntityObject())
                    .getAllPvolumes();
 
            int len = pvolumnObject.length;
            for (int i = 0; i < len; i++) {
                VCIBaseTreeNode node = new VCIBaseTreeNode(pvolumnObject[i].getName(), pvolumnObject[i]);
                treeModel.insertNodeInto(node, pvolumnObj, pvolumnObj.getChildCount());
            }
 
        } catch (VCIException re) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", re);
            rs = false;
        }
        return rs;
    }
 
    /**
     * 返回当前选中的树节点
     * 
     * @return
     */
    public VCIBaseTreeNode getCurremtSelectedTreeNode() {
        return (VCIBaseTreeNode) this.sysConfigTree.getLastSelectedPathComponent();
    }
 
    public TransmitTreeObject getTransmitTreeObject() {
        return transmitTreeObject;
    }
}