package com.vci.client.framework.systemConfig.stafforgmanage; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.Map; import javax.swing.JPanel; import javax.swing.border.TitledBorder; import com.vci.client.LogonApplication; import com.vci.client.common.VCIBasePanel; import com.vci.client.framework.delegate.RightManagementClientDelegate; import com.vci.client.framework.rightConfig.object.FunctionObject; import com.vci.client.framework.systemConfig.object.CombinationObject; import com.vci.client.framework.util.RightControlUtil; import com.vci.client.logon.client.LogonFrame; import com.vci.client.ui.exception.VCIException; import com.vci.client.ui.locale.LocaleDisplay; 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; /** * 密码组合方式管理界面 *

Title:

*

Description:

*

Copyright: Copyright (c) 2012

*

Company: VCI

* @author wangxl * @time 2013-1-3 * @version 1.0 */ public class CombinationTablePanel extends VCIBasePanel { private static final long serialVersionUID = 1L; 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 String userName = LogonApplication.getUserEntityObject().getUserName(); private LinkedList selfCustomButtons = new LinkedList(); { selfCustomButtons.add(addButton); selfCustomButtons.add(editButton); selfCustomButtons.add(deleteButton); } public CombinationTablePanel(FunctionObject funcObj){ super(funcObj); init(); checkPermission(); } private void init() { LogonApplication.getUserEntityObject().setModules(this.getClass().getName()); initComponents(); initAction();//初始化按钮点击事件 } private void initComponents() { setLayout(new BorderLayout()); add(initTablePanel(), BorderLayout.CENTER); } private void checkPermission(){ checkRight(RightControlUtil.CREATE, addButton); checkRight(RightControlUtil.UPDATE, editButton); checkRight(RightControlUtil.DELETE, deleteButton); } class MyDataProvider extends AbstractVCIJTableDataProvider{ @Override public CombinationObject[] getDatas(int pageIndex, int pageSize) { CombinationObject[] combinationObjs = null; try { combinationObjs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()) .fetchCombinationsToPage(pageIndex,pageSize); } catch (VCIException e) { VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e); return null; } return combinationObjs; } @Override public VCIJTableNode getNewRowNode(CombinationObject dataObj) { VCIJTableNode node = new VCIJTableNode(dataObj); node.setPropertyValue(getSpecialColumns()[0], dataObj.getName()); node.setPropertyValue(getSpecialColumns()[1], dataObj.getDescription()); return node; } @Override public String[] getSpecialColumns() { return "名称, 描述".split(","); } @Override public int getTotal() { int num = 0 ; CombinationObject[] combinationObjs = null; try { combinationObjs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()) .fetchAllCombinations(); } catch (VCIException e) { VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e); return 0; } if(combinationObjs !=null){ num = combinationObjs.length; } return num; } } MyDataProvider dataProvider = new MyDataProvider(); VCIJTablePanel tablePanel = new VCIJTablePanel(dataProvider); private VCIJPanel tablePanel(){ int startIndex = dataProvider.getDataColumnStartIndex(); LinkedHashMap widthMaps = new LinkedHashMap(); widthMaps.put(startIndex++, 250);widthMaps.put(startIndex++, 250);widthMaps.put(startIndex++, 250); tablePanel.setColumnWidthMaps(widthMaps); tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER); tablePanel.setCustomButtons(selfCustomButtons); tablePanel.setShowPaging(true); 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("密码组合方式")); pal.add(tablePanel(), BorderLayout.CENTER); pal.setVisible(true); return pal; } /** * 事件 */ private void initAction(){ 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_conform(); } }); } /** * 添加事件 */ private void addButton_conform(){ new CombinationDialog(this,"addCombination"); } /** * 修改事件 */ 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.deptedit2", "RMIPFramework", getLocale())); return; } CombinationObject obj = tablePanel.getSelectedRowObjects().get(0); new CombinationDialog (this,obj,"editCombination"); } /** * 删除事件 */ private void deleteButton_conform(){ int len = tablePanel.getSelectedRowIndexs().length; if(len == 0){ VCIOptionPane.showMessage(this, "请选择要删除的对象!"); return; } String[] puids = new String[len]; Map map = new HashMap(); for (int i = 0; i < len; i++) { CombinationObject combinationInfo = tablePanel.getSelectedRowObjects().get(i); puids[i] = combinationInfo.getId(); map.put(combinationInfo.getId(), combinationInfo.getName()); } /** * 删除前,检验密码组合方式是否被密码策略引用,若被引用,不能进行删除。 */ RightManagementClientDelegate del = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()); for(int k=0;k 0) { VCIOptionPane.showMessageDialog(LogonApplication.frame, "组合方式:"+map.get(puids[k]) +"已经被引用,不能对其进行删除操作!"); return; } } catch (VCIException e) { e.printStackTrace(); VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e); return ; } } int ok=VCIOptionPane.showQuestion(LogonApplication.frame, LocaleDisplay.getI18nString("rmip.stafforg.operate.pwdgroupdelete", "RMIPFramework", getLocale())); if (ok == 0) { boolean rs=true; try { rs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).deleteCombination(puids); } catch (VCIException e) { VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e); return ; } if (!rs) { return; } }else{ return; } tablePanel.refreshTableData(); } }