package com.vci.client.framework.systemConfig.stafforgmanage;
|
|
import java.awt.BorderLayout;
|
import java.awt.Color;
|
import java.awt.Dimension;
|
import java.awt.FlowLayout;
|
import java.awt.Point;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseEvent;
|
import java.util.ArrayList;
|
import java.util.Hashtable;
|
import java.util.LinkedHashMap;
|
import java.util.LinkedList;
|
import java.util.List;
|
|
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.JComboBox;
|
import javax.swing.JLabel;
|
import javax.swing.JPanel;
|
import javax.swing.JTextField;
|
import javax.swing.border.TitledBorder;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.common.TransmitTreeObject;
|
import com.vci.client.common.VCIBasePanel;
|
import com.vci.client.common.objects.DeptObject;
|
import com.vci.client.common.objects.RoleObject;
|
import com.vci.client.common.objects.UserEntityObject;
|
import com.vci.client.common.objects.UserLogonObject;
|
import com.vci.client.common.objects.UserObject;
|
import com.vci.client.common.providers.ServiceProvider;
|
import com.vci.client.framework.delegate.RightManagementClientDelegate;
|
import com.vci.client.framework.rightConfig.object.FunctionObject;
|
import com.vci.client.framework.specialrole.ModuleInterface.IModuleShow;
|
import com.vci.client.framework.systemConfig.object.PasswordStrategyObject;
|
import com.vci.client.framework.util.RightControlUtil;
|
import com.vci.client.ui.exception.VCIException;
|
import com.vci.client.ui.locale.LocaleDisplay;
|
import com.vci.client.ui.swing.KJButton;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.ui.swing.VCISwingUtil;
|
import com.vci.client.ui.swing.components.VCIJButton;
|
import com.vci.client.ui.swing.components.VCIJPanel;
|
import com.vci.client.ui.swing.components.table.AbstractVCIJTableDataProvider;
|
import com.vci.client.ui.swing.components.table.VCIJTableNode;
|
import com.vci.client.ui.swing.components.table.VCIJTablePanel;
|
import com.vci.client.ui.util.UIHelper;
|
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;
|
|
/**
|
* 成员管理界面,带Table页,便于客户查询
|
* @author wangxl
|
*
|
*/
|
public class UserTablePanel extends VCIBasePanel implements IModuleShow{
|
|
private static final long serialVersionUID = 1L;
|
private static final String ENUM_USERSECURITYENUM = "usersecurityenum";
|
private UserObject userInfo;
|
private String userName = LogonApplication.getUserEntityObject().getUserName();
|
private UserEntityObject userEntityObj = LogonApplication.getUserEntityObject();
|
private TransmitTreeObject transmitTreeObject = null;
|
public boolean isSearchClick = false;
|
Hashtable<String, String> hashTable = new Hashtable<String, String>();
|
// 控件的坐标位置变量
|
private int x = 10;
|
private int y = 20;
|
private int width = 50;
|
private int height = 25;
|
private int hspan = 5;
|
|
private JLabel trueNameLabel = new JLabel(LocaleDisplay.getI18nString("rmip.stafforg.logal.firstname", "RMIPFramework", getLocale()));
|
private JTextField trueNameText = new JTextField();
|
private JLabel nameLabel = new JLabel(LocaleDisplay.getI18nString("rmip.stafforg.logal.username", "RMIPFramework", getLocale()));
|
private JTextField userNameText = new JTextField();
|
private JLabel departmentLabel = new JLabel(LocaleDisplay.getI18nString("rmip.stafforg.logal.department", "RMIPFramework", getLocale()));
|
private JComboBox departmentComBox = new JComboBox();
|
|
private JLabel roleLabel = new JLabel("角色:");
|
private JComboBox roleComBox = new JComboBox();
|
|
private KJButton searchButton = new KJButton("查询","search.png");
|
|
private KJButton clearButton = new KJButton("清空","clear.gif");
|
|
private VCIJButton addButton = VCISwingUtil.createVCIJButton("",LocaleDisplay.getI18nString("rmip.stafforg.operate.add", "RMIPFramework", getLocale()) , LocaleDisplay.getI18nString("rmip.stafforg.operate.add", "RMIPFramework", getLocale()),"create.gif",null);
|
private VCIJButton editButton = VCISwingUtil.createVCIJButton("",LocaleDisplay.getI18nString("rmip.stafforg.operate.modify", "RMIPFramework", getLocale()) ,LocaleDisplay.getI18nString("rmip.stafforg.operate.modify", "RMIPFramework", getLocale()), "modify.gif",null);
|
private VCIJButton deleteButton = VCISwingUtil.createVCIJButton("",LocaleDisplay.getI18nString("rmip.stafforg.operate.delete", "RMIPFramework", getLocale()) ,LocaleDisplay.getI18nString("rmip.stafforg.operate.delete", "RMIPFramework", getLocale()), "delete.gif",null);
|
private VCIJButton roleButton = VCISwingUtil.createVCIJButton("","分配角色" ,"分配角色", "star.png",null);
|
private VCIJButton deptButton = VCISwingUtil.createVCIJButton("","分配部门" ,"分配部门", "book.png",null);
|
private VCIJButton setPasswordStrategyButton = VCISwingUtil.createVCIJButton("","设置密码策略" , "设置密码策略", "folder_images.gif" ,null);
|
private VCIJButton stopButton = VCISwingUtil.createVCIJButton("", "停用" , "停用" , "ruby_delete.png",null);
|
private VCIJButton startButton = VCISwingUtil.createVCIJButton("", "启用" ,"启用", "ruby_get.png",null);
|
private VCIJButton deblockButton = VCISwingUtil.createVCIJButton("", "解锁" ,"解锁" , "rightclass.gif",null);
|
private VCIJButton importButton = VCISwingUtil.createVCIJButton("", "导入人员" ,"导入人员" , "import.gif",null);
|
// private UsersExcelImportDialogActionListener actionListener = new UsersExcelImportDialogActionListener(this);
|
private VCIJButton btnExport = VCISwingUtil.createVCIJButton("export", "下载导入模板", "下载导入模板", "export.gif", null);
|
private ArrayList<Integer> ColumnNameisRed = new ArrayList<Integer>();
|
|
private LinkedList<VCIJButton> selfCustomButtons = new LinkedList<VCIJButton>();
|
{
|
selfCustomButtons.add(addButton);
|
selfCustomButtons.add(editButton);
|
selfCustomButtons.add(deleteButton);
|
// selfCustomButtons.add(roleButton);
|
selfCustomButtons.add(deptButton);
|
selfCustomButtons.add(setPasswordStrategyButton);
|
selfCustomButtons.add(stopButton);
|
selfCustomButtons.add(startButton);
|
selfCustomButtons.add(deblockButton);
|
selfCustomButtons.add(importButton);
|
selfCustomButtons.add(btnExport);
|
}
|
|
private String logonUserId = "",logonRoleId;
|
private String moduleName = "";
|
private String iconName,moduleShowInfo ;
|
|
// private SpecialRoleObject specialRoleObject = new SpecialRoleObject();
|
// public SpecialRoleObject getSpecialRoleObject() {
|
// return specialRoleObject;
|
// }
|
//
|
// public void setSpecialRoleObject(SpecialRoleObject specialRoleObject) {
|
// this.specialRoleObject = specialRoleObject;
|
// }
|
public String getLogonUserId() {
|
return logonUserId;
|
}
|
public void setLogonUserId(String logonUserId) {
|
this.logonUserId = logonUserId;
|
}
|
public String getLogonRoleId() {
|
return logonRoleId;
|
}
|
public void setLogonRoleId(String logonRoleId) {
|
this.logonRoleId = logonRoleId;
|
}
|
public void setModuleName(String moduleName) {
|
this.moduleName = moduleName;
|
}
|
public void setIconName(String iconName) {
|
this.iconName = iconName;
|
}
|
public void setModuleShowInfo(String moduleShowInfo) {
|
this.moduleShowInfo = moduleShowInfo;
|
}
|
public UserTablePanel(FunctionObject funcObj){
|
super(funcObj);
|
init();
|
// checkPermission();
|
}
|
private void init() {
|
LogonApplication.getUserEntityObject().setModules(this.getModuleName());
|
initComponents();
|
initAction();//初始化按钮点击事件
|
}
|
private void initComponents() {
|
setLayout(new BorderLayout());
|
initDepartment();
|
initRole();
|
add(initTablePanel(), BorderLayout.CENTER);
|
}
|
/** 权限检查的模块标识 **/
|
private void checkPermission(){
|
checkRight(RightControlUtil.CREATE, addButton);
|
checkRight(RightControlUtil.UPDATE, editButton);
|
checkRight(RightControlUtil.DELETE, deleteButton);
|
checkRight(RightControlUtil.EXPORT, roleButton);
|
checkRight(RightControlUtil.IMPORT, deptButton);
|
checkRight(RightControlUtil.RIGHT, setPasswordStrategyButton);
|
checkRight(RightControlUtil.UNFREZE, stopButton);
|
checkRight(RightControlUtil.RECYCLE, startButton);
|
checkRight(RightControlUtil.DISCARD, deblockButton);
|
checkRight(RightControlUtil.IMPORT2, importButton);
|
}
|
|
|
class MyDataProvider extends AbstractVCIJTableDataProvider<UserObject> {
|
private searchInfoClass searchInfos = new searchInfoClass();
|
|
public searchInfoClass getSearchInfos() {
|
return searchInfos;
|
}
|
|
public void setSearchInfos(searchInfoClass searchInfos) {
|
this.searchInfos = searchInfos;
|
}
|
|
@Override
|
public UserObject[] getDatas(int pageNo, int pageSize) {
|
UserObject[] userObj = null;
|
try {
|
//add by caill 2016.9.26判断是否是级联查询
|
if(isSearchClick){
|
userObj = new RightManagementClientDelegate(userEntityObj).fetchNormalUserInfoByConditionUnited(
|
searchInfos.getName() ,searchInfos.getUserName() , searchInfos.getDeptId(), searchInfos.getRoleId(),userName,pageNo,pageSize);
|
} else {
|
userObj = new RightManagementClientDelegate(userEntityObj).fetchNormalUserInfoByCondition(
|
searchInfos.getName() ,searchInfos.getUserName() , searchInfos.getDeptId(), searchInfos.getRoleId(),userName,pageNo,pageSize);
|
}
|
//add by caill end
|
/*userObj = new RightManagementClientDelegate(userEntityObj).fetchUserInfoByCondition(
|
searchInfos.getName() ,searchInfos.getUserName() , searchInfos.getDeptId(), searchInfos.getRoleId(),userName,pageNo,pageSize);*/
|
|
} catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
|
return null;
|
}
|
return userObj;
|
}
|
|
@Override
|
public VCIJTableNode<UserObject> getNewRowNode(UserObject dataObj) {
|
VCIJTableNode<UserObject> node = new VCIJTableNode<UserObject>(dataObj);
|
node.setPropertyValue(getSpecialColumns()[0], dataObj.getTrueName());
|
node.setPropertyValue(getSpecialColumns()[1], dataObj.getUserName());
|
node.setPropertyValue(getSpecialColumns()[2], dataObj.getStatus()==1 ? "停用":"启用");
|
/********BEGIN***********/
|
/**密码策略**/
|
try {
|
PasswordStrategyObject userPasswordStrategyObj = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
|
.fetchPasswordStrategyByUserId(dataObj.getId());
|
node.setPropertyValue(getSpecialColumns()[3], userPasswordStrategyObj == null ? "" : userPasswordStrategyObj);
|
} catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
|
}
|
|
/**锁定状态**/
|
try {
|
UserLogonObject lockObj = new RightManagementClientDelegate().getUserLogonObj(dataObj.getId());
|
node.setPropertyValue(getSpecialColumns()[4], lockObj.getPlWrongNum() == 0 ? "未锁定" : "锁定");
|
} catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
|
}
|
/********END***********/
|
|
// CompanyObject companyObj = null;
|
DeptObject obj = null;
|
RoleObject[] roles = null;
|
String deptName = "";
|
try {
|
obj = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
|
.fetchDeptByUserId(dataObj.getId());
|
if (obj != null){
|
if(!hashTable.containsKey((obj.getId()))){
|
deptName = getDeptObjectAllByDeptId(obj);
|
hashTable.put(obj.getId(), deptName);
|
}else{
|
deptName = hashTable.get(obj.getId());
|
}
|
}
|
|
roles = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
|
.fetchRoleInfoByUserId(dataObj.getId());
|
} catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework",e);
|
}
|
|
node.setPropertyValue(getSpecialColumns()[5], deptName);
|
|
// 专业
|
node.setPropertyValue(getSpecialColumns()[6], dataObj.getSpecialties());
|
|
String roleNames = "";
|
if (roles.length != 0){
|
for(int j = 0 ; j < roles.length ; j ++){
|
if (j < roles.length -1){
|
roleNames += roles[j].getName() + ",";
|
}else {
|
roleNames += roles[j].getName();
|
}
|
}
|
}
|
node.setPropertyValue(getSpecialColumns()[7], roleNames);
|
|
node.setPropertyValue(getSpecialColumns()[8], dataObj.getEmail());
|
|
node.setPropertyValue(getSpecialColumns()[9], dataObj.getDesc());
|
|
node.setPropertyValue(getSpecialColumns()[10], dataObj.getIsDeptLeader().equals("1") ? "是" : "否");
|
String secretGrade = dataObj.getSecretGrade();
|
try {
|
EnumItem item = ServiceProvider.getOMDService().getEnumService().getEmItemByName(ENUM_USERSECURITYENUM);
|
EnumChild[] children = item.children;
|
String securityShowName = "";
|
for(EnumChild child: children){
|
if(child.value.equals(secretGrade)){
|
securityShowName = child.name;
|
break;
|
}
|
}
|
node.setPropertyValue(getSpecialColumns()[11], securityShowName);
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
// node.setPropertyValue(getSpecialColumns()[10], SecretLevelConstants.getSecretLevelDescript(secretGrade));
|
return node;
|
}
|
|
@Override
|
public String[] getSpecialColumns() {
|
return "姓名, 账号, 状态, 密码策略, 锁定状态, 所属部门, 专业, 角色, 电子邮件, 描述, 部门领导, 密级".split(",");
|
}
|
|
//根据子部门查询所属的父类部门,并拼接成字符串形式,返回
|
public String getDeptObjectAllByDeptId(DeptObject obj){
|
String fetchDepName = "";
|
try{
|
DeptObject[] depObjectAll = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
|
.fetchDepartmentInfosBySonId(obj.getId());
|
|
for(int i=depObjectAll.length-1;i>=0; i--){
|
fetchDepName += depObjectAll[i].getName()+"/";
|
}
|
if(fetchDepName.length() != 0){
|
fetchDepName = fetchDepName.substring(0, fetchDepName.length() - 1);
|
}
|
}catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
|
}
|
|
return fetchDepName;
|
|
}
|
|
@Override
|
public int getTotal() {
|
try {
|
total = new RightManagementClientDelegate(userEntityObj).getNormalUserTotalByCondition(
|
searchInfos.getName() ,searchInfos.getUserName() , searchInfos.getDeptId(), searchInfos.getRoleId(),userName);
|
} catch (VCIException e) {
|
e.printStackTrace();
|
VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework",e);
|
}
|
|
return this.total;
|
}
|
}
|
MyDataProvider dataProvider = new MyDataProvider();
|
VCIJTablePanel<UserObject> tablePanel = new VCIJTablePanel<UserObject>(dataProvider);
|
private VCIJPanel tablePanel(){
|
int startIndex = dataProvider.getDataColumnStartIndex()+5;
|
LinkedHashMap<Integer, Integer> widthMaps = new LinkedHashMap<Integer, Integer>();
|
widthMaps.put(startIndex++, 250); // 部门
|
widthMaps.put(startIndex++, 250); // 专业
|
widthMaps.put(startIndex++, 250); // 角色
|
widthMaps.put(startIndex++, 250); // Email
|
widthMaps.put(startIndex++, 250); // 描述
|
widthMaps.put(startIndex++, 80); // 部门领导
|
|
tablePanel.setColumnWidthMaps(widthMaps);
|
tablePanel.setCustomButtons(selfCustomButtons);
|
tablePanel.setShowPaging(true);
|
tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER);
|
tablePanel.setPageButtonFlowAlign(FlowLayout.CENTER);
|
tablePanel.setShowExport(false);
|
tablePanel.buildTablePanel();
|
tablePanel.refreshTableData();
|
return tablePanel;
|
}
|
|
private JPanel initTablePanel(){
|
JPanel pal = new JPanel();
|
pal.setLayout(new BorderLayout());
|
pal.setBorder(new TitledBorder("成员管理"));
|
|
JPanel searchPal = new JPanel();
|
searchPal.setLayout(null);
|
searchPal.setPreferredSize(new Dimension(600,40));
|
|
|
|
x = 20; y = 7; width = 40; height = 23;
|
trueNameLabel.setBounds(x, y, width, height);
|
|
x = trueNameLabel.getX() + trueNameLabel.getWidth(); width = 120;
|
trueNameText.setBounds(x, y, width, height);
|
|
x = trueNameText.getX() + trueNameText.getWidth() + height;width = 40;
|
nameLabel.setBounds(x, y, width, height);
|
|
x = nameLabel.getX() + nameLabel.getWidth() ; width = 120;
|
userNameText.setBounds(x, y, width, height);
|
|
//x = 20; y = 50; width = 40; height = 23;
|
x = userNameText.getX() + userNameText.getWidth() + height ; width = 40;
|
roleLabel.setBounds(x, y, width, height);
|
|
x = roleLabel.getX() +roleLabel.getWidth(); width=120;
|
roleComBox.setBounds(x, y, width, height);
|
|
x = roleComBox.getX() +roleComBox.getWidth() + height; width=40;
|
departmentLabel.setBounds(x, y, width, height);
|
|
x = departmentLabel.getX() +departmentLabel.getWidth() + 10; width=120;
|
departmentComBox.setBounds(x, y, width, height);
|
|
JLabel jLabel = new JLabel();
|
x = departmentComBox.getX() +departmentComBox.getWidth() + 10; width=50;
|
jLabel.setBounds(x, y, width, height);
|
departmentComBox.setEnabled(false);
|
|
jLabel.setText("<html><u>"+"选择部门"+"</u><html>");
|
jLabel.setForeground(Color.BLACK);
|
jLabel.addMouseListener(new MouseAdapter() {
|
public void mouseClicked(MouseEvent e){
|
selectDept();
|
}
|
});
|
|
|
x += jLabel.getWidth() + hspan * 3; width=80;height=23;
|
searchButton.setBounds(x, y, width, height);
|
|
x += searchButton.getWidth() + hspan; width=80;height=23;
|
clearButton.setBounds(x, y, width, height);
|
|
searchPal.add(trueNameLabel);
|
searchPal.add(trueNameText);
|
searchPal.add(nameLabel);
|
searchPal.add(userNameText);
|
searchPal.add(departmentLabel);
|
searchPal.add(departmentComBox);
|
searchPal.add(roleLabel);
|
searchPal.add(roleComBox);
|
searchPal.add(jLabel);
|
searchPal.add(searchButton);
|
searchPal.add(clearButton);
|
|
pal.add(searchPal, BorderLayout.NORTH);
|
pal.add(tablePanel(), BorderLayout.CENTER);
|
pal.setVisible(true);
|
return pal;
|
}
|
|
private void selectDept() {
|
DeptingTreeDialog dialog = new DeptingTreeDialog("1");
|
final DeptObject dept = dialog.getDeptObj();
|
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
model.addElement(new DeptObject());
|
model.addElement(dept);
|
departmentComBox.setModel(model);
|
departmentComBox.setSelectedItem(dept);
|
departmentComBox.setToolTipText(dept==null ? "" : dept.getName());
|
|
}
|
|
|
/**
|
* 初始化部门
|
*
|
*/
|
private void initDepartment() {
|
departmentComBox.addItem(new DeptObject());
|
}
|
/**
|
* 初始化角色
|
*
|
*/
|
private void initRole() {
|
try {
|
roleComBox.addItem(new RoleObject());
|
userInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByName(userName);
|
RoleObject[] roleInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchRoleInfoByType(userInfo.getUserType());
|
int size = roleInfo.length;
|
for (int i = 0; i < size; i++) {
|
roleComBox.addItem(roleInfo[i]);
|
}
|
} catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
|
return ;
|
}
|
}
|
|
private void initAction(){
|
|
if(!"secAdmin".equals(userInfo.getUserName())){
|
deblockButton.setVisible(false);
|
}
|
if("secAdmin".equals(userInfo.getUserName())){
|
addButton.setVisible(false);
|
editButton.setVisible(true);
|
deleteButton.setVisible(false);
|
roleButton.setVisible(false);
|
deptButton.setVisible(false);
|
setPasswordStrategyButton.setVisible(false);
|
stopButton.setVisible(false);
|
startButton.setVisible(false);
|
importButton.setVisible(false);
|
btnExport.setVisible(false);
|
}
|
tablePanel.getTable().addMouseListener(new MouseAdapter() {
|
public void mouseReleased(MouseEvent e) {
|
mousePressed(e);
|
}
|
|
public void mousePressed(MouseEvent e) {
|
Point p = e.getPoint();
|
int row = tablePanel.getTable().rowAtPoint(p);
|
if(row < 0) return;
|
UserObject obj = tablePanel.getTableModel().getList().get(row).getObject();
|
/**停用,启用状态的判断**/
|
if (obj.getStatus()==0){
|
stopButton.setEnabled(true);
|
startButton.setEnabled(false);
|
}else{
|
stopButton.setEnabled(false);
|
startButton.setEnabled(true);
|
}
|
|
/**解锁状态是否启用**/
|
String lockName = (String) tablePanel.getTableModel().getList().get(row).getPropertyValue("锁定状态");
|
boolean lockFlag = lockName == "未锁定" ? true : false;
|
if(lockFlag) {
|
deblockButton.setEnabled(false);
|
}else {
|
deblockButton.setEnabled(true);
|
}
|
|
}
|
});
|
searchButton.addActionListener(new ActionListener(){
|
public void actionPerformed(ActionEvent e){
|
searchButton_actionPerformed();
|
}
|
});
|
|
clearButton.addActionListener(new ActionListener(){
|
public void actionPerformed(ActionEvent e){
|
clearButton_actionPerformed();
|
}
|
});
|
addButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
addButton_conform();
|
}
|
});
|
editButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
editButton_conform();
|
}
|
});
|
deleteButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
deleteButton_actionPerformed();
|
}
|
});
|
roleButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
roleButton_actionPerformed();
|
}
|
});
|
deptButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
deptButton_actionPerformed();
|
}
|
});
|
setPasswordStrategyButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
setPasswordStrategyButton_actionPerformed();
|
}
|
});
|
|
stopButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
stopButton_actionPerformed();
|
}
|
});
|
startButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
startButton_actionPerformed();
|
}
|
});
|
deblockButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
deblockButton_actionPerformed();
|
}
|
});
|
importButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
importButton_actionPerformed();
|
}
|
});
|
btnExport.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
/*downloadImportStuffTemplate();*/
|
new UsersExcelImportDialogActionListener().downloadImportStuffTemplate();
|
}
|
});
|
}
|
// private void downloadImportStuffTemplate() {
|
// final String[] columns = new String[] { "账号", "密码", "姓名", "电子邮箱", "描述",
|
// "部门(上下级部门之间以反斜杠隔开(/))" ,"密级"};// 设置表单列名
|
// ColumnNameisRed.clear();
|
// ColumnNameisRed.add(0);
|
// ColumnNameisRed.add(1);
|
// ColumnNameisRed.add(2);
|
// final boolean[] ress = new boolean[1];
|
// final QANProcessBarFrame frame = new QANProcessBarFrame();
|
// final QANProcessBar[] bar = new QANProcessBar[1];
|
// bar[0] = new QANProcessBar(new Thread() {
|
// public void run() {
|
// frame.setContent("正在导出Excel文件,请稍等......");
|
// try {
|
// String[][] datas = new String[1][columns.length];
|
// datas[0] = columns;
|
// ress[0] = exportExcel(datas, "人员模板");
|
// } finally {
|
// frame.setProcessBarCancel(true);
|
// }
|
// }
|
// }, frame, frame, "人员模板导出", false);
|
// bar[0].setVisible(true);
|
// if (ress[0]) {
|
// VCIOptionPane.showMessageDialog(LogonApplication.frame, "导出成功!");
|
// }
|
//
|
// }
|
// private boolean exportExcel(String[][] datas, String sheetName) {
|
// File file = getRequiredFile(false);
|
// if (file == null) {
|
// return false;
|
// }
|
// String fileName = file.getAbsolutePath();
|
// // add by xchao 2014.05.15 end
|
// new ExcelFileOperation().writeExcelFileInfo(fileName, sheetName, datas,
|
// new ExcelCellStyleSettingCallback() {
|
// @Override
|
// public WorkboolStyleSetting doSetWorkbookStyle(
|
// final Workbook workbook) {
|
// WorkboolStyleSetting setting = new WorkboolStyleSetting() {
|
// @Override
|
// public LinkedHashMap<String, CellStyle> getStyleMap() {
|
// LinkedHashMap<String, CellStyle> styleMap = new LinkedHashMap<String, CellStyle>();
|
// org.apache.poi.ss.usermodel.CellStyle style = workbook
|
// .createCellStyle();
|
// org.apache.poi.ss.usermodel.Font font = (org.apache.poi.ss.usermodel.Font) workbook
|
// .createFont();
|
// font.setColor(HSSFFont.COLOR_RED);
|
// style.setFont(font);
|
// for (int column : ColumnNameisRed) {
|
// styleMap.put("0*" + (column) + "", style);
|
// }
|
// return styleMap;
|
// }
|
// };
|
// return setting;
|
// }
|
// });
|
// return true;
|
// }
|
// private File getRequiredFile(boolean isRead) {
|
// File files = getExcelFile();
|
// // add by xchao 2014.04.15 begin
|
// // 有错误数据要输出时,必须选择有效的excel文件
|
// while (files == null) {
|
// return null;
|
// }
|
// String fileName = files.getAbsolutePath();
|
// // 需要写入时,必须选择一个有效的、可以写入的文件
|
// if (!isRead) {
|
// // 如果文件被打开着,则必须选择其它的未打开着的文件
|
// while (files.exists() && !files.renameTo(new File(fileName))) {
|
// VCIJOptionPane.showMessageDialog(null,
|
// "另一个程序正在使用此文件,进程无法访问,请重新选择!");
|
// // 重新选择文件时,也必须选择有效的excel文件
|
// files = null;
|
// while (files == null) {
|
// files = getExcelFile();
|
// }
|
// fileName = files.getAbsolutePath();
|
// }
|
// }
|
// return files;
|
// }
|
/**
|
* 搜索事件
|
*/
|
private void searchButton_actionPerformed(){
|
searchInfoClass searchInfo = new searchInfoClass();
|
searchInfo.setName(this.gettrueNameText().trim());
|
searchInfo.setUserName(this.getUserNameText().trim());
|
searchInfo.setRoleId(this.getRoleId());
|
searchInfo.setDeptId(this.getDeptId());
|
|
dataProvider.setSearchInfos(searchInfo);
|
//add by caill 2016.9.26
|
int j = VCIOptionPane.showConfirmDialog(UserTablePanel.this, "是否级联查询当前部门下的子部门的用户?",LocaleDisplay.getI18nString("rmip.framework.friend.message.dialog.title", "RMIPFramework", getLocale()),VCIOptionPane.YES_NO_OPTION);
|
if(j==0){
|
isSearchClick=true;
|
}else{
|
isSearchClick=false;
|
}
|
//add by caill end
|
this.tablePanel.refreshTableData();
|
}
|
|
private void clearButton_actionPerformed(){
|
|
this.userNameText.setText("");
|
this.trueNameText.setText("");
|
this.departmentComBox.setSelectedIndex(0);
|
departmentComBox.setToolTipText("");
|
this.roleComBox.setSelectedIndex(0);
|
|
searchInfoClass info = new searchInfoClass();
|
dataProvider.setSearchInfos(info);
|
tablePanel.refreshTableData();
|
}
|
/**
|
* 添加事件
|
*/
|
private void addButton_conform(){
|
new UserDialog(this,transmitTreeObject,"add");
|
}
|
|
/**
|
* 修改事件
|
*/
|
private void editButton_conform(){
|
|
int len = tablePanel.getSelectedRowIndexs().length;
|
if(len == 0){
|
VCIOptionPane.showMessage(this,
|
"请选择人员再进行操作!");
|
return;
|
}
|
if (len > 1){
|
VCIOptionPane.showMessage(this,
|
LocaleDisplay.getI18nString("rmip.stafforg.operate.useredit2", "RMIPFramework", getLocale()));
|
return;
|
}
|
|
UserObject obj = tablePanel.getSelectedRowObjects().get(0);
|
new UserDialog(this,transmitTreeObject , obj ,"edit");
|
}
|
|
/**
|
* 删除事件
|
*/
|
private void deleteButton_actionPerformed(){
|
int len = tablePanel.getSelectedRowIndexs().length;
|
if(len == 0){
|
VCIOptionPane.showMessage(this,
|
LocaleDisplay.getI18nString("rmip.stafforg.operate.userdelete1", "RMIPFramework", getLocale()));
|
return;
|
}
|
List<UserObject> objList = tablePanel.getSelectedRowObjects();
|
for(int i=0;i<objList.size();i++){
|
UserObject userObj = objList.get(i);
|
String name = LogonApplication.getUserEntityObject().getUserName();
|
String userName = userObj.getUserName();
|
if(name.equals(userName)){
|
VCIOptionPane.showMessage(this,
|
"不可以删除自己!");
|
return;
|
}
|
if(RightControlUtil.isAdminOrDeveloperOrRoot(userName)
|
|| userName.equalsIgnoreCase("sysAdmin")
|
|| userName.equalsIgnoreCase("secAdmin")
|
|| userName.equalsIgnoreCase("auditAdmin")){
|
VCIOptionPane.showMessage(this,
|
"该用户不可以删除!");
|
return;
|
}
|
|
}
|
int ask = VCIOptionPane.showQuestion(this,
|
LocaleDisplay.getI18nString("rmip.stafforg.operate.userdelete2", "RMIPFramework", getLocale()));
|
if(ask == 1) return;
|
|
String[] puids = new String[len];
|
for (int i = 0; i < len; i++) {
|
UserObject obj = tablePanel.getSelectedRowObjects().get(i);
|
puids[i] = obj.getId();
|
}
|
boolean rs=true;
|
try {
|
rs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).deleteUser(puids);
|
} catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e);
|
return;
|
}
|
if (!rs) {
|
return;
|
}
|
tablePanel.refreshTableData();
|
}
|
|
private void roleButton_actionPerformed(){
|
int len = tablePanel.getSelectedRowIndexs().length;
|
if(len == 0){
|
VCIOptionPane.showMessage(this,
|
"请选择要进行分配角色的人员!");
|
return;
|
}
|
|
List<UserObject> objList = tablePanel.getSelectedRowObjects();
|
for(int i=0;i<objList.size();i++){
|
String name = LogonApplication.getUserEntityObject().getUserName();
|
String userName = objList.get(i).getUserName();
|
if(name.equals(userName)){
|
VCIOptionPane.showMessage(this,
|
"不可以给自己分配角色!");
|
return;
|
}
|
}
|
new RolingDialog(this,objList);
|
}
|
private void deptButton_actionPerformed(){
|
int len = tablePanel.getSelectedRowIndexs().length;
|
if(len == 0){
|
VCIOptionPane.showMessage(this,
|
"请选择要进行分配部门的人员!");
|
return;
|
}
|
List<UserObject> objList = tablePanel.getSelectedRowObjects();
|
for(int i=0;i<objList.size();i++){
|
String name = LogonApplication.getUserEntityObject().getUserName();
|
String userName = objList.get(i).getUserName();
|
if(name.equals(userName)){
|
VCIOptionPane.showMessage(this,
|
"不可以给自己分配部门");
|
return;
|
}
|
}
|
new DeptingTreeDialog(this, objList);
|
}
|
private void setPasswordStrategyButton_actionPerformed(){
|
int len = tablePanel.getSelectedRowIndexs().length;
|
if(len == 0){
|
VCIOptionPane.showMessage(this,
|
"请先选择人员再进行操作");
|
return;
|
}
|
List<UserObject> objList = tablePanel.getSelectedRowObjects();
|
new PasswordStrategySetingDialog(this,objList);
|
}
|
|
private void stopButton_actionPerformed(){
|
int len = tablePanel.getSelectedRowIndexs().length;
|
if(len == 0){
|
VCIOptionPane.showMessage(this,
|
"请选择要进行停用操作的人员!");
|
return;
|
}
|
List<UserObject> objList = tablePanel.getSelectedRowObjects();
|
for(int i=0;i<objList.size();i++){
|
String name = LogonApplication.getUserEntityObject().getUserName();
|
String userName = objList.get(i).getUserName();
|
if(name.equals(userName)){
|
VCIOptionPane.showMessage(this,
|
"不可以停用自己!");
|
return;
|
}
|
}
|
int ask = VCIOptionPane.showQuestion(this,
|
"一经停用,该人员无法继续使用本系统,确定要对其停用?");
|
if(ask == 1) return;
|
|
String[] puids = new String[len];
|
for (int i = 0; i < len; i++) {
|
UserObject obj = tablePanel.getSelectedRowObjects().get(i);
|
puids[i] = obj.getId();
|
}
|
boolean rs=true;
|
try {
|
rs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).stopUsers(puids,true);
|
} catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e);
|
return;
|
}
|
if (!rs) {
|
return;
|
}
|
tablePanel.refreshTableData();
|
}
|
private void startButton_actionPerformed(){
|
int len = tablePanel.getSelectedRowIndexs().length;
|
if(len == 0){
|
VCIOptionPane.showMessage(this,
|
"请选择要进行启用操作的人员!");
|
return;
|
}
|
int ask = VCIOptionPane.showQuestion(this,
|
"一经起用,该人员可以继续使用本系统,确定要对其启用?");
|
if(ask == 1) return;
|
|
String[] puids = new String[len];
|
for (int i = 0; i < len; i++) {
|
UserObject obj = tablePanel.getSelectedRowObjects().get(i);
|
puids[i] = obj.getId();
|
}
|
boolean rs=true;
|
try {
|
rs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).stopUsers(puids,false);
|
} catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e);
|
return;
|
}
|
if (!rs) {
|
return;
|
}
|
tablePanel.refreshTableData();
|
}
|
public void deblockButton_actionPerformed(){
|
|
int len = tablePanel.getSelectedRowIndexs().length;
|
if(len == 0){
|
VCIOptionPane.showMessage(this,
|
"请选择要进行解锁操作的人员!");
|
return;
|
}
|
String[] puids = new String[len];
|
for (int i = 0; i < len; i++) {
|
UserObject obj = tablePanel.getSelectedRowObjects().get(i);
|
puids[i] = obj.getId();
|
}
|
try {
|
new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).deblock(puids);
|
} catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework",e);
|
return;
|
}
|
VCIOptionPane.showMessageDialog(LogonApplication.frame, "解锁成功!");
|
tablePanel.refreshTableData();
|
}
|
public void importButton_actionPerformed(){
|
UsersImportDialog eid = new UsersImportDialog(this);
|
eid.init();
|
eid.setSize(UIHelper.DIALOG_DEFAULT_WIDTH, UIHelper.DIALOG_DEFAULT_HEIGHT);
|
eid.setLocationRelativeTo(ClientContextVariable.getFrame());
|
eid.setVisible(true);
|
}
|
/**
|
* 获取姓名
|
* @return
|
*/
|
public String gettrueNameText(){
|
return trueNameText.getText().trim();
|
}
|
|
/**
|
* 获取用户名
|
* @return
|
*/
|
public String getUserNameText(){
|
return userNameText.getText().trim();
|
}
|
|
/**
|
* 获取角色id
|
* @return
|
*/
|
public String getRoleId(){
|
String roleId = ((RoleObject)roleComBox.getSelectedItem()).getId() == null ?
|
"" : ((RoleObject)roleComBox.getSelectedItem()).getId();
|
return roleId;
|
}
|
|
/**
|
*
|
* <p>Description: 获取部门ID</p>
|
*
|
* @author wangxl
|
* @time 2012-5-14
|
* @return
|
*/
|
public String getDeptId(){
|
String deptId = "";
|
if ((DeptObject)departmentComBox.getSelectedItem() != null && ((DeptObject)departmentComBox.getSelectedItem()).getId() != null ){
|
deptId = ((DeptObject)departmentComBox.getSelectedItem()).getId();
|
}
|
return deptId;
|
}
|
|
public class searchInfoClass {
|
private String name = "";
|
private String userName = "";
|
private String roleId = "";
|
private String deptId = "";
|
|
public String getName() {
|
return name;
|
}
|
public void setName(String name) {
|
this.name = name;
|
}
|
public String getUserName() {
|
return userName;
|
}
|
public void setUserName(String userName) {
|
this.userName = userName;
|
}
|
public String getRoleId() {
|
return roleId;
|
}
|
public void setRoleId(String roleId) {
|
this.roleId = roleId;
|
}
|
public String getDeptId() {
|
return deptId;
|
}
|
public void setDeptId(String deptId) {
|
this.deptId = deptId;
|
}
|
|
}
|
|
@Override
|
public String getUserID() {
|
return logonUserId;
|
}
|
@Override
|
public String getRoleID() {
|
return logonRoleId;
|
}
|
@Override
|
public JPanel getModuleComponent() {
|
return this;
|
}
|
@Override
|
public String getModuleName() {
|
if (this.getFuncObj() != null && this.getFuncObj().getName() != null)
|
return this.getFuncObj().getName();
|
else if (moduleName != null && !moduleName.isEmpty())
|
return moduleName;
|
else
|
return this.getClass().getName();
|
}
|
@Override
|
public String getIconName() {
|
return iconName;
|
}
|
@Override
|
public String getModuleShowInfo() {
|
return moduleShowInfo;
|
}
|
}
|