package com.vci.client.omd.attribpool.ui; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import com.vci.client.omd.provider.ApProvider; import com.vci.corba.omd.atm.AttribItem; public class ExpActionListener implements ActionListener{ private JFileChooser fileChooser; public ExpActionListener(){ fileChooser = new JFileChooser(); fileChooser.setDialogTitle("导出"); } @Override public void actionPerformed(ActionEvent e) { AttribItem[] abs = AttribPoolPanel.getInstance().getSelectedAbs(); //未选中, 返回 if(abs == null || abs.length == 0){ JOptionPane.showMessageDialog(AttribPoolPanel.getInstance(), "请选中数据", "请选中数据", JOptionPane.ERROR_MESSAGE); return; } //选中根节点, 返回 fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setApproveButtonText("导出"); int result = fileChooser.showOpenDialog(AttribPoolPanel.getInstance()); if(result == JFileChooser.APPROVE_OPTION){ String dir = fileChooser.getSelectedFile().getAbsolutePath(); boolean rs = ApProvider.getInstance().expData(dir, abs); if(rs){ JOptionPane.showMessageDialog(AttribPoolPanel.getInstance(), "导出成功", "导出成功", JOptionPane.INFORMATION_MESSAGE); return; }else{ JOptionPane.showMessageDialog(AttribPoolPanel.getInstance(), "导出失败", "导出失败", JOptionPane.INFORMATION_MESSAGE); return; } } } }