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