From 4010d3692b58c155031aafee000c686459b074df Mon Sep 17 00:00:00 2001 From: "John.Ying" Date: Mon, 29 Aug 2022 16:57:33 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-79108=20=E5=AF=BC=E5=87=BA=E5=8D=A1?= =?UTF-8?q?=E9=A1=BF=E6=97=A5=E5=BF=97=E9=BB=98=E8=AE=A4=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E6=A1=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/carton/FeedbackToolboxDialog.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/carton/FeedbackToolboxDialog.java b/designer-base/src/main/java/com/fr/design/carton/FeedbackToolboxDialog.java index f9aee284e2..5e0e2e559a 100644 --- a/designer-base/src/main/java/com/fr/design/carton/FeedbackToolboxDialog.java +++ b/designer-base/src/main/java/com/fr/design/carton/FeedbackToolboxDialog.java @@ -16,18 +16,23 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.env.detect.ui.EnvDetectorDialog; import com.fr.file.FILE; import com.fr.file.FILEChooserPane; +import com.fr.file.FILEFactory; +import com.fr.file.FileFILE; import com.fr.file.filter.ChooseFileFilter; import com.fr.general.GeneralUtils; +import com.fr.io.repository.base.fs.FileSystemRepository; import com.fr.log.FineLoggerFactory; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; +import javax.annotation.Nullable; import javax.swing.BorderFactory; import javax.swing.JDialog; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.UIManager; +import javax.swing.filechooser.FileSystemView; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -43,7 +48,7 @@ import java.io.File; import java.io.FileInputStream; import java.text.ParseException; import java.util.List; - +import java.util.Objects; public class FeedbackToolboxDialog extends JDialog { @@ -134,6 +139,9 @@ public class FeedbackToolboxDialog extends JDialog { fileChooserPane.setFileNameTextField(fileName.toString(), " "); fileChooserPane.removeAllFilter(); fileChooserPane.addChooseFILEFilter(new ChooseFileFilter("zip", Toolkit.i18nText("Fine-Design_Basic_Carton_Compile_File"))); + //默认选择桌面 + FILE desktop = FILEFactory.createFILE(FILEFactory.FILE_PREFIX + FileSystemView.getFileSystemView().getHomeDirectory().getPath()); + fileChooserPane.setCurrentDirectory(desktop); int chooseResult = fileChooserPane.showSaveDialog(DesignerContext.getDesignerFrame()); if (chooseResult == 0) { FILE selectedFile = fileChooserPane.getSelectedFILE(); @@ -343,7 +351,7 @@ public class FeedbackToolboxDialog extends JDialog { */ private void exportCartonLog(File sourceFile, String path, String sourceFilePath) { File[] files = sourceFile.listFiles(); - if (files != null) { + if (!Objects.isNull(files)) { try { if (path.startsWith(WORK_SPACE_PATH)) { if (WorkContext.getCurrent().isLocal()) { @@ -362,20 +370,22 @@ public class FeedbackToolboxDialog extends JDialog { } else { LogZipUtils.compress(files, path, false); } - FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Report_Exported_Successfully")); + FineJOptionPane.showMessageDialog(this, Toolkit.i18nText("Fine-Design_Report_Exported_Successfully")); } catch (Exception exception) { - FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Report_Export_Failed"), UIManager.getString("OptionPane.messageDialogTitle"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(this, Toolkit.i18nText("Fine-Design_Report_Export_Failed"), UIManager.getString("OptionPane.messageDialogTitle"), JOptionPane.ERROR_MESSAGE); FineLoggerFactory.getLogger().error("export file fail", exception); } } } + /** * 根据文件地址将文件转换成byte[] * * @param pathStr 本地文件目录 * @return 本地文件转成的byte[] */ - public static byte[] getBytesByFile(String pathStr) { + @Nullable + private static byte[] getBytesByFile(String pathStr) { File file = new File(pathStr); try { FileInputStream fis = new FileInputStream(file);