package com.vci.client.omd.btm.ui; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import com.vci.client.omd.provider.BtmProvider; import com.vci.corba.omd.btm.BtmItem; public class ExpActionListener implements ActionListener{ private JFileChooser fileChooser; public ExpActionListener(){ fileChooser = new JFileChooser(); fileChooser.setDialogTitle("导出"); } @Override public void actionPerformed(ActionEvent e) { List list = BtmPanel.getInstance().getSelectedBtms(); if(list == null || list.size() < 1){ JOptionPane.showMessageDialog(BtmPanel.getInstance(), "请选中数据", "请选中数据", JOptionPane.ERROR_MESSAGE); return; } fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setApproveButtonText("导出"); int result = fileChooser.showOpenDialog(BtmPanel.getInstance()); if(result == JFileChooser.APPROVE_OPTION){ String dir = fileChooser.getSelectedFile().getAbsolutePath(); boolean rs = BtmProvider.getInstance().expData(dir, list.toArray(new BtmItem[0])); if(rs){ JOptionPane.showMessageDialog(BtmPanel.getInstance(), "导出成功", "导出成功", JOptionPane.INFORMATION_MESSAGE); return; }else{ JOptionPane.showMessageDialog(BtmPanel.getInstance(), "导出失败", "导出失败", JOptionPane.INFORMATION_MESSAGE); return; } } } }