田源
2025-01-09 8a166a60cfd1a2e593ffa103d10c0dc224fc8628
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
package com.vci.client.uif.actions.client;
 
import java.io.File;
import java.util.Map;
 
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
 
import com.vci.client.bof.ClientLinkObject;
import com.vci.client.uif.engine.common.IDataNode;
import com.vci.client.utils.ImportDataTool;
import com.vci.corba.omd.data.LinkObject;
import com.vci.mw.ClientContextVariable;
 
/**
 * 导入链接对象: 导入业务对象时, 创建对应的链接对象.
 * @author zhouhui
 *
 */
public class ImportLOAction extends DoseNotSelectDataAction{
    /**
     * 按钮参数信息
     */
    private Map<String, String> paramsMap;
    
    @Override
    public String getKey() {
        return IMPORTLO;
    }
    
    @Override
    public boolean doPost() {
        try{
            
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            fileChooser.setDialogTitle("选择文件");
            int result = fileChooser.showOpenDialog(ClientContextVariable.getFrame());
            if(result != JFileChooser.APPROVE_OPTION){
                return false;
            }
            File file = fileChooser.getSelectedFile().getAbsoluteFile();
            String fileName = file.getName();
            //获得按钮参数
            paramsMap = getButtonParams();
            String linkType = paramsMap.get("linkType");
            String type = paramsMap.get("type");
            IDataNode d2 = getRegionPanel().getSourceData();
            ClientLinkObject lo = (ClientLinkObject) d2.getMaterObject();
            LinkObject lo_ = lo.getLinkObject();
            String f_oid = lo_.toOid;
            String f_type = lo_.toBTName;
            String f_revisionOid = lo_.toRevOid;
            String f_nameoid = lo_.toNameOid;
            Map<String, String> infoMap = ImportDataTool.importLOData(file, fileName, type, 
                    linkType, f_type, f_oid, f_revisionOid, f_nameoid, 1);
            String errorInfo = infoMap.get(ImportDataTool.ERROR);
            if(errorInfo != null){
                JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), 
                        errorInfo, errorInfo, JOptionPane.INFORMATION_MESSAGE);
                return false;
            }
            boolean flag = Boolean.valueOf(infoMap.get(ImportDataTool.RESULT));
            if(flag){
                JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), 
                        "导入数据成功", "导入数据成功", JOptionPane.INFORMATION_MESSAGE);
            }else{
                JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), 
                        "导入数据失败", "导入数据失败", JOptionPane.INFORMATION_MESSAGE);
            }
            return flag;
        }catch(Throwable e){
            UIFUtils.showErrorMessage(ClientContextVariable.getFrame(),
                    "uifmodel.plm.uif.actions.importBOerror", e);
            return false;
        }
    }
}