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
268
269
270
271
package com.vci.client.framework.specialrole;
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
 
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.UserObject;
import com.vci.client.logon.base.BaseJDialog;
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;
 
/**
 * <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 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 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 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");
    
    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(610, 400);
         this.setVisible(true);
         
    }
    
    /***
     *  绘制用户组件
     * @return
     */
    private JPanel initCenterContentPanel() {
        /**人员信息即可从人员库中选择,又可以自己手动录入**/
        JPanel contentPanel = new JPanel();
        contentPanel.setLayout(null);
        
        nameLabel.setBounds(60, 20, 80, 25);
        userNameText.setBounds(120,20,180,25);
        
        passwordLabel.setBounds(310, 20, 80, 25);
        passwordText.setBounds(370, 20, 180, 25);
        
        confirmPasswordLabel.setBounds(60, 55, 80, 25);
        confirmPasswordText.setBounds(120, 55, 180, 25);
        confirmPasswordText.setEnabled(false);
 
        trueNameLabel.setBounds(310, 55, 80, 25);
        trueNameText.setBounds(370, 55, 180, 25);
        
        emailLabel.setBounds(60, 90, 80, 25);
        emailText.setBounds(120, 90, 430, 25);
        
        
        
        descriptionLabel.setBounds(60, 125, 80, 25);
        
        JScrollPane jsDescription=new JScrollPane();
        descriptionArea.setLineWrap(true);
        jsDescription.setViewportView(descriptionArea);
        jsDescription.setBounds(new Rectangle(120,125,430,110));
        
        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(companyLabel);
//        contentPanel.add(companyComBox);
        contentPanel.add(emailLabel);
        contentPanel.add(emailText);
        contentPanel.add(descriptionLabel);
        contentPanel.add(jsDescription);
        initContent();
        return contentPanel;
    }
    
    private void initContent(){
        if (userObj != null){
            userNameText.setText(userObj.getUserName());
            userNameText.setEditable(false);
            passwordText.setText(userObj.getPwd());
            confirmPasswordText.setText(userObj.getPwd());
            trueNameText.setText(userObj.getTrueName());
            emailText.setText(userObj.getEmail());
            emailText.setText(userObj.getEmail());
            descriptionArea.setText(userObj.getDesc());
            
        }
    }
    
    /**
     * 取消按钮事件
     * @param e
     */
    private void cancelButton_ActionPerformed(ActionEvent e) {
        this.dispose();
    }
 
        /**
         * 获取用户名
         * @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 getEmailText(){
            return emailText.getText().trim();
        }
        /**
         * 获取备注
         * @return
         */
        public String getDescriptionArea() {
            return descriptionArea.getText().trim();
        }
        
        /**
         * 获取树节点
         * @return
         */
        public TransmitTreeObject getTransmitTreeObject() {
            return transmitTreeObject;
        }
 
}