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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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
}