package com.vci.client.framework.systemConfig.specialCharacter; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.LinkedHashMap; import java.util.LinkedList; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.border.TitledBorder; import com.vci.client.LogonApplication; import com.vci.client.common.VCIBasePanel; import com.vci.client.framework.delegate.SystemCfgClientDelegate; import com.vci.client.framework.rightConfig.object.FunctionObject; import com.vci.client.framework.systemConfig.object.SpecialCharClsfObject; 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.KTextField; 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; public class SpecialCharacterClassificationPanel extends VCIBasePanel{ /****************************国际化信息**********************************/ private String DELETE = LocaleDisplay.getI18nString("rmip.framework.sysconfig.delete", "RMIPFramework",getLocale()); 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 SPECIALCHARCLSF = LocaleDisplay.getI18nString("rmip.framework.sysconfig.specialCharClsf", "RMIPFramework",getLocale()); /** * 特殊字符分类的Panel */ private static final long serialVersionUID = 1L; private KTextField nameField; //名称 private JTextArea descriptionArea;//描述 public SpecialCharClsfObject clsfObj = null; private LinkedList selfCustomButtons = new LinkedList(); { selfCustomButtons.add(addButton); selfCustomButtons.add(editButton); selfCustomButtons.add(deleteButton); } public SpecialCharacterClassificationPanel(FunctionObject funcObj) { super(funcObj); init(); checkPermission(); } public void init() { this.setLayout(new BorderLayout()); JPanel tablePanel = initTablePanel(); this.add(tablePanel,BorderLayout.CENTER); initAction(); } private void checkPermission(){ checkRight(RightControlUtil.CREATE, addButton); checkRight(RightControlUtil.UPDATE, editButton); checkRight(RightControlUtil.DELETE, deleteButton); } /** * 初始化table的Panle * @return */ private JPanel initTablePanel(){ JPanel palTable = new JPanel(); palTable.setLayout(new BorderLayout()); palTable.setBorder(new TitledBorder(SPECIALCHARCLSF)); palTable.add(tablePanel(), BorderLayout.CENTER); return palTable; } class MyDataProvider extends AbstractVCIJTableDataProvider { @Override public SpecialCharClsfObject[] getDatas(int pageNo, int pageSize) { SpecialCharClsfObject[] Objects = null; try { Objects = new SystemCfgClientDelegate(LogonApplication.getUserEntityObject()) .getSpecialCharClsfList(pageNo,pageSize); } catch (VCIException e) { VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e); return null; } return Objects; } @Override public VCIJTableNode getNewRowNode(SpecialCharClsfObject dataObj) { VCIJTableNode node = new VCIJTableNode( dataObj); node.setPropertyValue(getSpecialColumns()[0], dataObj.getName()); node.setPropertyValue(getSpecialColumns()[1], dataObj.getDesc()); return node; } @Override public String[] getSpecialColumns() { return "名称,描述".split(","); } @Override public int getTotal() { try { total = new SystemCfgClientDelegate(LogonApplication.getUserEntityObject()).getSpecialCharClsTotal(); } catch (VCIException e) { e.printStackTrace(); VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e); } return this.total; } } MyDataProvider dataProvider = new MyDataProvider(); VCIJTablePanel tablePanel = new VCIJTablePanel(dataProvider); private VCIJPanel tablePanel() { int startIndex = dataProvider.getDataColumnStartIndex(); LinkedHashMap widthMaps = new LinkedHashMap(); widthMaps.put(startIndex++, 300); widthMaps.put(startIndex++, 300); tablePanel.setColumnWidthMaps(widthMaps); tablePanel.setShowPaging(true); tablePanel.setCustomButtons(selfCustomButtons); tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER); tablePanel.setPageButtonFlowAlign(FlowLayout.CENTER); tablePanel.buildTablePanel(); tablePanel.refreshTableData(); return tablePanel; } /** * *

Description:初始化特殊字符分类按钮

* * @author sunbo * @time 2012-5-25 */ public void initAction(){ // 添加分类 addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addClassButton_conform(); } }); editButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editClassButton_conform(); } }); deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteClassButton_conform(); } }); } /** * 添加特殊字符分类 */ private void addClassButton_conform(){ new SpecialCharacterDialog("add",null); tablePanel.refreshTableData(); } /** * 修改特殊字符分类 */ private void editClassButton_conform(){ int len = tablePanel.getSelectedRowIndexs().length; if(len == 0){ VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.stafforg.operate.deptedit1", "RMIPFramework", getLocale())); return; } if (len > 1){ VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.stafforg.operate.deptedit2", "RMIPFramework", getLocale())); return; } SpecialCharClsfObject clsObj = tablePanel.getSelectedRowObjects().get(0); new SpecialCharacterDialog("modify",clsObj); tablePanel.refreshTableData(); } /** * *

Description: 删除分类

* * @author sunbo * @time 2012-5-28 */ private void deleteClassButton_conform() { int len = tablePanel.getSelectedRowIndexs().length; if(len == 0){ VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.stafforg.operate.deptdelete1", "RMIPFramework", getLocale())); return; } String[] puids = new String[len]; for (int i = 0; i < len; i++) { SpecialCharClsfObject obj = tablePanel.getSelectedRowObjects().get(i); puids[i] = obj.getId(); } int ok=VCIOptionPane.showQuestion(LogonApplication.frame,"您确定要删除选中的特殊字符分类吗?(删除分类将同时删除分类下特殊字符)"); if (ok == 0) { boolean rs=true; try { rs = new SystemCfgClientDelegate(LogonApplication.getUserEntityObject()).deletSpecialCharClsf(puids); } catch (VCIException e) { VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework",e); return; } if (!rs) { return; } } tablePanel.refreshTableData(); } private void decreaseSelRows(int start, Integer[] selRows){ for(int i = start + 1; i < selRows.length; i++){ selRows[i] = selRows[i] - 1; } } public String getDescriptionArea() { return descriptionArea.getText().trim(); } public String getNameFieldText() { return nameField.getText().trim(); } }