package com.vci.client.framework.specialrole;
|
|
import java.awt.BorderLayout;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
|
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.DeptObject;
|
import com.vci.client.common.objects.UserObject;
|
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.VCIOptionPane;
|
|
/**
|
* <p>Title: DeptingDialog</p>
|
* <p>Description:为人员分配部门 </p>
|
* <p>Copyright: Copyright (c) 2012</p>
|
* <p>Company: VCI</p>
|
* @author wangxl
|
* @time 2012-5-13
|
* @version 1.0
|
*/
|
public class DeptingDialog extends BaseJDialog{
|
|
private static final long serialVersionUID = 1L;
|
private JLabel deptLabel = new JLabel();
|
private JComboBox departmentComBox = 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 UserObject userObj;
|
|
public DeptingDialog(UserTablePanel userPanel ,UserObject userObj){
|
super(LogonApplication.frame);
|
this.userObj = userObj;
|
this.userPanel = userPanel;
|
this.setModal(true);
|
init();
|
}
|
|
|
/**
|
* 初始化界面
|
*/
|
private void init() {
|
JLabel titleLabel = new JLabel();
|
titleLabel.setText("分配部门");
|
titleLabel.setIcon(new BundleImage().createImageIcon ("book.png"));
|
JPanel bottomPanel = new JPanel();
|
bottomPanel.add(conformBut);
|
bottomPanel.add(cancelBut);
|
|
JPanel contentPanel = initCenterContentPanel();
|
// initRole(); //初始化角色信息
|
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);
|
initDialogSize(610, 550);
|
this.setVisible(true);
|
}
|
|
private JPanel initCenterContentPanel() {
|
JPanel contentPanel = new JPanel();
|
contentPanel.setLayout(null);
|
|
deptLabel.setText("所属部门:");
|
deptLabel.setBounds(60, 30, 60, 25);
|
|
departmentComBox.setBounds(130, 30, 150, 25);
|
initDepartment();
|
|
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(deptLabel);
|
contentPanel.add(departmentComBox);
|
return contentPanel;
|
|
}
|
|
private void addButton_actionPerformed() {
|
String deptId = "";
|
if (departmentComBox.getSelectedItem() instanceof DeptObject){
|
deptId = ((DeptObject)departmentComBox.getSelectedItem()).getId() == null ? "" : ((DeptObject)departmentComBox.getSelectedItem()).getId() ;
|
}
|
try{
|
new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
|
.saveUserDept(new String[]{userObj.getId()},deptId);
|
|
}catch(VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework",e);
|
return ;
|
}
|
userPanel.tablePanel.refreshTableData();
|
this.dispose();
|
}
|
|
public void cancelCreate(){
|
this.dispose();
|
}
|
|
/**
|
* 初始化部门
|
*
|
*/
|
private void initDepartment() {
|
try {
|
departmentComBox.addItem(new DeptObject());
|
DeptObject[] departmentInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchDepartmentInfo();
|
int size = departmentInfo.length;
|
for (int i = 0; i < size; i++) {
|
departmentComBox.addItem(departmentInfo[i]);
|
}
|
DeptObject userDeptObj = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
|
.fetchDeptByUserId(userObj.getId());
|
if (userDeptObj != null){
|
int count = departmentComBox.getItemCount();
|
for (int i = 0 ; i < count ; i++){
|
DeptObject deptObj = (DeptObject)departmentComBox.getItemAt(i);
|
if (userDeptObj.getId().equals(deptObj.getId())){
|
departmentComBox.setSelectedIndex(i);
|
break;
|
}
|
}
|
}
|
} catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
|
return ;
|
}
|
|
}
|
|
}
|