package com.vci.client.omd.attribpool.toOutside; import java.awt.Dimension; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; 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 ApTableForBtm extends JXTable{ /** * */ private static final long serialVersionUID = -483194770273076948L; private HashMap> apNameMap = null; private AttribItem[] abItemArray = null; private final int TABLE_HEADER_HEIGHT = 25; private final int ROW_HEIGHT = 30; public ApTableForBtm(HashMap> apNameMap){ this.apNameMap = apNameMap; 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(); } public void initApTable(){ ApTableModelForBtm model = new ApTableModelForBtm(); this.setModel(model); AttribItem abItem; String btmName; int rowCountOriginal; for(Iterator i = apNameMap.keySet().iterator(); i.hasNext();){ btmName = i.next(); try { abItemArray = APClient.getService().getAttribItemsByNames( apNameMap.get(btmName).toArray(new String[0])); } catch (VCIError e) { //e.printStackTrace(); ClientLog4j.logger.error(e); } if(abItemArray == null){ return; } rowCountOriginal = model.getRowCount(); model.setRowCount(rowCountOriginal + abItemArray.length); this.setEditable(true); for(int k = 0; k < abItemArray.length; k++){ abItem = abItemArray[k]; this.setValueAt(abItem.name, rowCountOriginal + k, 0); this.setValueAt(btmName, rowCountOriginal + k, 1); this.setValueAt(abItem.vtDataType, rowCountOriginal + k, 2); this.setValueAt(abItem.defValue, rowCountOriginal + k, 3); this.setValueAt(abItem.description, rowCountOriginal + k, 4); } this.setEditable(false); } } }