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 apNameList = null; private ArrayList 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 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(); 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 getSelectedApNameList(){ return selectedApNameList; } }