package com.vci.client.portal.NewNewUI.actionExport;
|
import java.awt.Color;
|
import java.awt.GridBagConstraints;
|
import java.awt.GridBagLayout;
|
import java.awt.Insets;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.io.File;
|
import java.util.Map;
|
|
import javax.swing.JButton;
|
import javax.swing.JFileChooser;
|
import javax.swing.JLabel;
|
import javax.swing.JPanel;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTextField;
|
import javax.swing.filechooser.FileFilter;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.portal.NewNewUI.Export.VCIExportTree;
|
import com.vci.client.portal.UI.dialog.VCIGuideStepPanel;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.ui.swing.VCISwingUtil;
|
|
import javax.swing.UIManager;
|
/**
|
* Action导出步骤1界面
|
* @Title :ExpActionStep1Panel.java
|
* @Description :
|
* @Copyright :宏博远达科技有限公司
|
* @Author :平台与规划部/ZhongGY/E-mail:zhonggy@vci-tech.com
|
* @Date :2015-6-5
|
* @Version :1
|
* @Other :产生注释:Alt+Shift+J
|
*/
|
public class ExpActionStep1Panel extends VCIGuideStepPanel {
|
|
private static final long serialVersionUID = 1L;
|
|
private VCIExportTree exportTree ;
|
private JTextField txtDirectory;
|
private JButton btnSelDirectory;
|
private String exportFilePath = null;
|
private JScrollPane scrollPane = new JScrollPane();
|
public ExpActionStep1Panel() {
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
gridBagLayout.columnWidths = new int[]{0, 0, 0, 0};
|
gridBagLayout.rowHeights = new int[]{0, 30, 0};
|
gridBagLayout.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
gridBagLayout.rowWeights = new double[]{1.0, 0.0, Double.MIN_VALUE};
|
setLayout(gridBagLayout);
|
|
|
JLabel label_2 = new JLabel(" ");
|
GridBagConstraints gbc_label_2 = new GridBagConstraints();
|
gbc_label_2.insets = new Insets(0, 0, 5, 5);
|
gbc_label_2.gridx = 0;
|
gbc_label_2.gridy = 0;
|
add(label_2, gbc_label_2);
|
|
// JScrollPane scrollPane = new JScrollPane();
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.insets = new Insets(0, 0, 5, 5);
|
gbc_scrollPane.gridx = 1;
|
gbc_scrollPane.gridy = 0;
|
add(scrollPane, gbc_scrollPane);
|
|
|
JLabel label = new JLabel(" ");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 5, 0);
|
gbc_label.gridx = 2;
|
gbc_label.gridy = 0;
|
add(label, gbc_label);
|
|
JPanel panel = new JPanel();
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
gbc_panel.insets = new Insets(0, 0, 0, 5);
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
gbc_panel.gridx = 1;
|
gbc_panel.gridy = 1;
|
add(panel, gbc_panel);
|
GridBagLayout gbl_panel = new GridBagLayout();
|
gbl_panel.columnWidths = new int[]{0, 0, 0, 0};
|
gbl_panel.rowHeights = new int[]{0, 0};
|
gbl_panel.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
|
gbl_panel.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
panel.setLayout(gbl_panel);
|
|
JLabel label_3 = new JLabel("导出目录:");
|
GridBagConstraints gbc_label_3 = new GridBagConstraints();
|
gbc_label_3.insets = new Insets(0, 0, 0, 5);
|
gbc_label_3.anchor = GridBagConstraints.EAST;
|
gbc_label_3.gridx = 0;
|
gbc_label_3.gridy = 0;
|
panel.add(label_3, gbc_label_3);
|
|
txtDirectory = new JTextField();
|
txtDirectory.setText("请选择导出目录...");
|
txtDirectory.setEditable(false);
|
txtDirectory.setBackground(UIManager.getColor("CheckBox.background"));
|
txtDirectory.setForeground(Color.BLACK);
|
GridBagConstraints gbc_txtDirectory = new GridBagConstraints();
|
gbc_txtDirectory.insets = new Insets(0, 0, 0, 5);
|
gbc_txtDirectory.fill = GridBagConstraints.HORIZONTAL;
|
gbc_txtDirectory.gridx = 1;
|
gbc_txtDirectory.gridy = 0;
|
panel.add(txtDirectory, gbc_txtDirectory);
|
txtDirectory.setColumns(10);
|
|
btnSelDirectory = new JButton("...");
|
btnSelDirectory.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
ExpActionStep1Panel.this.selectDirectory(e);
|
}
|
});
|
GridBagConstraints gbc_btnSelDirectory = new GridBagConstraints();
|
gbc_btnSelDirectory.anchor = GridBagConstraints.EAST;
|
gbc_btnSelDirectory.gridx = 2;
|
gbc_btnSelDirectory.gridy = 0;
|
panel.add(btnSelDirectory, gbc_btnSelDirectory);
|
}
|
|
/**
|
* 选择目录
|
* @Title :selectDirectory
|
* @Description :
|
* @param e
|
*/
|
public void selectDirectory(ActionEvent e) {
|
//TODO:给txtDirectory赋值
|
this.openFileChoser();
|
}
|
|
@Override
|
public void initUI() {
|
//可不处理,默认加载即可
|
initData();
|
}
|
|
public Map<String,Object> getCommonMap(){
|
return this.getGuidCommonShareData();
|
}
|
@Override
|
//执行“导出”树的初始化,并添加到scrollPane中
|
public void initData() {
|
// TODO:主要处理结构树的加载(包括树结构勾选逻辑)
|
// 初始化树
|
//put("exportTree",new VCIActionExportTree());
|
if (exportTree == null) {
|
exportTree = new VCIActionExportTree();
|
getCommonMap().put("exportTree", exportTree);
|
}
|
exportTree = (VCIExportTree)getCommonMap().get("exportTree");
|
exportTree.init();
|
// exportTree.doLayout();
|
scrollPane.setViewportView(exportTree);
|
// scrollPane.doLayout();
|
|
}
|
|
private void openFileChoser() {
|
JFileChooser jf = new JFileChooser();
|
jf.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
jf.removeChoosableFileFilter(jf.getFileFilter());
|
jf.setFileFilter(new FileFilter() {
|
public String getDescription() {
|
return "文件夹";
|
}
|
public boolean accept(File f) {
|
return (f.isDirectory());
|
}
|
});
|
jf.setDialogTitle("选择action导出文件夹");
|
int showOpenDialog = jf.showOpenDialog(LogonApplication.frame);
|
if (showOpenDialog == JFileChooser.APPROVE_OPTION) {
|
File selectedFile = jf.getSelectedFile();
|
exportFilePath = selectedFile.getAbsolutePath();
|
this.getCommonMap().put("exportFilePath", exportFilePath);
|
txtDirectory.setFont(VCISwingUtil.FONT_SONTTI_PLAN_14);
|
txtDirectory.setText(exportFilePath);
|
}
|
}
|
@Override
|
public String getStepName() {
|
return "第一步:导出文件选择";
|
}
|
|
@Override
|
public boolean isPreBtnVisible() {
|
//第一步没有“上一步”
|
return false;
|
}
|
|
@Override
|
public String getPreBtnText() {
|
return null;
|
}
|
|
@Override
|
public boolean doPreBtnAction() {
|
return false;
|
}
|
|
@Override
|
public boolean isNextBtnVisible() {
|
return true;
|
}
|
|
@Override
|
public String getNextBtnText() {
|
return "导出";
|
}
|
|
/**
|
* 导出的主要处理入口
|
*/
|
@Override
|
public boolean doNextBtnAction() {
|
//判断导出树是否正确选择导出内容
|
if(exportTree.hasSelectExportContent()){
|
if(this.exportFilePath!=null){
|
File file = new File(exportFilePath);
|
|
if(!file.exists()){
|
VCIOptionPane.showMessage(LogonApplication.frame, "导出地址不存在,请确保导出地址存在");
|
}
|
|
VCIGuideStepPanel nextStepUI = getNextStepUI();
|
nextStepUI.initUI();
|
return true;
|
}else{
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择导出地址");
|
return false;
|
}
|
|
}else{
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择数据");
|
return false;
|
}
|
// ExportBeans exportData = new ExportBeans();
|
// exportData.setCommonMap(getCommonMap());
|
// //exportData.set导出的相关数据
|
//
|
// getCommonMap().put("exportData", exportData);
|
|
|
|
}
|
|
@Override
|
public boolean isCancelBtnVisible() {
|
return true;
|
}
|
|
@Override
|
public String getcancelBtnText() {
|
return "取消";
|
}
|
|
String dialogProcess = ""; //[第X步/共X步]
|
public String getDialogProcess() {
|
dialogProcess = "[第1步/共2步]";
|
return dialogProcess;
|
}
|
|
public VCIGuideStepPanel getNextStepUI() {
|
if (super.getNextStepUI() == null) {
|
VCIGuideStepPanel nextStepUI = new ExpActionStep2Panel();
|
nextStepUI.setPreStepUI(this);
|
nextStepUI.setOwnParent(this.getOwnParent());
|
super.setNextStepUI(nextStepUI);
|
}
|
|
return super.getNextStepUI() ;
|
}
|
}
|