|
|
|
@ -8,11 +8,18 @@ import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.FileReader;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
import java.nio.file.Path;
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
|
|
import javax.swing.JButton;
|
|
|
|
|
import javax.swing.JFileChooser;
|
|
|
|
@ -52,7 +59,7 @@ public class StructExportDialog extends AbstractAIFDialog {
|
|
|
|
|
private JTextField jtf_path; // 路径textField
|
|
|
|
|
private JButton b_path; // 选择路径
|
|
|
|
|
private String name; //报名类型
|
|
|
|
|
|
|
|
|
|
private String nameEnglish;//报表类型
|
|
|
|
|
public StructExportDialog(AbstractAIFApplication app, String actionInfo, ProgressBar pb_start) {
|
|
|
|
|
// TODO Auto-generated constructor stub
|
|
|
|
|
super(false);
|
|
|
|
@ -63,9 +70,11 @@ public class StructExportDialog extends AbstractAIFDialog {
|
|
|
|
|
switch (actionInfo) {
|
|
|
|
|
case "M008_Project":
|
|
|
|
|
name = "项目报表";
|
|
|
|
|
nameEnglish = "d";
|
|
|
|
|
break;
|
|
|
|
|
case "M008_Part":
|
|
|
|
|
name = "方案报表";
|
|
|
|
|
nameEnglish = "e";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
@ -87,7 +96,7 @@ public class StructExportDialog extends AbstractAIFDialog {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initUI() {
|
|
|
|
|
private void initUI() throws IOException {
|
|
|
|
|
|
|
|
|
|
this.setTitle("结构报表导出");
|
|
|
|
|
this.setPreferredSize(new Dimension(500, 400));
|
|
|
|
@ -196,24 +205,35 @@ public class StructExportDialog extends AbstractAIFDialog {
|
|
|
|
|
return panel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JPanel getPathPanel() {
|
|
|
|
|
private JPanel getPathPanel() throws IOException {
|
|
|
|
|
JPanel panel = new JPanel(new PropertyLayout());
|
|
|
|
|
|
|
|
|
|
// JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 15, 5));
|
|
|
|
|
jtf_path = new JTextField(30);
|
|
|
|
|
//2022/11/14新增记录保存路径
|
|
|
|
|
String tempPath = System.getProperty("java.io.tmpdir");
|
|
|
|
|
String tempFilePath = tempPath + File.separator + name + "功能导出路径.txt";
|
|
|
|
|
File exportFileTxt = new File(tempFilePath);
|
|
|
|
|
if(exportFileTxt.exists()) {
|
|
|
|
|
String[] openTextFile = openTextFile(tempFilePath);
|
|
|
|
|
System.out.println("上次保存路径:"+openTextFile[0]);
|
|
|
|
|
jtf_path.setText(openTextFile[0]);
|
|
|
|
|
System.out.println("System.getenv(\"Temp\")==========="+System.getenv("Temp"));
|
|
|
|
|
Path configFilePath = Paths.get(System.getenv("Temp")+"//export_dir.config");
|
|
|
|
|
// 检查文件是否存在,不存在则创建
|
|
|
|
|
if (!Files.exists(configFilePath)) {
|
|
|
|
|
Files.createFile(configFilePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Properties properties = new Properties();
|
|
|
|
|
try (InputStream in = new FileInputStream(System.getenv("Temp")+"//export_dir.config")) {
|
|
|
|
|
properties.load(in);
|
|
|
|
|
}
|
|
|
|
|
System.out.println("properties==="+properties.toString());
|
|
|
|
|
System.out.println("size==="+properties.size());
|
|
|
|
|
System.out.println("nameEnglish======="+nameEnglish);
|
|
|
|
|
String property = properties.getProperty(nameEnglish);
|
|
|
|
|
if(property != null && !property.isEmpty()) {
|
|
|
|
|
jtf_path.setText(property);
|
|
|
|
|
}else {
|
|
|
|
|
File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory();
|
|
|
|
|
String desktopPath = desktopDir.getAbsolutePath();
|
|
|
|
|
jtf_path.setText(desktopPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
b_path = new JButton("浏览");
|
|
|
|
|
|
|
|
|
|
panel.add("1.1.left.top", new JLabel("报表保存路径: "));
|
|
|
|
@ -230,16 +250,13 @@ public class StructExportDialog extends AbstractAIFDialog {
|
|
|
|
|
JFileChooser jfc = new JFileChooser();
|
|
|
|
|
FileSystemView fsv = FileSystemView.getFileSystemView();
|
|
|
|
|
//2022/11/14新增记录保存路径
|
|
|
|
|
String tempPath = System.getProperty("java.io.tmpdir");
|
|
|
|
|
String tempFilePath = tempPath + File.separator + name + "功能导出路径.txt";
|
|
|
|
|
File exportFileTxt = new File(tempFilePath);
|
|
|
|
|
if(exportFileTxt.exists()) {
|
|
|
|
|
String[] openTextFile = openTextFile(tempFilePath);
|
|
|
|
|
System.out.println("上次保存路径:"+openTextFile[0]);
|
|
|
|
|
jfc.setCurrentDirectory(new File(openTextFile[0]));
|
|
|
|
|
String property = properties.getProperty(nameEnglish);
|
|
|
|
|
if(property != null && !property.isEmpty()) {
|
|
|
|
|
jfc.setCurrentDirectory(new File(property));
|
|
|
|
|
}else {
|
|
|
|
|
jfc.setCurrentDirectory(fsv.getHomeDirectory());
|
|
|
|
|
}
|
|
|
|
|
System.out.println("111111111111111111111111111111111111111111111111");
|
|
|
|
|
|
|
|
|
|
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
|
|
|
|
jfc.showOpenDialog(StructExportDialog.this);
|
|
|
|
@ -248,14 +265,17 @@ public class StructExportDialog extends AbstractAIFDialog {
|
|
|
|
|
System.out.println("->" + f.getAbsolutePath());
|
|
|
|
|
jtf_path.setText(f.getAbsolutePath());
|
|
|
|
|
//2022/11/14新增记录保存路径
|
|
|
|
|
try {
|
|
|
|
|
writeFile(tempFilePath,f.getAbsolutePath());
|
|
|
|
|
properties.setProperty(nameEnglish, f.getAbsolutePath());
|
|
|
|
|
System.out.println("f.getAbsolutePath()=========="+f.getAbsolutePath());
|
|
|
|
|
}
|
|
|
|
|
// 保存修改后的配置
|
|
|
|
|
try (OutputStream out = Files.newOutputStream(configFilePath)) {
|
|
|
|
|
properties.store(out, null);
|
|
|
|
|
} catch (IOException e1) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return panel;
|
|
|
|
|