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;
|
}
|
}
|