package com.vci.client.framework.systemConfig.stafforgmanage;
|
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.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.RightManagementClientDelegate;
|
import com.vci.client.framework.rightConfig.object.FunctionObject;
|
import com.vci.client.framework.systemConfig.SysConfigTableModel;
|
import com.vci.client.framework.systemConfig.object.CombinationObject;
|
import com.vci.client.framework.systemConfig.object.CombinationValueObject;
|
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;
|
/**
|
* 组合方式取值范围
|
* <p>Title: </p>
|
* <p>Description: </p>
|
* <p>Copyright: Copyright (c) 2012</p>
|
* <p>Company: VCI</p>
|
* @author wangxl
|
* @time 2013-1-3
|
* @version 1.0
|
*/
|
public class CombinationValueTablePanel extends VCIBasePanel{
|
//值
|
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 combValTableModel; //表格的tableModel
|
private JTable combValTable; //表格的table
|
private KTextField valueText = new KTextField() ;
|
private TransmitTreeObject transmitTreeObject;
|
private CombinationValueObject combinationValueObject = null; //选中的字符
|
public CombinationObject combObject = 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 CombinationValueTablePanel(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);
|
}
|
|
/**
|
* 加载组合方式取值范围
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-1-3
|
* @return
|
*/
|
private JPanel initSpecialCharacter() {
|
|
JPanel bottomPanel = new JPanel();
|
bottomPanel.add(addButton);
|
bottomPanel.add(editButton);
|
bottomPanel.add(deleteButton);
|
|
combValTableModel=new SysConfigTableModel(classes);
|
VCIBaseTableNode specialCharacterTableNode=new VCIBaseTableNode(null);
|
combValTableModel.addRow(1, specialCharacterTableNode);
|
combValTable=new JTable(combValTableModel);
|
combValTable.setRowHeight(25);
|
combValTable.addMouseListener(new java.awt.event.MouseAdapter() {
|
public void mouseClicked(java.awt.event.MouseEvent e) {
|
initContent();
|
}
|
});
|
/**
|
* 修改界面初始加载密码组合方式取值范围
|
*/
|
if (this.classComBox.getItemCount() == 0){
|
initTableProperty("");
|
}else {
|
CombinationObject obj = (CombinationObject)classComBox.getItemAt(0);
|
initTableProperty(obj.getId());
|
}
|
|
combValTable.setColumnSelectionAllowed(true);
|
combValTable.setCellSelectionEnabled(false);
|
JScrollPane js=new JScrollPane(combValTable);
|
|
|
//创建值输入框
|
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("组合方式取值范围"));
|
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(78, 10, 200, 25);
|
searchPal.add(classLabel);
|
searchPal.add(classComBox);
|
|
palTable.add(searchPal,BorderLayout.NORTH);
|
palTable.add(initSpecialCharacter(), BorderLayout.CENTER);
|
|
|
return palTable;
|
}
|
/**
|
* 获取密码组合方式,填充下拉列表
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-1-3
|
*/
|
public void initCharacterClassCombox(){
|
try {
|
CombinationObject[] objs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchAllCombinations();
|
int size = objs.length;
|
for (int i = 0; i < size; i++) {
|
classComBox.addItem(objs[i]);
|
}
|
} catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
|
return ;
|
}
|
|
}
|
|
/**
|
* 通过选中的密码组合方式的id获取组合方式取值范围
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-1-3
|
* @param id
|
*/
|
public void initTableProperty(String id){
|
try {
|
combValTableModel.list.clear();
|
valueText.setText("");
|
CombinationValueObject[] combValueObjs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
|
.fetchCombinationValuesByParentId(id);//objs是由id取到的取值
|
int length=combValueObjs.length;
|
int rowLength = length/12;
|
if (length%12 != 0) {
|
rowLength += 1;
|
}
|
for (int i = 0; i < rowLength; i++) {
|
VCIBaseTableNode combValueTableNode = new VCIBaseTableNode(null);
|
for(int column = 0; column < 12;column++){
|
if (i*12 + column < length){
|
CombinationValueObject combValObject= combValueObjs[i*12 + column];
|
String name=String.valueOf(column+1);
|
combValueTableNode.setPropertyValueByName(name, combValObject);
|
}
|
}
|
combValTableModel.addRow(i + 1 , combValueTableNode);
|
}
|
combValTable.setModel(combValTableModel);
|
combValTableModel.fireTableDataChanged();
|
} catch (VCIException e) {
|
VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
|
}
|
}
|
|
|
/**
|
* 填充控件值
|
* <p>Description: </p>
|
*
|
* @author wangxl
|
* @time 2013-1-3
|
*/
|
public void initContent(){
|
int rowIndex = combValTable.getSelectedRow();
|
int columnIndex = combValTable.getSelectedColumn();
|
Object combValObj = combValTableModel.getValueAt(rowIndex, columnIndex);
|
if(combValObj instanceof CombinationValueObject){
|
combinationValueObject = (CombinationValueObject)combValObj;
|
valueText.setText(combinationValueObject.getValue());
|
} else {
|
combinationValueObject = null;
|
valueText.setText("");
|
}
|
}
|
|
|
/**
|
* 分类下拉框触发事件
|
* <p>Description: </p>
|
*
|
* @author llb
|
* @time 2013-1-3
|
*/
|
public void initAction(){
|
classComBox.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
classCombox_conform();
|
|
}
|
});
|
classCombox_conform();
|
addButton.addActionListener(new CombinationValueActionListener(this,"add"));
|
editButton.addActionListener(new CombinationValueActionListener(this,"modify"));
|
deleteButton.addActionListener(new CombinationValueActionListener(this,"delete"));
|
}
|
|
private void classCombox_conform(){
|
String id = "";
|
int select = classComBox.getSelectedIndex();
|
if(select>=0){
|
CombinationObject obj = (CombinationObject)classComBox.getSelectedItem();
|
combObject = obj;
|
id = obj.getId();
|
}
|
initTableProperty(id);//用户在下拉框取到的id,刷新table
|
}
|
|
private void decreaseSelRows(int start, Integer[] selRows){
|
for(int i = start + 1; i < selRows.length; i++){
|
selRows[i] = selRows[i] - 1;
|
}
|
}
|
|
public CombinationValueObject getCombinationValueObject() {
|
return combinationValueObject;
|
}
|
public CombinationObject getCombinationObject() {
|
return combObject;
|
}
|
public TransmitTreeObject getTransmitTreeObject() {
|
return transmitTreeObject;
|
}
|
public void setValueText(String value) {
|
valueText.setText(value);
|
}
|
|
public VCIJComboBox getClassComBox(){
|
return classComBox;
|
}
|
public String getValueText() {
|
return valueText.getText().trim();
|
}
|
|
}
|