package com.vci.client.uif.engine.client;
|
|
import java.awt.BorderLayout;
|
import java.awt.Component;
|
import java.awt.FlowLayout;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.util.LinkedHashMap;
|
import java.util.LinkedList;
|
|
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.framework.delegate.RightManagementClientDelegate;
|
import com.vci.client.ui.exception.VCIException;
|
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.VCIJDialog;
|
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.mw.ClientContextVariable;
|
|
public class SelectDeptDialog extends VCIJDialog{
|
private VCIJButton btnOk = VCISwingUtil.createVCIJButton("ok", "确定", "确定", "accept.png");
|
private VCIJButton btnCancel = VCISwingUtil.createVCIJButton("cancel", "取消", "取消", "cancel.png");
|
|
private DeptObject deptObj;
|
|
|
|
|
public DeptObject getDeptObj() {
|
return deptObj;
|
}
|
public void setDeptObj(DeptObject deptObj) {
|
this.deptObj = deptObj;
|
}
|
|
private UserEntityObject userEntityObj = null;
|
private Component parentComponent = null;
|
public SelectDeptDialog(Component parentComponent){
|
super(ClientContextVariable.getFrame(), true);
|
this.userEntityObj = new UserEntityObject(
|
ClientContextVariable.getInvocationInfo().userName,
|
ClientContextVariable.getInvocationInfo().clientIPInfo);
|
init();
|
setSize(UIHelper.DIALOG_DEFAULT_WIDTH, UIHelper.DIALOG_DEFAULT_HEIGHT);
|
this.parentComponent = parentComponent;
|
setLocationRelativeTo(parentComponent);
|
setVisible(true);
|
}
|
public void init(){
|
setLayout(new BorderLayout());
|
this.setTitle("选择部门");
|
add(tablePanel(), BorderLayout.CENTER);
|
initAction();//初始化按钮点击事件
|
}
|
|
private LinkedList<VCIJButton> selfCustomButtons = new LinkedList<VCIJButton>();
|
{
|
selfCustomButtons.add(btnOk);
|
selfCustomButtons.add(btnCancel);
|
}
|
|
MyDataProvider dataProvider = new MyDataProvider();
|
VCIJTablePanel<DeptObject> tablePanel = new VCIJTablePanel<DeptObject>(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);widthMaps.put(startIndex++, 250);
|
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;
|
}
|
|
|
class MyDataProvider extends AbstractVCIJTableDataProvider<DeptObject>{
|
DeptObject[] roleObjs = null;
|
@Override
|
public DeptObject[] getDatas(int arg0, int arg1) {
|
try {
|
roleObjs = new RightManagementClientDelegate(userEntityObj).fetchDepartmentInfo();
|
} catch (VCIException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
VCIOptionPane.showError(parentComponent,"RMIPFramework", e);
|
}
|
// TODO Auto-generated method stub
|
return roleObjs;
|
}
|
|
@Override
|
public VCIJTableNode<DeptObject> getNewRowNode(DeptObject dataObj) {
|
// TODO Auto-generated method stub
|
VCIJTableNode<DeptObject> node = new VCIJTableNode<DeptObject>(dataObj);
|
node.setPropertyValue(getSpecialColumns()[0], dataObj.getName());
|
node.setPropertyValue(getSpecialColumns()[1], dataObj.getNum());
|
node.setPropertyValue(getSpecialColumns()[1], dataObj.getDescription());
|
return node;
|
}
|
|
@Override
|
public String[] getSpecialColumns() {
|
// TODO Auto-generated method stub
|
return "名称,编号,描述".split(",");
|
}
|
|
@Override
|
public int getTotal() {
|
// TODO Auto-generated method stub
|
return roleObjs.length;
|
}
|
|
}
|
private void initAction(){
|
btnCancel.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
// TODO Auto-generated method stub
|
cancelButton_ActionPerformed(e);
|
}
|
});
|
btnOk.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
// TODO Auto-generated method stub
|
addButton_ActionPerformed();
|
}
|
});
|
}
|
/**
|
* 确认按钮事件
|
* <p>Description: </p>
|
* @author heyj
|
* @time 2014-3-25
|
*/
|
private void addButton_ActionPerformed(){
|
int len = tablePanel.getSelectedRowIndexs().length;
|
if(len == 0){
|
VCIOptionPane.showMessage(this, "请选择角色再进行操作!");
|
return;
|
}
|
if (len > 1){
|
VCIOptionPane.showMessage(this, "一次只能选择一个角色进行操作");
|
return;
|
}
|
DeptObject obj = tablePanel.getSelectedRowObjects().get(0);
|
this.setDeptObj(obj);
|
this.dispose();
|
}
|
/**
|
* 取消按钮事件
|
* @param e
|
*/
|
private void cancelButton_ActionPerformed(ActionEvent e) {
|
this.deptObj = null;
|
this.dispose();
|
}
|
}
|