package com.vci.client.framework.systemConfig.specialCharacter; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextArea; 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.framework.delegate.SystemCfgClientDelegate; import com.vci.client.framework.rightConfig.object.FunctionObject; import com.vci.client.framework.systemConfig.SysConfigTableModel; import com.vci.client.framework.systemConfig.object.SpecialCharClsfObject; import com.vci.client.framework.systemConfig.object.SpecialCharObject; 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.VCIJComboBox; import com.vci.client.ui.swing.components.VCIJLabel; import com.vci.client.ui.table.VCIBaseTableNode; import com.vci.corba.common.VCIError; //特殊字符Panel public class SpecialCharacterPanel extends VCIBasePanel{ /****************************国际化信息**********************************/ //特殊字符 private String SPECIALCHAR = LocaleDisplay.getI18nString("rmip.framework.sysconfig.specialChar", "RMIPFramework",getLocale()); //值 private String VALUE = LocaleDisplay.getI18nString("rmip.framework.sysconfig.value", "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 VCIJLabel classLabel = new VCIJLabel("分类:"); private VCIJComboBox classComBox = new VCIJComboBox(); private static final long serialVersionUID = 1L; private SysConfigTableModel specialCharacterTableModel; //表格的tableModel private JTable specialCharacterTable; //表格的table private KTextField nameField; //名称 private JTextArea descriptionArea;//描述 private KTextField valueText = new KTextField() ; private TransmitTreeObject transmitTreeObject; private SpecialCharObject specialCharObject = null; //选中的字符 public SpecialCharClsfObject clsfObj = null; private Class[] classes = { String.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class}; public SpecialCharacterPanel(FunctionObject funcObj) { super(funcObj); init(); checkPermission(); } public void init() { setLayout(new BorderLayout()); JPanel rightPanel = initTablePanel(); this.add(rightPanel, BorderLayout.CENTER); initAction(); } private void checkPermission(){ checkRight(RightControlUtil.CREATE, addButton); checkRight(RightControlUtil.UPDATE, editButton); checkRight(RightControlUtil.DELETE, deleteButton); } /** * *
Description: 加载特殊字符
* * @author sunbo * @time 2012-5-25 */ private JPanel initSpecialCharacter() { JPanel bottomPanel = new JPanel(); bottomPanel.add(addButton); bottomPanel.add(editButton); bottomPanel.add(deleteButton); //创建特殊字符table specialCharacterTableModel=new SysConfigTableModel(classes); VCIBaseTableNode specialCharacterTableNode=new VCIBaseTableNode(null); specialCharacterTableModel.addRow(1, specialCharacterTableNode); specialCharacterTable=new JTable(specialCharacterTableModel); specialCharacterTable.setRowHeight(25); specialCharacterTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { initContent(); } }); initTableProperty(""); specialCharacterTable.setColumnSelectionAllowed(true); JScrollPane js=new JScrollPane(specialCharacterTable); //创建值输入框 JPanel centerBottomCPanel = new JPanel(); centerBottomCPanel.setLayout(null); JLabel valueLabel = new JLabel(VALUE); valueLabel.setBounds(20, 10, 80, 25); valueText.setBounds(50, 10, 200, 25); centerBottomCPanel.add(valueLabel); centerBottomCPanel.add(valueText); centerBottomCPanel.setPreferredSize(new Dimension(400, 70)); JPanel palTable = new JPanel(new BorderLayout()); palTable.add(js, BorderLayout.CENTER); palTable.add(centerBottomCPanel,BorderLayout.SOUTH); JPanel centerPanel = new JPanel(); centerPanel.setLayout(new BorderLayout()); centerPanel.add(palTable, BorderLayout.CENTER); centerPanel.add(bottomPanel,BorderLayout.SOUTH); return centerPanel; } /** * 初始化table的Panle * @return */ private JPanel initTablePanel(){ JPanel palTable = new JPanel(); palTable.setBorder(new TitledBorder(SPECIALCHAR)); palTable.setLayout(new BorderLayout()); //初始化特殊字符分类下拉框 initCharacterClassCombox(); //分类下拉框 JPanel searchPal = new JPanel(); searchPal.setLayout(null); searchPal.setPreferredSize(new Dimension(300,40)); classLabel.setBounds(20, 10, 80, 25); classComBox.setBounds(60, 10, 200, 25); searchPal.add(classLabel); searchPal.add(classComBox); palTable.add(searchPal,BorderLayout.NORTH); palTable.add(initSpecialCharacter(), BorderLayout.CENTER); classCombox_conform(); return palTable; } public void initCharacterClassCombox(){ try { //classComBox.addItem(""); SpecialCharClsfObject[] Objects = new SystemCfgClientDelegate(LogonApplication.getUserEntityObject()).getSpecialCharClsfList(); int size = Objects.length; for (int i = 0; i < size; i++) { classComBox.addItem(Objects[i]); } } catch (VCIException e) { VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e); return ; } } /** * 通过下拉款的分类ID加载分类下面的特殊字符 *Description:
* * @author llb * @time 2013-1-3 * @param id */ public void initTableProperty(String id){ try { specialCharacterTableModel.list.clear(); valueText.setText(""); SpecialCharObject[] specialCharInfos = new SystemCfgClientDelegate(LogonApplication.getUserEntityObject()).fetchSpecialChar(id); int length=specialCharInfos.length; int rowLength = length/12; if (length%12 != 0) { rowLength += 1; } for (int i = 0; i < rowLength; i++) { VCIBaseTableNode specialCharacterTableNode = new VCIBaseTableNode(null); for(int column = 0; column < 12;column++){ if (i*12 + column < length){ SpecialCharObject specialCharObject= specialCharInfos[i*12 + column]; String name=String.valueOf(column+1); specialCharacterTableNode.setPropertyValueByName(name, specialCharObject); } } specialCharacterTableModel.addRow(i + 1 , specialCharacterTableNode); } specialCharacterTable.setModel(specialCharacterTableModel); specialCharacterTableModel.fireTableDataChanged(); } catch (VCIError e) { VCIOptionPane.showError(LogonApplication.frame, LocaleDisplay.getI18nString(String.valueOf(e.code), "RMIPFramework", getLocale())); } } /** * 点击表单里面的任何一个特殊字符数据,并在下面的值输入框显示信息,进而进行修改删除操作 *Description:
* * @author llb * @time 2013-1-3 */ public void initContent(){ int rowIndex = specialCharacterTable.getSelectedRow(); int columnIndex = specialCharacterTable.getSelectedColumn(); Object selectCharObj = specialCharacterTableModel.getValueAt(rowIndex, columnIndex); if(selectCharObj instanceof SpecialCharObject){ specialCharObject = (SpecialCharObject)selectCharObj; valueText.setText(specialCharObject.getValue()); } else { specialCharObject = null; valueText.setText(""); } } /** * 分类下拉框触发事件 *Description:
* * @author llb * @time 2013-1-3 */ public void initAction(){ classComBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub classCombox_conform(); } }); addButton.addActionListener(new SpecialCharacterActionListener(this,"add")); editButton.addActionListener(new SpecialCharacterActionListener(this,"modify")); deleteButton.addActionListener(new SpecialCharacterActionListener(this,"delete")); } private void classCombox_conform(){ String id = ""; Object select = classComBox.getSelectedItem(); if(select != null){ SpecialCharClsfObject obj = (SpecialCharClsfObject)classComBox.getSelectedItem(); clsfObj = obj; id = obj.getId(); } initTableProperty(id); } private void decreaseSelRows(int start, Integer[] selRows){ for(int i = start + 1; i < selRows.length; i++){ selRows[i] = selRows[i] - 1; } } public SpecialCharObject getSpecialCharObject() { return specialCharObject; } public SpecialCharClsfObject getSpecialCharClsfObject() { return clsfObj; } public TransmitTreeObject getTransmitTreeObject() { return transmitTreeObject; } public void setValueText(String value) { valueText.setText(value); } public VCIJComboBox getClassComBox(){ return classComBox; } public String getDescriptionArea() { return descriptionArea.getText().trim(); } public String getNameFieldText() { return nameField.getText().trim(); } public String getValueText() { return valueText.getText().trim(); } }