package com.vci.client.omd.attribpool.toOutside;
|
|
import java.awt.Dimension;
|
import java.util.ArrayList;
|
|
import javax.swing.JCheckBox;
|
import javax.swing.table.JTableHeader;
|
import javax.swing.table.TableColumn;
|
|
import org.jdesktop.swingx.JXTable;
|
import org.jdesktop.swingx.decorator.HighlighterFactory;
|
|
import com.vci.client.omd.attribpool.ui.APClient;
|
import com.vci.client.ui.table.CheckBoxEditor;
|
import com.vci.client.ui.table.CheckBoxRenderer;
|
import com.vci.client.common.ClientLog4j;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.omd.atm.AttribItem;
|
|
public class ApSelectTableForBtm extends JXTable{
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = -6470680235636503508L;
|
|
private ArrayList<String> apNameList = null;
|
private AttribItem[] abItemArray = null;
|
private final int TABLE_HEADER_HEIGHT = 25;
|
private final int ROW_HEIGHT = 30;
|
private ApSelectTableModelForBtm model = null;
|
|
|
|
public ApSelectTableForBtm(ArrayList<String> apNameList){
|
this.apNameList = apNameList;
|
this.setHorizontalScrollEnabled(true);
|
this.setAutoscrolls(true);
|
this.setSortable(false);
|
this.setHighlighters(HighlighterFactory.createAlternateStriping());
|
this.setRowHeight(ROW_HEIGHT);
|
model = new ApSelectTableModelForBtm();
|
this.setModel(model);
|
TableColumn column = this.getColumn(0);
|
column.setCellEditor(new CheckBoxEditor(new JCheckBox()));
|
column.setCellRenderer(new CheckBoxRenderer());
|
//设置表头高度
|
JTableHeader tableHeader = this.getTableHeader();
|
Dimension size = tableHeader.getPreferredSize();
|
size.height = TABLE_HEADER_HEIGHT;
|
tableHeader.setPreferredSize(size);
|
initApTable();
|
}
|
|
public void initApTable(){
|
AttribItem abItem;
|
try {
|
|
abItemArray = APClient.getService().getAttribItemsOutNames(
|
apNameList.toArray(new String[0]),"");
|
} catch (VCIError e) {
|
//e.printStackTrace();
|
ClientLog4j.logger.error(e);
|
}
|
// 重新设置table的Cell的可编辑性
|
model.setInitFlag(false);
|
model.setRowCount(abItemArray.length);
|
for (int i = 0; i < abItemArray.length; i++) {
|
abItem = abItemArray[i];
|
this.setValueAt(new JCheckBox(), i, 0);
|
this.setValueAt(abItem.name, i, 1);
|
this.setValueAt(abItem.vtDataType, i, 2);
|
this.setValueAt(abItem.defValue, i, 3);
|
this.setValueAt(abItem.description, i, 4);
|
}
|
// 重新设置table的Cell的可编辑性
|
model.setInitFlag(true);
|
}
|
//add by caill start
|
//添加方法实现模糊查询
|
public void initApTable2(String textValue){
|
String text;
|
AttribItem abItem;
|
try {
|
text = textValue;
|
abItemArray = APClient.getService().getAttribItemsOutNames(
|
apNameList.toArray(new String[0]),text);
|
model.setRowCount(abItemArray.length);
|
//重新设置table的Cell的可编辑性
|
model.setInitFlag(false);
|
for(int i = 0; i < abItemArray.length; i++){
|
abItem = abItemArray[i];
|
this.setValueAt(new JCheckBox(), i, 0);
|
this.setValueAt(abItem.name, i, 1);
|
this.setValueAt(abItem.vtDataType, i, 2);
|
this.setValueAt(abItem.defValue, i, 3);
|
this.setValueAt(abItem.description, i, 4);
|
}
|
//重新设置table的Cell的可编辑性
|
model.setInitFlag(true);
|
|
} catch (VCIError e) {
|
//e.printStackTrace();
|
ClientLog4j.logger.error(e);
|
}
|
}
|
//add by caill end
|
}
|