package com.vci.client.portal.NewNewUI.actionExport; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; import java.util.Map; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JTable; import com.vci.client.LogonApplication; import com.vci.client.portal.NewNewUI.Export.VCIImportTree; import com.vci.client.portal.UI.dialog.VCIGuideStepPanel; import com.vci.client.ui.swing.VCIOptionPane; /** * Action导出第二步界面 * * @Title :ExpActionStep2Panel.java * @Description : * @Copyright :宏博远达科技有限公司 * @Author :平台与规划部/ZhongGY/E-mail:zhonggy@vci-tech.com * @Date :2015-6-5 * @Version :1 * @Other :产生注释:Alt+Shift+J */ public class ImpActionStep2Panel extends VCIGuideStepPanel { private static final long serialVersionUID = 1L; /** *导入文件全路径显示 */ private JLabel importFileFullPath; /** * 导出日志文件全路径显示 */ private JLabel lblLogFileFullPath; /** * 导出日志清单列表 */ private JScrollPane scrollPane = new JScrollPane(); private JTable tblExportLog; /** * 导出文件名 */ private String logFileName = "..."; /*private String vciamfFileName = "...";*/ private VCIImportTree importTree = null; public ImpActionStep2Panel() { GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0, 0 }; gridBagLayout.rowHeights = new int[] { 25, 25, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE }; setLayout(gridBagLayout); JLabel label = new JLabel(" "); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.insets = new Insets(0, 0, 5, 5); gbc_label.gridx = 0; gbc_label.gridy = 0; add(label, gbc_label); JLabel label_1 = new JLabel("导入文件路径:"); GridBagConstraints gbc_label_1 = new GridBagConstraints(); gbc_label_1.insets = new Insets(0, 0, 5, 5); gbc_label_1.gridx = 1; gbc_label_1.gridy = 0; add(label_1, gbc_label_1); importFileFullPath = new JLabel("..."); GridBagConstraints gbc_lblModelFileFullPath = new GridBagConstraints(); gbc_lblModelFileFullPath.anchor = GridBagConstraints.WEST; gbc_lblModelFileFullPath.insets = new Insets(0, 0, 5, 5); gbc_lblModelFileFullPath.gridx = 2; gbc_lblModelFileFullPath.gridy = 0; add(importFileFullPath, gbc_lblModelFileFullPath); JLabel label_2 = new JLabel(" "); GridBagConstraints gbc_label_2 = new GridBagConstraints(); gbc_label_2.insets = new Insets(0, 0, 5, 0); gbc_label_2.gridx = 3; gbc_label_2.gridy = 0; add(label_2, gbc_label_2); JLabel label_4 = new JLabel("导入日志路径:"); GridBagConstraints gbc_label_4 = new GridBagConstraints(); gbc_label_4.insets = new Insets(0, 0, 5, 5); gbc_label_4.gridx = 1; gbc_label_4.gridy = 1; add(label_4, gbc_label_4); lblLogFileFullPath = new JLabel("..."); GridBagConstraints gbc_lblLogFileFullPath = new GridBagConstraints(); gbc_lblLogFileFullPath.anchor = GridBagConstraints.WEST; gbc_lblLogFileFullPath.insets = new Insets(0, 0, 5, 5); gbc_lblLogFileFullPath.gridx = 2; gbc_lblLogFileFullPath.gridy = 1; add(lblLogFileFullPath, gbc_lblLogFileFullPath); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.gridwidth = 2; gbc_scrollPane.insets = new Insets(0, 0, 0, 5); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 1; gbc_scrollPane.gridy = 2; add(scrollPane, gbc_scrollPane); tblExportLog = new JTable(); } public ImpActionStep1Panel getPreStepUI() { if (super.getPreStepUI() != null) { return (ImpActionStep1Panel) super.getPreStepUI(); } else { return null; } } public Map getCommonMap(){ /*return (HashMap)this.getOwnParent().getDialogCommonShareData();*/ return this.getGuidCommonShareData(); } @Override public void initUI() { // 可不用处理,默认加载即可 importTree = (VCIImportTree) getCommonMap().get("importTree"); String filePath = (String) getCommonMap().get("filePath"); String logFileFullPath = filePath.substring(0, filePath.lastIndexOf(File.separator)+1); this.logFileName = logFileFullPath+"VCIAcionImport"+System.nanoTime()+".log"; this.importFileFullPath.setText(filePath); this.lblLogFileFullPath.setText(this.logFileName); this.scrollPane.setViewportView(tblExportLog); initData(); } @Override public void initData() { PrintWriter logFileWriter = null; try { File logFile = new File(logFileName); logFileWriter = new PrintWriter(logFile); importTree.exeImport(logFileWriter,this.tblExportLog); } catch (FileNotFoundException e) { VCIOptionPane.showMessage(LogonApplication.frame, "导出文件创建失败!"); e.printStackTrace(); } catch (@SuppressWarnings("hiding") IOException e) { VCIOptionPane.showMessage(LogonApplication.frame, "导出流异常!"); e.printStackTrace(); } finally { try { if (logFileWriter != null) { logFileWriter.flush(); logFileWriter.close(); } } catch (Exception e) { VCIOptionPane.showMessage(LogonApplication.frame, "导出流关闭异常!"); e.printStackTrace(); } } // TODO: 加载日志清单数据(tblExportLog/lblModelFileFullPath/lblLogFileFullPath) } @Override public String getStepName() { String secondStepName = null; if((secondStepName = (String)this.getCommonMap().get("secondStepName") )!= null){ return secondStepName; } return "第二步:Action导入结果"; } @Override public boolean isPreBtnVisible() { return true; } @Override public String getPreBtnText() { return "上一步"; } @Override public boolean doPreBtnAction() { // TODO:上一步操作处理 return true; } @Override public boolean isNextBtnVisible() { // 最后一步不显示“下一步” return false; } @Override public String getNextBtnText() { return null; } @Override public boolean doNextBtnAction() { return true; } @Override public boolean isCancelBtnVisible() { return true; } @Override public String getcancelBtnText() { return "完成"; } String dialogProcess = ""; // [第X步/共X步] public String getDialogProcess() { dialogProcess = "[第2步/共2步]"; return dialogProcess; } }