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
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<BtmItem> 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;
            }
        }
    }
}