ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
109
110
111
112
113
114
115
116
117
118
119
120
package com.vci.client.omd.btm.ui;
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import com.vci.client.omd.attribpool.toOutside.ApSelectTableForBtm;
 
/**
 * 为业务类型选择属性
 * @author Administrator
 *
 */
public class ApSelectDialog extends JDialog{
 
    /**
     * 
     */
    private static final long serialVersionUID = 6816801739535934309L;
    private ApSelectTableForBtm apsTable;
    private ArrayList<String> apNameList = null;
    private ArrayList<String> selectedApNameList = null;
    private JPanel centerPanel, southPanel,northPanel;
    private JScrollPane scrollPanel;
    private JButton btnOK;
    private JButton btnCancel;
    public  JTextField tfFilter=new JTextField(20);
    public  JButton sel=new JButton("查询");
    
    public ApSelectDialog(ArrayList<String> apNameList){
        this.apNameList = apNameList;
        initUI();
        initTable();
        addListener();
    }
    
    private void initUI(){
        this.setTitle("属性池");
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        this.setSize(screenSize.width/2, screenSize.height/2);
        this.setModal(true);
        this.setLocationRelativeTo(null);
        this.setResizable(false);
        
        this.setLayout(new BorderLayout(5, 5));
        //查询框
        northPanel=new JPanel();
        //属性池列表
        centerPanel = new JPanel();
        //按钮
        southPanel = new JPanel();
        this.add(northPanel,BorderLayout.NORTH);
        this.add(centerPanel, BorderLayout.CENTER);
        this.add(southPanel, BorderLayout.SOUTH);
        
        northPanel.add(new JLabel("属性名"));
        northPanel.add(tfFilter);
        northPanel.add(sel);
        //add by caill start
        //给查询按钮添加点击事件
        sel.addActionListener(new ActionListener() {
            @Override
                public void actionPerformed(ActionEvent e) {
                    apsTable.initApTable2(tfFilter.getText().trim());
                }
            });
        //add by caill end
        centerPanel.setLayout(new BorderLayout());
        scrollPanel = new JScrollPane();
        centerPanel.add(scrollPanel, BorderLayout.CENTER);
        
        btnOK = new JButton("确定");
        btnCancel = new JButton("取消");
        southPanel.add(btnOK);
        southPanel.add(btnCancel);
    }
    
    private void initTable(){
        apsTable = new ApSelectTableForBtm(apNameList);
        scrollPanel.setViewportView(apsTable);
    }
 
    private void addListener(){
        btnOK.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent e) {
                selectedApNameList = new ArrayList<String>();
                for(int i = 0; i < apsTable.getRowCount(); i++){
                    if(((JCheckBox)apsTable.getValueAt(i, 0)).isSelected()){
                        selectedApNameList.add((String) apsTable.getValueAt(i, 1));
                    }
                }
                dispose();
            }
        });
        
        btnCancel.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent e) {
                dispose();
            }
        });
    }
    
    public ArrayList<String> getSelectedApNameList(){
        return selectedApNameList;
    }
    
}