ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
package com.vci.client.framework.systemConfig.stafforgmanage;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
 
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
 
import com.vci.client.LogonApplication;
import com.vci.client.common.TransmitTreeObject;
import com.vci.client.common.objects.DeptObject;
import com.vci.client.common.objects.UserObject;
import com.vci.client.common.providers.ServiceProvider;
import com.vci.client.framework.appConfig.object.AppConfigDetailObject;
import com.vci.client.framework.delegate.AppConfigDetailClientDelegate;
import com.vci.client.framework.delegate.RightManagementClientDelegate;
import com.vci.client.logon.base.BaseJDialog;
import com.vci.client.ui.exception.VCIException;
import com.vci.client.ui.image.BundleImage;
import com.vci.client.ui.locale.LocaleDisplay;
import com.vci.client.ui.swing.KJButton;
import com.vci.client.ui.swing.KPasswordField;
import com.vci.client.ui.swing.KTextField;
import com.vci.corba.common.VCIError;
import com.vci.corba.omd.etm.EnumChild;
import com.vci.corba.omd.etm.EnumItem;
import com.vci.mw.ClientContextVariable;
 
/**
 * <p>Title:人员添加 、修改界面 </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2012</p>
 * <p>Company: VCI</p>
 * @author wangxl
 * @time 2012-5-11
 * @version 1.0
 */
public class UserDialog extends BaseJDialog {
 
    
    private static final long serialVersionUID = 1L;
    private static final String ENUM_USERSECURITYENUM = "usersecurityenum";
    private EnumChild[] securityEnum ;
    private TransmitTreeObject transmitTreeObject;
    private UserTablePanel userTablePanel;
    private UserObject userObj;
    private String optType;
    private JLabel nameLabel = new JLabel(LocaleDisplay.getI18nString("rmip.stafforg.logal.username", "RMIPFramework", getLocale()));
    public KTextField userNameText = new KTextField();
    
    private JLabel security = new JLabel(LocaleDisplay.getI18nString("rmip.stafforg.logal.security", "RMIPFramework", getLocale()));
    public JComboBox securityCombo = new JComboBox();
    
    private JLabel passwordLabel = new JLabel(LocaleDisplay.getI18nString("rmip.stafforg.logal.password", "RMIPFramework", getLocale()));
    private KPasswordField passwordText = new KPasswordField();
    
    private JLabel confirmPasswordLabel = new JLabel(LocaleDisplay.getI18nString("rmip.stafforg.logal.confpassword", "RMIPFramework", getLocale()));
    private KPasswordField confirmPasswordText = new KPasswordField();
    
    private JLabel trueNameLabel = new JLabel(LocaleDisplay.getI18nString("rmip.stafforg.logal.firstname", "RMIPFramework", getLocale()));
    public KTextField trueNameText = new KTextField(); 
 
    private JLabel labelSpecialties = new JLabel("专业");
    public JTextField textSpecialties = new JTextField(); 
 
    private JLabel emailLabel = new JLabel("电子邮箱");
    public JTextField emailText = new JTextField(); 
    private JLabel descriptionLabel = new JLabel(LocaleDisplay.getI18nString("rmip.stafforg.logal.desc", "RMIPFramework", getLocale()));
    JTextArea descriptionArea = new JTextArea();
 
    private KJButton conformButton = new KJButton(LocaleDisplay.getI18nString("rmip.framework.button.confirm", "RMIPFramework", getLocale()), "bullet_blue.png");
    private KJButton cancelButton = new KJButton(LocaleDisplay.getI18nString("rmip.framework.button.cancel", "RMIPFramework", getLocale()) , "bullet_delete.png");
    /*
     * start add by caicong 2014/6/4 
     */
    private JLabel dept = new JLabel(LocaleDisplay.getI18nString("rmip.stafforg.logal.department", "RMIPFramework", getLocale()));
    private JComboBox deptBox = new JComboBox(); 
    /*
     * end add by caicong 2014/6/4 
     */
    private AppConfigDetailClientDelegate confDelegate = new AppConfigDetailClientDelegate(LogonApplication.getUserEntityObject());
 
    //AppConfigDetailObject ipConfigDetail = delegate.getAppConfigDetailByKey("ipSecuritySwitch");
    //AppConfigDetailObject userConfigDetail = delegate.getAppConfigDetailByKey("userSecuritySwith");
 
    public UserDialog(UserTablePanel userTablePanel ,TransmitTreeObject transmitTreeObject ,String optType){
        super(LogonApplication.frame);
        this.setModal(true);
        this.transmitTreeObject = transmitTreeObject;
        this.userTablePanel = userTablePanel;
        this.optType = optType;
        init();
    }
    public UserDialog(UserTablePanel userTablePanel ,TransmitTreeObject transmitTreeObject ,UserObject userObj , String optType){
        super(LogonApplication.frame);
        this.setModal(true);
        this.transmitTreeObject = transmitTreeObject;
        this.userTablePanel = userTablePanel;
        this.userObj = userObj;
        this.optType = optType;
        init();
    }
 
    /**
     * 初始化界面
     */
    private void init() {
         JLabel titleLabel = new JLabel();
         titleLabel.setText(LocaleDisplay.getI18nString("rmip.stafforg.menu.staff", "RMIPFramework", getLocale()));
         titleLabel.setIcon(new BundleImage().createImageIcon ("user_suit.png"));
         JPanel bottomPanel = new JPanel();
         
//         bottomPanel.add(selectFromBankButton);
         bottomPanel.add(conformButton);
         bottomPanel.add(cancelButton);
         
         JPanel contentPanel = initCenterContentPanel();
         
         JPanel midPanel = new JPanel();
         midPanel.setLayout(new BorderLayout());
         JTextField jTextField1 = new JTextField();//instead of up line
         JTextField jTextField2 = new JTextField();//instead of down line
         jTextField1.setPreferredSize(new Dimension(63,2));
         jTextField2.setPreferredSize(new Dimension(63,2));
         midPanel.add(jTextField1, BorderLayout.NORTH);
         midPanel.add(jTextField2, BorderLayout.SOUTH);
         midPanel.add(contentPanel, BorderLayout.CENTER);
         
         this.setLayout(new BorderLayout());
         this.add(titleLabel, BorderLayout.NORTH);
         this.add(midPanel, BorderLayout.CENTER);
         this.add(bottomPanel, BorderLayout.SOUTH); 
         initDialogSize(550, 400);
         this.setVisible(true);
         
    }
    
    /***
     *  绘制用户组件
     * @return
     */
    private JPanel initCenterContentPanel() {
        /**人员信息即可从人员库中选择,又可以自己手动录入**/
        JPanel contentPanel = new JPanel();
        contentPanel.setLayout(null);
        
        nameLabel.setBounds(40, 20, 60, 25);
        userNameText.setBounds(100,20,160,25);
        
        trueNameLabel.setBounds(270, 20, 60, 25);
        trueNameText.setBounds(330, 20, 160, 25);
        passwordLabel.setBounds(40, 55, 60, 25);
        passwordText.setBounds(100, 55, 160, 25);
        
        confirmPasswordLabel.setBounds(270, 55, 60, 25);
        confirmPasswordText.setBounds(330, 55, 160, 25);
        confirmPasswordText.setEnabled(false);
 
        labelSpecialties.setBounds(40, 90, 60, 25);
        textSpecialties.setBounds(100, 90, 390, 25);
        
        emailLabel.setBounds(40, 125, 60, 25);
        emailText.setBounds(100, 125, 390, 25);
        
        descriptionLabel.setBounds(40, 160, 60, 25);
        
        JScrollPane jsDescription=new JScrollPane();
        descriptionArea.setLineWrap(true);
        jsDescription.setViewportView(descriptionArea);
        jsDescription.setBounds(new Rectangle(100,160,390,50));
        
        //add by caicong 2014/6/4 start
        dept.setBounds(40, 245, 60, 25);
        deptBox.setBounds(100,245,300,25);
        deptBox.setEditable(false);
        KJButton btnDept = new KJButton();
        btnDept.setBounds(410, 245, 80, 25);
        //jLabel.setText("<html><u>"+"选择部门"+"</u><html>"); 
        btnDept.setText("选择部门"); 
        btnDept.setForeground(Color.BLACK);
        btnDept.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e){
                selectDept();
            }
        });
        //add security
         security.setBounds(40, 280, 60, 25);
         securityCombo.setBounds(100,280,180,25);
         this.initSecurityCombo();
        //add by caicong 2014/6/4  end
        passwordText.getDocument().addDocumentListener(new DocumentListener() {
            
            @SuppressWarnings("deprecation")
            public void insertUpdate(DocumentEvent e) {
                String passwordString = passwordText.getText();
                confirmPasswordText.setText("");
                if("".equals(passwordString)){
                    confirmPasswordText.setEnabled(false);
                }else{
                    confirmPasswordText.setEnabled(true);
                }
            }
            
            public void removeUpdate(DocumentEvent e) {
            }
            
            public void changedUpdate(DocumentEvent e) {
            }
            
        });
        
        conformButton.addActionListener(new UserActionListener(this, userTablePanel ,optType , userObj));
        
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                cancelButton_ActionPerformed(e);
            }
        });
        
            contentPanel.add(nameLabel);
            contentPanel.add(userNameText);
            contentPanel.add(passwordLabel);
            contentPanel.add(passwordText);
            contentPanel.add(confirmPasswordLabel);
            contentPanel.add(confirmPasswordText);
            contentPanel.add(trueNameLabel);
            contentPanel.add(trueNameText);
        
            // 专业
            contentPanel.add(labelSpecialties);
            contentPanel.add(textSpecialties);
        
    //        contentPanel.add(companyLabel);
    //        contentPanel.add(companyComBox);
            contentPanel.add(emailLabel);
            contentPanel.add(emailText);
            contentPanel.add(descriptionLabel);
            contentPanel.add(jsDescription);
            contentPanel.add(dept);
            contentPanel.add(deptBox);
            contentPanel.add(btnDept);
 
        //add by caill start 2016.11.17判断用户密级是否开启
        if(IsUserSecurity()){
            contentPanel.add(security);
            contentPanel.add(securityCombo);
                securityCombo.setEnabled(true);
        }
        //add by caill end
        initContent();
        return contentPanel;
    }
     
    private void initSecurityCombo() {
        try {
            securityCombo.setEditable(false);
            EnumItem item = ServiceProvider.getOMDService().getEnumService().getEmItemByName(ENUM_USERSECURITYENUM);
            securityEnum = item.children;
            if(!ClientContextVariable.getUserSecretSwith().equals("on")){
                //modify by weidy@2021-06-16 密级的选项不能有空的
                securityCombo.addItem("");
            }
            //securityCombo.addItem("");
            for(EnumChild child: securityEnum){
                securityCombo.addItem(child.name);
                if(userObj != null && child.value.equals(userObj.getSecretGrade())){
                    securityCombo.setSelectedItem(child.name);
                }
            }
        } catch (VCIError e) {
            e.printStackTrace();
        }
    }
    /**
     * 获取部门对象,存储到combox中。
     */
    private void selectDept() {
        DeptingTreeDialog dialog = new DeptingTreeDialog("1");
        final DeptObject deptObj = dialog.getDeptObj();
        DefaultComboBoxModel model = new DefaultComboBoxModel();
        model.addElement(new DeptObject());
        model.addElement(deptObj);
        deptBox.setModel(model);
        deptBox.setSelectedItem(deptObj);
        deptBox.setToolTipText(deptObj==null ? "" : deptObj.getName());
            
    }
    private void initContent(){
        if (userObj != null){
            //weidy@2021-06-16
            //写死,在secAdmin的时候,只显示密级的字段
            boolean readOnly = false;
            if("secAdmin".equalsIgnoreCase(ClientContextVariable.getUserName())){
                readOnly = true;
            }
            userNameText.setText(userObj.getUserName());
            userNameText.setEditable(false);
            passwordText.setText(userObj.getPwd());
            confirmPasswordText.setText(userObj.getPwd());
            trueNameText.setText(userObj.getTrueName());
            this.textSpecialties.setText(userObj.getSpecialties());
            emailText.setText(userObj.getEmail());
            descriptionArea.setText(userObj.getDesc());
            setDept(userObj.getUserName());
//            if(readOnly){
//                passwordText.setEditable(false);
//                confirmPasswordText.setEditable(false);
//                emailText.setEditable(false);
//                descriptionArea.setEditable(false);
//                deptBox.setEditable(false);
//            }else{
//                passwordText.setEditable(true);
//                confirmPasswordText.setEditable(true);
//                emailText.setEditable(true);
//                descriptionArea.setEditable(true);
//                deptBox.setEditable(true);
//            }
        }
    }
                
    //复现部门信息。
    private void setDept(String userName ) {
        try {
            DeptObject[] depts  = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchDeptByUserNames(new String[]{userName});
            if(depts.length == 0) return;
            DeptObject deptObj = depts[0];
            DefaultComboBoxModel model = new DefaultComboBoxModel();
            model.addElement(new DeptObject());
            model.addElement(deptObj);
            deptBox.setModel(model);
            deptBox.setSelectedItem(deptObj);
            deptBox.setToolTipText(deptObj==null ? "" : deptObj.getName());
        } catch (VCIException e) {
            e.printStackTrace();
        }
    }
    /**
     * 取消按钮事件
     * @param e
     */
    private void cancelButton_ActionPerformed(ActionEvent e) {
        this.dispose();
    }
        /**
         * 获取密级
         */
        public String getSecurity(){
            String selItem = (String) securityCombo.getSelectedItem();
            if(selItem != ""){
                for(EnumChild child: securityEnum){
                    securityCombo.addItem(child.name);
                    if(child.name.equals(selItem)){
                        return child.value;
                    }
                }
            }
            return "";
        }
    
        /**
         * 获取用户名
         * @return
         */
        public String getUserNameText() {
            return userNameText.getText().trim();
        }
        /**
         * 获取密码
         * @return
         */
        @SuppressWarnings("deprecation")
        public String getPasswordText() {
            return passwordText.getText().trim();
        }
        /**
         * 获取确认密码
         * @return
         */
        @SuppressWarnings("deprecation")
        public String getConformPwdText(){
            return confirmPasswordText.getText().trim();
        }
        
        /**
         * 获取姓氏
         * @return
         */
        public String gettrueNameText(){
            return trueNameText.getText().trim();
        }
        
        
        /**
         * 获取专业
         * @return
         */
        public String getSpecialtiesText(){
            return textSpecialties.getText().trim();
        }
        
        /**
         * 获取电子邮件
         * @return
         */
        public String getEmailText(){
            return emailText.getText().trim();
        }
        /**
         * 获取备注
         * @return
         */
        public String getDescriptionArea() {
            return descriptionArea.getText().trim();
        }
        
        /**
         * 获取树节点
         * @return
         */
        public TransmitTreeObject getTransmitTreeObject() {
            return transmitTreeObject;
        }
        /**
         * 获取部门
         * @return
         */
        public JComboBox getDeptBox() {
            return deptBox;
        }
        
        private Boolean IsUserSecurity() {
            try {
                AppConfigDetailObject confDetail = confDelegate.getAppConfigDetailByKey("userSecuritySwith");
                if (confDetail.getValue().equalsIgnoreCase("on"))
                    return true;
                else
                    return false;
            } catch (VCIException e) {
                e.printStackTrace();
            }
            
            return false;
        }
}