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 e05d3626a1..c7192eb099 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,21 +16,38 @@ 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.filter.ChooseFileFilter; import com.fr.general.GeneralUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import org.jetbrains.annotations.Nullable; +import com.fr.workspace.WorkContext; -import javax.swing.*; -import java.awt.*; + +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; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowEvent; +import java.io.ByteArrayOutputStream; 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 { @@ -44,6 +61,7 @@ public class FeedbackToolboxDialog extends JDialog { private final Color lineColor = new Color(192, 192, 192, 120); private JPanel body = null; private static final String WORK_SPACE_PATH = "reportlets"; + private static final int BUFFER_SIZE = 2 * 1024; public FeedbackToolboxDialog(Frame owner) { super(owner, Toolkit.i18nText("Fine-Design_Basic_Carton_Feedback_ToolBox")); @@ -93,7 +111,7 @@ public class FeedbackToolboxDialog extends JDialog { exportLogLabel.setForeground(UIConstants.FLESH_BLUE); exportLogLabel.addMouseListener(new MouseAdapter() { @Override - public void mousePressed(MouseEvent e) { + public void mouseClicked(MouseEvent e) { if (exportLogLabel.isEnabled()) { exportLogFile(); } @@ -120,6 +138,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(); @@ -127,24 +148,10 @@ public class FeedbackToolboxDialog extends JDialog { //selectDate 2002-03-09例子 String[] split = selectDate.split("-"); int month = Integer.parseInt(split[1]); - File sourceFile = new File(StableUtils.pathJoin(SwitchForSwingChecker.JOURNAL_FILE_PATH, split[0], "month-" + month, selectDate)); + String sourceFilePath = StableUtils.pathJoin(SwitchForSwingChecker.JOURNAL_FILE_PATH, split[0], "month-" + month, selectDate); + File sourceFile = new File(sourceFilePath); if (sourceFile.exists()) { - File[] files = sourceFile.listFiles(); - if (files != null) { - try { - if (path.startsWith(WORK_SPACE_PATH)) { - String curEnvName = DesignerEnvManager.getEnvManager().getCurEnvName(); - DesignerWorkspaceInfo workspaceInfo = DesignerEnvManager.getEnvManager().getWorkspaceInfo(curEnvName); - String workspaceInfoPath = workspaceInfo.getPath(); - path = new StringBuilder(workspaceInfoPath).append(path.substring(10)).toString(); - } - LogZipUtils.compress(files, path, false); - FineJOptionPane.showMessageDialog(null, 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); - FineLoggerFactory.getLogger().error("export file fail", exception); - } - } + exportCartonLog(sourceFile, path, sourceFilePath); } fileChooserPane.removeAllFilter(); } @@ -333,4 +340,68 @@ public class FeedbackToolboxDialog extends JDialog { uploadButton.setEnabled(flag); exportLogLabel.setEnabled(flag); } + + /** + * 导出卡顿日志到本地或远程服务器WEB-INF下 + * + * @param sourceFile 导出的卡顿日志所在文件夹 + * @param path 文件需要导出到的路径 + * @param sourceFilePath 导出的卡顿日志所在文件夹的路径 + */ + private void exportCartonLog(File sourceFile, String path, String sourceFilePath) { + File[] files = sourceFile.listFiles(); + if (!Objects.isNull(files)) { + try { + if (path.startsWith(WORK_SPACE_PATH)) { + if (WorkContext.getCurrent().isLocal()) { + String curEnvName = DesignerEnvManager.getEnvManager().getCurEnvName(); + DesignerWorkspaceInfo workspaceInfo = DesignerEnvManager.getEnvManager().getWorkspaceInfo(curEnvName); + String workspaceInfoPath = workspaceInfo.getPath(); + path = StableUtils.pathJoin(workspaceInfoPath, path); + LogZipUtils.compress(files, path, false); + } else { + String sourceFilePathZip = sourceFilePath + ".zip"; + LogZipUtils.compress(files, sourceFilePathZip, false); + byte[] bytesByFile = getBytesByFile(sourceFilePathZip); + WorkContext.getWorkResource().write(path, bytesByFile); + LogZipUtils.delDir(sourceFilePathZip); + } + } else { + LogZipUtils.compress(files, path, false); + } + FineJOptionPane.showMessageDialog(this, Toolkit.i18nText("Fine-Design_Report_Exported_Successfully")); + } catch (Exception exception) { + 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[] + */ + @Nullable + private static byte[] getBytesByFile(String pathStr) { + File file = new File(pathStr); + try { + FileInputStream fis = new FileInputStream(file); + ByteArrayOutputStream bos = new ByteArrayOutputStream(BUFFER_SIZE); + byte[] b = new byte[BUFFER_SIZE]; + int n; + while ((n = fis.read(b)) != -1) { + bos.write(b, 0, n); + } + fis.close(); + byte[] data = bos.toByteArray(); + bos.close(); + return data; + } catch (Exception e) { + FineLoggerFactory.getLogger().error("reading local file fail", e); + } + return null; + } + } diff --git a/designer-base/src/main/java/com/fr/design/javascript/beautify/JavaScriptFormatHelper.java b/designer-base/src/main/java/com/fr/design/javascript/beautify/JavaScriptFormatHelper.java index 8e794f1924..e787fd132f 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/beautify/JavaScriptFormatHelper.java +++ b/designer-base/src/main/java/com/fr/design/javascript/beautify/JavaScriptFormatHelper.java @@ -1,16 +1,6 @@ package com.fr.design.javascript.beautify; -import com.eclipsesource.v8.V8; -import com.eclipsesource.v8.V8Array; -import com.eclipsesource.v8.V8Object; -import com.eclipsesource.v8.utils.V8ObjectUtils; -import com.fr.general.IOUtils; -import com.fr.log.FineLoggerFactory; -import com.fr.stable.EncodeConstants; - -import java.io.InputStream; -import java.io.UnsupportedEncodingException; public class JavaScriptFormatHelper { @@ -33,7 +23,7 @@ public class JavaScriptFormatHelper { * @see JSBeautify */ public static String beautify(String jsCode, BeautifyOption option) { - InputStream resourceAsStream = IOUtils.readResource("com/fr/design/javascript/beautify/beautify.js"); + /* InputStream resourceAsStream = IOUtils.readResource("com/fr/design/javascript/beautify/beautify.js"); String result = jsCode; V8 v8 = V8.createV8Runtime(); try { @@ -49,8 +39,8 @@ public class JavaScriptFormatHelper { FineLoggerFactory.getLogger().error(e.getMessage(), e); } finally { v8.release(true); - } - return result; + }*/ + return jsCode; } public static void main(String[] args) { diff --git a/designer-base/src/main/java/com/fr/startup/metric/DesignerStartupModel.java b/designer-base/src/main/java/com/fr/startup/metric/DesignerStartupModel.java index 9c0c07315d..5ed94d82eb 100644 --- a/designer-base/src/main/java/com/fr/startup/metric/DesignerStartupModel.java +++ b/designer-base/src/main/java/com/fr/startup/metric/DesignerStartupModel.java @@ -6,7 +6,7 @@ import com.fr.plugin.context.PluginContext; import com.fr.plugin.manage.PluginManager; import com.fr.stable.os.AbstractOperatingSystem; import com.fr.stable.os.OperatingSystem; -import com.fr.start.common.DesignerStartupConfig; +import com.fr.start.common.DesignerStartupContext; import com.fr.workspace.WorkContext; import java.lang.management.ManagementFactory; @@ -117,7 +117,8 @@ public class DesignerStartupModel { private void fillMode() { - this.setMode(DesignerStartupConfig.getInstance().isEnabled() ? 0 : 1); + // 这里需要使用 showStartupPage , 表示是否存在启动页 + this.setMode(DesignerStartupContext.getInstance().isShowStartupPage() ? 0 : 1); } public void fill() { diff --git a/designer-realize/src/main/java/com/fr/design/webattr/WriteWebSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/WriteWebSettingPane.java index 527acb4c49..dd93281acd 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/WriteWebSettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/WriteWebSettingPane.java @@ -4,7 +4,6 @@ import com.fr.base.BaseUtils; import com.fr.design.ExtraDesignClassManager; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.ibutton.UIColorButton; -import com.fr.design.gui.ibutton.UINoThemeColorButton; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; @@ -45,7 +44,7 @@ public class WriteWebSettingPane extends WebSettingPane { protected JPanel createOtherSetPane() { colorBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Background_Of_Current_Row") + ":"); colorBox.setSelected(true); - colorButton = new UINoThemeColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/background.png")); + colorButton = new UIColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/background.png")); colorBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { colorButton.setEnabled(colorBox.isSelected()); diff --git a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java index 568b512938..ccae1a19a6 100644 --- a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java @@ -47,10 +47,17 @@ public class DesignerStartupPageActivator extends Activator { if (context.isShowStartupPage()) { showDesignerStartupPage(context); } else { - DesignerStartupPageUtil.enterWorkspace(); + startNonStartupPage(); } } + private void startNonStartupPage() { + + StopWatch recorder = DesignerStartupContext.getRecorder(); + DesignerStartupPageUtil.enterWorkspace(); + recordStartupEnd(recorder); + } + private void showDesignerStartupPage(DesignerStartupContext context) { // 启动页关闭