package com.vci.client.omd.attribpool.toOutside; import java.awt.Dimension; import java.util.ArrayList; import javax.swing.table.JTableHeader; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.HighlighterFactory; import com.vci.client.omd.attribpool.ui.APClient; import com.vci.client.common.ClientLog4j; import com.vci.corba.common.VCIError; import com.vci.corba.omd.atm.AttribItem; public class ApTableForOut extends JXTable{ /** * */ private static final long serialVersionUID = -7697724659976326314L; private AttribItem[] abItemArray = null; private ArrayList apNameList; private final int TABLE_HEADER_HEIGHT = 25; private final int ROW_HEIGHT = 30; /** * 根据属性名字列表,获取属性列表 * @param apNameList */ public ApTableForOut(ArrayList apNameList){ this.apNameList = apNameList; this.setHorizontalScrollEnabled(true); this.setAutoscrolls(true); this.setSortable(false); this.setHighlighters(HighlighterFactory.createAlternateStriping()); this.setRowHeight(ROW_HEIGHT); //设置表头高度 JTableHeader tableHeader = this.getTableHeader(); Dimension size = tableHeader.getPreferredSize(); size.height = TABLE_HEADER_HEIGHT; tableHeader.setPreferredSize(size); initApTable(); } private void initApTable(){ ApTableModelForOut model = new ApTableModelForOut(); this.setModel(model); AttribItem abItem; try { abItemArray = APClient.getService().getAttribItemsByNames( apNameList.toArray(new String[0])); } catch (VCIError e) { //e.printStackTrace(); ClientLog4j.logger.error(e); } model.setRowCount(abItemArray.length); this.setEditable(true); for(int k = 0; k < abItemArray.length; k++){ abItem = abItemArray[k]; this.setValueAt(abItem.name, k, 0); this.setValueAt(abItem.vtDataType, k, 1); this.setValueAt(abItem.defValue, k, 2); this.setValueAt(abItem.description, k, 3); } this.setEditable(false); } }