Browse Source

REPORT-79108 导出卡顿日志默认选择桌面

newui
John.Ying 2 years ago
parent
commit
4010d3692b
  1. 20
      designer-base/src/main/java/com/fr/design/carton/FeedbackToolboxDialog.java

20
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);

Loading…
Cancel
Save