xiejun
2023-07-27 5f545a51231ab4955763fd812a0d914b1d8bc561
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
package com.vci.ubcs.codeapply;
 
import com.vci.base.common.resource.CommonProperties;
import com.vci.base.ui.swing.VCIOptionPane;
import com.vci.base.ui.swing.VCISwingUtil;
import com.vci.base.ui.swing.components.VCIJButton;
import com.vci.base.ui.swing.components.VCIJDialog;
import com.vci.base.ui.swing.components.VCIJPanel;
import com.vci.ubcs.codeapply.utils.ConfigUtils;
import com.vci.ubcs.system.user.entity.User;
 
import javax.swing.*;
import java.awt.*;
import java.util.LinkedHashMap;
import java.util.Map;
 
public class CodeApplyFor410Dialog extends VCIJDialog {
 
 
    private static final long serialVersionUID = -3286164100581857853L;
    private static User userOb = new User();
    private String userName = null;
    private String codeValue = null;
    private CodeApplyFor410DialogActionListener actionListener = new CodeApplyFor410DialogActionListener(this);
    private VCIJButton okBtn = VCISwingUtil.createVCIJButton("ok", "确认", "确认", "ok.gif", actionListener);
    private VCIJButton cancelBtn = VCISwingUtil.createVCIJButton("cancel", "取消", "取消", "cancel.gif", actionListener);
    private CodeApplyPanelFor410 mainPal = null;
    private Component parentComponet = null;
    private Map<String, String> attrNameAndValMap = new LinkedHashMap();//存储属性名称(包含内部名称和外部名称)和对应的值
 
    /**
     * 存储分类的Map,key:分类名称,value:分类值
     */
    private String clsfName = null;
    /**
     * 存储属性和值的Map,key:属性名称,value:属性值
     */
    private String deptName = null;
 
    private String[] libName = ConfigUtils.getConfigValue("410.PDM.LibCodeName").split("#");//ConfigUtils.getConfigValue("410.PDM.LibCodeName").split("#");//代码项名称
 
    public CodeApplyFor410Dialog(Frame frame, String clsfName, String deptName) {
        this(frame, "pdmUser", clsfName, deptName,new String[]{});
    }
    public CodeApplyFor410Dialog(JDialog dialog, String clsfName, String deptName) {
        this(dialog, "pdmUser", clsfName, deptName,new String[]{});
    }
    public CodeApplyFor410Dialog(Frame frame, String userName, String clsfName, String deptName, String[] libName){
        super(frame, true);
        try {
            this.setModal(true);
            parentComponet = frame;
            this.userName = userName;
            this.clsfName = clsfName;
            this.deptName = deptName;
            //this.libName = libName;
            init();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    public CodeApplyFor410Dialog(JDialog dialog, String userName, String clsfName, String deptName, String[] libName) {
        super(dialog, true);
        try {
            this.setModal(true);
            parentComponet = dialog;
            this.userName = userName;
            this.clsfName = clsfName;
            this.deptName = deptName;
            //    this.libName = libName;
 
            init();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    private void initUserInfo() {
//        userOb.set("127.0.0.1");
//        userOb.setModules("TC集成代码申请");
//        userOb.setUserName(userName);
    }
 
    public void buildDialog() {
        Dimension dime = Toolkit.getDefaultToolkit().getScreenSize();
        int x = dime.width/2 - 400;
        int y = dime.height/2-400;
        this.setLocation(x, y);
        this.setSize(new Dimension(900, 800));
        this.setResizable(true);
        this.setVisible(true);
    }
 
 
    private void init() {
        boolean isConnect = verifyConnect();
        if (isConnect) {
            try {
                initUserInfo();
                bulidPal();
            }catch (Exception e){
                showMessageBox( "服务出现异常:->"+e.getMessage());
            }
        } else {
            showMessageBox("无法连接代码服务器!");
        }
    }
 
    private void bulidPal() throws Exception {
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        this.setTitle("代码申请");
        mainPal = new CodeApplyPanelFor410(this,userOb, true, clsfName, deptName,libName);
 
        VCIJPanel btnPal = new VCIJPanel();
        btnPal.add(okBtn);
        btnPal.add(cancelBtn);
 
        this.setLayout(new BorderLayout());
        this.add(mainPal,BorderLayout.CENTER);
        this.add(btnPal,BorderLayout.SOUTH);
        buildDialog();
    }
 
    public boolean verifyConnect() {
        try {
//            if (ClientSession.getFrameworkService() != null) {
//                return true;
//            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
 
    public String getApplyCode() {
        return mainPal.getApplyCode();
    }
 
    public String getCodeValue() {
        return codeValue;
    }
 
    public void setCodeValue(String codeValue) {
        this.codeValue = codeValue;
    }
 
    public String getAttributeValue(String attribute) {
        if(attrNameAndValMap.containsKey(attribute)) {
            return attrNameAndValMap.get(attribute);
        }
        return "";
    }
 
    public void setAttrNameAndValMap() {
        this.attrNameAndValMap = mainPal.getAttrNameAndValMap();
    }
 
    private void showMessageBox(String message) {
        VCIOptionPane.showMessage(parentComponet, message);
    }
 
}