wangting
2025-01-16 18c43123b51a1688ab4ae01fe3d171c7d92e619b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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<String> apNameList;
    private final int TABLE_HEADER_HEIGHT = 25;
    private final int ROW_HEIGHT = 30; 
 
    /**
     * 根据属性名字列表,获取属性列表
     * @param apNameList
     */
    public ApTableForOut(ArrayList<String> 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);
 
    }
}