package com.vci.client.framework.systemConfig.stafforgmanage;
|
|
import java.awt.BorderLayout;
|
import java.awt.Dimension;
|
import java.awt.Rectangle;
|
import java.awt.event.ActionEvent;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
import javax.swing.ImageIcon;
|
import javax.swing.JCheckBox;
|
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.border.TitledBorder;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.framework.systemConfig.object.PasswordStrategyObject;
|
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.KTextField;
|
import com.vci.client.ui.swing.components.VCIJPanel;
|
|
public class PasswordSrategyDialog extends BaseJDialog {
|
|
private static final long serialVersionUID = 1L;
|
private PasswordStrategyTablePanel pwdStgTablePanel;
|
private PasswordStrategyObject pwdStgObj;
|
private String optType;
|
private Map<String, String> map = new HashMap<String, String>();
|
private JLabel lblName = new JLabel("策略名称:");
|
private JLabel passwordLabel = new JLabel("密码最小长度:");
|
private JLabel passwordMaxLabel = new JLabel("密码最大长度:");
|
private JLabel compentLabel = new JLabel("组合方式种类");
|
private JLabel requiredTypeLabel = new JLabel("必填种类");
|
private JLabel expiredLabel = new JLabel("过期时间:");
|
private JLabel remideLabel = new JLabel("提醒时间:");
|
private JLabel lockLabel = new JLabel("重试次数:");
|
private JLabel lockTimeLabel = new JLabel("锁定时间:");
|
private JLabel defaultPolicyLable = new JLabel("设置为默认策略");
|
private JLabel descLabel = new JLabel("描述:");
|
|
private JLabel unitMinuteLabel = new JLabel("(单位:分钟)");
|
private JLabel unitDayLabel = new JLabel("(单位:天)");
|
private JLabel unitExpireDayLabel = new JLabel("(单位:天)");
|
private JLabel unitLockTimeLabel = new JLabel("(单位:次)");
|
|
private KTextField txtName = new KTextField();
|
private KTextField passwordLenText = new KTextField();
|
private KTextField passwordLenMaxText = new KTextField();
|
private JComboBox requiredTypeCbx = new JComboBox();
|
private JCheckBox[] chkBoxes = null;
|
private KTextField expiredText = new KTextField();
|
private KTextField remideText = new KTextField();
|
private KTextField lockText = new KTextField();
|
private KTextField lockTimeText = new KTextField();
|
private JTextField jTextField2 = new JTextField();
|
private JTextField jTextField1 = new JTextField();
|
private JCheckBox defaultBox = new JCheckBox();
|
private 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 PasswordSrategyDialog(PasswordStrategyTablePanel pwdStgTablePanel, String optType) {
|
super(LogonApplication.frame);
|
this.setModal(true);
|
this.pwdStgTablePanel = pwdStgTablePanel;
|
this.optType = optType;
|
init();
|
}
|
|
public PasswordSrategyDialog(PasswordStrategyTablePanel pwdStgTablePanel, PasswordStrategyObject pwdStgObj,
|
String optType) {
|
super(LogonApplication.frame);
|
this.setModal(true);
|
this.pwdStgTablePanel = pwdStgTablePanel;
|
this.pwdStgObj = pwdStgObj;
|
this.optType = optType;
|
init();
|
}
|
|
/**
|
* 初始化界面
|
*/
|
public void init() {
|
this.setTitle("密码策略");
|
|
ImageIcon icon = new BundleImage().createImageIcon("folder_wrench.png");
|
|
this.setIconImage(icon.getImage());
|
// JLabel titleLabel = new JLabel();
|
// titleLabel.setText("");
|
// titleLabel.setIcon(new BundleImage().createImageIcon ("folder_wrench.png"));
|
|
JPanel bottomPanel = new JPanel();
|
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);
|
|
VCIJPanel pal = new VCIJPanel(new BorderLayout());
|
// pal.add(titleLabel, BorderLayout.NORTH);
|
pal.add(midPanel, BorderLayout.CENTER);
|
// pal.add(bottomPanel, BorderLayout.SOUTH);
|
pal.setPreferredSize(new Dimension(450, 570));
|
|
JScrollPane scroPal = new JScrollPane();
|
scroPal.setPreferredSize(new Dimension(450, 580));
|
scroPal.getViewport().add(pal);
|
this.setLayout(new BorderLayout());
|
this.add(scroPal, BorderLayout.CENTER);
|
this.add(bottomPanel, BorderLayout.SOUTH);
|
initDialogSize(480, 640);
|
this.setResizable(true);
|
}
|
|
private JPanel initCenterContentPanel() {
|
JPanel contentPanel = new JPanel();
|
contentPanel.setLayout(null);
|
JScrollPane jsDescription = new JScrollPane();
|
lblName.setBounds(new Rectangle(62, 10, 150, 25));
|
txtName.setBounds(new Rectangle(150, 10, 270, 25));
|
|
passwordLabel.setBounds(new Rectangle(62, 40, 150, 25));
|
passwordLenText.setBounds(new Rectangle(150, 40, 270, 25));
|
|
passwordMaxLabel.setBounds(new Rectangle(62, 70, 150, 25));
|
passwordLenMaxText.setBounds(new Rectangle(150, 70, 270, 25));
|
|
compentLabel.setBounds(new Rectangle(62, 100, 150, 25));
|
// JScrollPane scrollPanel = new JScrollPane(this.createCbxPanel());
|
// scrollPanel.setBounds(40, 120, 380, 70);
|
JPanel scrollPanel = new JPanel();
|
scrollPanel.setLayout(null);
|
scrollPanel.setBorder(new TitledBorder("组合方式种类"));
|
scrollPanel.setBounds(40, 100, 380, 90);
|
this.createCbxPanel(scrollPanel);
|
|
requiredTypeLabel.setBounds(new Rectangle(62, 200, 380, 25));
|
requiredTypeCbx.setBounds(new Rectangle(150, 200, 270, 25));
|
|
JPanel expirationSetPal = new JPanel();
|
expirationSetPal.setLayout(null);
|
expirationSetPal.setBorder(new TitledBorder("过期时间设置"));
|
expirationSetPal.setBounds(40, 240, 380, 90);
|
expiredLabel.setBounds(new Rectangle(25, 25, 150, 25));
|
remideLabel.setBounds(new Rectangle(25, 50, 150, 25));
|
expiredText.setBounds(new Rectangle(110, 25, 200, 25));
|
unitExpireDayLabel.setBounds(new Rectangle(310, 25, 200, 25));
|
remideText.setBounds(new Rectangle(110, 50, 200, 25));
|
unitDayLabel.setBounds(new Rectangle(310, 50, 200, 25));
|
|
expirationSetPal.add(expiredLabel);
|
expirationSetPal.add(expiredText);
|
expirationSetPal.add(remideLabel);
|
expirationSetPal.add(unitExpireDayLabel);
|
expirationSetPal.add(remideText);
|
expirationSetPal.add(unitDayLabel);
|
|
JPanel lockTimeSetPal = new JPanel();
|
lockTimeSetPal.setLayout(null);
|
lockTimeSetPal.setBorder(new TitledBorder("重试次数设置"));
|
lockTimeSetPal.setBounds(40, 340, 380, 90);
|
lockLabel.setBounds(new Rectangle(25, 25, 150, 25));
|
lockTimeLabel.setBounds(new Rectangle(25, 50, 150, 25));
|
lockText.setBounds(new Rectangle(110, 25, 200, 25));
|
unitLockTimeLabel.setBounds(new Rectangle(310, 25, 200, 25));
|
lockTimeText.setBounds(new Rectangle(110, 50, 200, 25));
|
unitMinuteLabel.setBounds(new Rectangle(310, 50, 200, 25));
|
lockTimeSetPal.add(lockLabel);
|
lockTimeSetPal.add(lockTimeLabel);
|
lockTimeSetPal.add(lockText);
|
lockTimeSetPal.add(unitLockTimeLabel);
|
lockTimeSetPal.add(lockTimeText);
|
lockTimeSetPal.add(unitMinuteLabel);
|
|
descLabel.setBounds(new Rectangle(62, 440, 150, 25));
|
jsDescription.setBounds(new Rectangle(150, 440, 270, 75));
|
descriptionArea.setLineWrap(true);
|
jsDescription.getViewport().add(descriptionArea);
|
jTextField1.setPreferredSize(new Dimension(63, 2));
|
jTextField2.setPreferredSize(new Dimension(63, 2));
|
|
defaultBox.setBounds(new Rectangle(62, 520, 20, 25));
|
defaultPolicyLable.setBounds(new Rectangle(82, 520, 200, 25));
|
|
contentPanel.setLayout(null);
|
|
contentPanel.add(lblName);
|
contentPanel.add(txtName);
|
|
contentPanel.add(passwordLabel);
|
contentPanel.add(passwordLenText);
|
|
contentPanel.add(passwordMaxLabel);
|
contentPanel.add(passwordLenMaxText);
|
|
// contentPanel.add(compentLabel);
|
contentPanel.add(scrollPanel);
|
|
contentPanel.add(requiredTypeLabel);
|
contentPanel.add(requiredTypeCbx);
|
|
contentPanel.add(expirationSetPal);
|
contentPanel.add(lockTimeSetPal);
|
|
contentPanel.add(descLabel);
|
contentPanel.add(jsDescription);
|
|
contentPanel.add(defaultBox);
|
contentPanel.add(defaultPolicyLable);
|
|
conformButton.addActionListener(new CommenListener(this, pwdStgTablePanel, optType, pwdStgObj));
|
|
cancelButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
cancelButton_ActionPerformed(e);
|
}
|
});
|
initContent();
|
return contentPanel;
|
}
|
|
// private JPanel createCbxPanel(){
|
// JPanel pal = new VCIJPanel();
|
//
|
// try {
|
// pal.removeAll();
|
// CombinationObject[] combObjs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchAllCombinations();
|
// int length = combObjs.length;
|
// //bug2231 by liujw
|
//
|
// pal.setLayout(null);
|
// chkBoxes = new JCheckBox[length];
|
// int x = 0, y= 0, width = 80, height = 25;
|
// for(int i = 0 ; i < length ; i ++){
|
// map.put(combObjs[i].getName(),combObjs[i].getId());
|
// chkBoxes[i] = new JCheckBox(combObjs[i].getName());
|
// chkBoxes[i].setName(combObjs[i].getName());
|
// if (i%2 == 1){
|
// x = 180; y = chkBoxes[i-1].getBounds().y;
|
//
|
// }else {
|
// if (i == 0){
|
// x = 30 ; y = 0;
|
// }else{
|
// x = 30 ; y = chkBoxes[i-1].getBounds().y +30;
|
// }
|
//
|
// }
|
// chkBoxes[i].setBounds(x, y, width, height);
|
// pal.add(chkBoxes[i]);
|
// pal.updateUI();
|
// requiredTypeCbx.addItem(i+1);
|
// }
|
// pal.setPreferredSize(new Dimension(360,y+20));
|
// } catch (VCIException e1) {
|
// e1.printStackTrace();
|
// }
|
// return pal;
|
// }
|
|
private void createCbxPanel(JPanel panel) {
|
// JPanel pal = new VCIJPanel();
|
|
int length = 4;
|
String[] labels = new String[] { "数字", "小写字母", "大写字母", "符号" };
|
String[] names = new String[] { "number", "lower", "upper", "symbol" };
|
chkBoxes = new JCheckBox[length];
|
int x = 0, y = 0, width = 80, height = 25;
|
for (int i = 0; i < length; i++) {
|
// map.put(names[i],labels[i]);
|
chkBoxes[i] = new JCheckBox();
|
chkBoxes[i].setName(names[i]);
|
chkBoxes[i].setText(labels[i]);
|
// chkBoxes[i].setName(combObjs[i].getName());
|
if (i % 2 == 1) {
|
x = 180;
|
y = chkBoxes[i - 1].getBounds().y;
|
|
} else {
|
if (i == 0) {
|
x = 30;
|
y = 25;
|
} else {
|
x = 30;
|
y = chkBoxes[i - 1].getBounds().y + 30;
|
}
|
|
}
|
chkBoxes[i].setBounds(x, y, width, height);
|
panel.add(chkBoxes[i]);
|
// panel.updateUI();
|
requiredTypeCbx.addItem(i + 1);
|
}
|
// pal.setPreferredSize(new Dimension(360,y+20));
|
}
|
|
private void initContent() {
|
if (pwdStgObj != null) {
|
txtName.setText(pwdStgObj.getName());
|
passwordLenText.setText(String.valueOf(pwdStgObj.getPasswordLen()));
|
passwordLenMaxText.setText(String.valueOf(pwdStgObj.getPasswordMaxLen()));
|
requiredTypeCbx.setSelectedItem(pwdStgObj.getRequiredType());
|
expiredText.setText(String.valueOf(pwdStgObj.getOverdueDay()));
|
remideText.setText(String.valueOf(pwdStgObj.getRemideDay()));
|
lockText.setText(String.valueOf(pwdStgObj.getRetryTime()));
|
lockTimeText.setText(String.valueOf(pwdStgObj.getLockTime()));
|
descriptionArea.setText(pwdStgObj.getDesc());
|
// CombinationObject[] combinationObjs = null;
|
|
int containsTypes = pwdStgObj.getCharTypes();
|
for (int i = 0; i < 4; i++) {
|
int type = (int) Math.pow(2, i);
|
if ((containsTypes & type) == type) {
|
chkBoxes[i].setSelected(true);
|
}
|
}
|
|
if (pwdStgObj.getIsDefault()) {
|
defaultBox.setSelected(true);
|
} else {
|
defaultBox.setSelected(false);
|
}
|
}
|
}
|
|
/**
|
* 取消按钮事件
|
*
|
* @param e
|
*/
|
private void cancelButton_ActionPerformed(ActionEvent e) {
|
this.dispose();
|
}
|
|
public String getName() {
|
return txtName.getText();
|
}
|
|
public String getDescriptionArea() {
|
return descriptionArea.getText().trim();
|
}
|
|
public String getPasswordLen() {
|
return passwordLenText.getText();
|
}
|
|
public String getPasswordMaxLen() {
|
return this.passwordLenMaxText.getText();
|
}
|
|
public short getRequiredType() {
|
short requiredType = 0;
|
if (!"".equals(this.requiredTypeCbx.getSelectedItem())) {
|
requiredType = Short.valueOf(this.requiredTypeCbx.getSelectedItem().toString());
|
}
|
return requiredType;
|
}
|
|
public short getContainsTypes() {
|
short containsTypes = 0;
|
for (int i = 0; i < chkBoxes.length; i++) {
|
if (chkBoxes[i].isSelected()) {
|
containsTypes = (short) (containsTypes | (short) Math.pow(2, i));
|
}
|
}
|
return containsTypes;
|
}
|
|
// public String[] getCombinationId(){
|
// List<String> list = new ArrayList<String>();
|
// for (int i = 0 ; i < chkBoxes.length ; i ++){
|
// if (chkBoxes[i].isSelected()){
|
// String combinationName = chkBoxes[i].getName();
|
// //String combinationOid = map.get(combinationName);
|
// list.add(combinationName);
|
// }
|
// }
|
// return list.toArray(new String[]{});
|
// }
|
public String getLockTime() {
|
return lockTimeText.getText();
|
}
|
|
public String getOverDay() {
|
return expiredText.getText();
|
}
|
|
public String getRemideDay() {
|
return remideText.getText();
|
}
|
|
public String getLockCount() {
|
return lockText.getText();
|
}
|
|
public boolean getIsDefault() {
|
boolean isDefault = false;
|
if (defaultBox.isSelected()) {
|
isDefault = true;
|
} else {
|
isDefault = false;
|
}
|
return isDefault;
|
}
|
|
}
|