package com.vci.client.framework.specialrole;
|
|
import java.awt.BorderLayout;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.util.List;
|
|
import javax.swing.JButton;
|
import javax.swing.JComboBox;
|
import javax.swing.JLabel;
|
import javax.swing.JPanel;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.common.objects.UserObject;
|
import com.vci.client.framework.delegate.RightManagementClientDelegate;
|
import com.vci.client.framework.systemConfig.object.PasswordStrategyObject;
|
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.VCIOptionPane;
|
|
/**
|
* <p>Title: 为人员设置密级</p>
|
* <p>Description: </p>
|
* <p>Copyright: Copyright (c) 2012</p>
|
* <p>Company: VCI</p>
|
* @author wangxl
|
* @time 2012-5-23
|
* @version 1.0
|
*/
|
public class PasswordStrategySetingDialog extends BaseJDialog{
|
|
private static final long serialVersionUID = 1L;
|
private JLabel secretLevelLabel = new JLabel();
|
private JComboBox secretPsdComBox = new JComboBox();
|
private JButton conformBut = new JButton(LocaleDisplay.getI18nString("rmip.stafforg.operate.conform", "RMIPFramework", getLocale()));
|
private JButton cancelBut = new JButton(LocaleDisplay.getI18nString("rmip.stafforg.operate.cancel", "RMIPFramework", getLocale()));
|
private UserTablePanel userPanel;
|
private List<UserObject> userList;
|
|
public PasswordStrategySetingDialog(UserTablePanel userPanel ,List<UserObject> userList){
|
super(LogonApplication.frame);
|
this.userList = userList;
|
this.userPanel = userPanel;
|
this.setModal(true);
|
init();
|
}
|
|
|
/**
|
* 初始化界面
|
*/
|
private void init() {
|
JLabel titleLabel = new JLabel();
|
titleLabel.setText("设置密码策略");
|
titleLabel.setIcon(new BundleImage().createImageIcon ("folder_images.gif"));
|
JPanel bottomPanel = new JPanel();
|
bottomPanel.add(conformBut);
|
bottomPanel.add(cancelBut);
|
|
JPanel contentPanel = initCenterContentPanel();
|
JPanel midPanel = new JPanel();
|
midPanel.setLayout(new BorderLayout());
|
|
midPanel.add(contentPanel, BorderLayout.CENTER);
|
|
this.setLayout(new BorderLayout());
|
this.add(titleLabel, BorderLayout.NORTH);
|
this.add(midPanel, BorderLayout.CENTER);
|
this.add(bottomPanel, BorderLayout.SOUTH);
|
// int x = (int)(this.getParent().getLocationOnScreen().getX()) + 200;
|
// int y = (int)(this.getParent().getLocationOnScreen().getY()) + 80;
|
// this.setLocation(x , y);
|
// this.setSize(400, 200);
|
initDialogSize(400, 200);
|
this.setVisible(true);
|
}
|
|
private JPanel initCenterContentPanel() {
|
JPanel contentPanel = new JPanel();
|
contentPanel.setLayout(null);
|
|
secretLevelLabel.setText("密码策略:");
|
secretLevelLabel.setBounds(60, 30, 60, 25);
|
|
secretPsdComBox.setBounds(130, 30, 150, 25);
|
initPasswordStrategy();
|
|
conformBut.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
addButton_actionPerformed();
|
}
|
});
|
|
cancelBut.addActionListener(new ActionListener(){
|
public void actionPerformed(ActionEvent e) {
|
cancelCreate();
|
}
|
});
|
contentPanel.add(secretLevelLabel);
|
contentPanel.add(secretPsdComBox);
|
return contentPanel;
|
|
}
|
|
private void addButton_actionPerformed() {
|
String passwordStrategyId = "";
|
if (secretPsdComBox.getSelectedItem() instanceof PasswordStrategyObject){
|
passwordStrategyId = ((PasswordStrategyObject)secretPsdComBox.getSelectedItem()).getId() == null ? "" : ((PasswordStrategyObject)secretPsdComBox.getSelectedItem()).getId() ;
|
}
|
String[] userIds = new String[userList.size()];
|
for (int i = 0 ; i < userList.size() ; i ++){
|
userIds[i] = userList.get(i).getId();
|
}
|
try{
|
new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
|
.saveUserPasswordStrateg(userIds,passwordStrategyId);
|
|
}catch(VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e);
|
return ;
|
}
|
userPanel.tablePanel.refreshTableData();
|
this.dispose();
|
}
|
|
public void cancelCreate(){
|
this.dispose();
|
}
|
|
/**
|
* <p>Description: 初始化</p>
|
*
|
* @author wangxl
|
* @time 2012-5-23
|
*/
|
private void initPasswordStrategy() {
|
try {
|
secretPsdComBox.addItem(new PasswordStrategyObject());
|
PasswordStrategyObject[] objs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchAllPasswordStrategy();
|
int size = objs.length;
|
for (int i = 0; i < size; i++) {
|
secretPsdComBox.addItem(objs[i]);
|
}
|
if (userList.size() == 1){
|
PasswordStrategyObject userPasswordStrategyObj = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
|
.fetchPasswordStrategyByUserId(userList.get(0).getId());
|
if (userPasswordStrategyObj != null){
|
int count = secretPsdComBox.getItemCount();
|
for (int i = 0 ; i < count ; i++){
|
PasswordStrategyObject secObj = (PasswordStrategyObject)secretPsdComBox.getItemAt(i);
|
if (userPasswordStrategyObj.getId().equals(secObj.getId())){
|
secretPsdComBox.setSelectedIndex(i);
|
break;
|
}
|
}
|
}
|
}
|
} catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e);
|
return ;
|
}
|
}
|
}
|