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; /** *
Title:人员添加 、修改界面
*Description:
*Copyright: Copyright (c) 2012
*Company: VCI
* @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; } }