diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 1f3055d40a..8eb4a9afb7 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -1,9 +1,6 @@ package com.fr.design; import com.fr.common.report.ReportState; -import com.fr.design.env.processor.RemoteDesignerWorkspaceInfoProcessor; -import com.fr.design.mainframe.manager.clip.TemplateTreeClipboard; -import com.fr.design.plugin.remind.PluginErrorDesignReminder; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; @@ -14,13 +11,16 @@ import com.fr.design.env.DesignerWorkspaceInfoContext; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteWorkspace; +import com.fr.design.env.processor.RemoteDesignerWorkspaceInfoProcessor; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.SaveSomeTemplatePane; import com.fr.design.file.TemplateTreePane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.manager.clip.TemplateTreeClipboard; import com.fr.design.notification.NotificationCenter; +import com.fr.design.plugin.remind.PluginErrorDesignReminder; import com.fr.design.utils.DesignUtils; import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.env.EnvListPane; @@ -31,6 +31,7 @@ import com.fr.invoke.Reflect; import com.fr.json.JSONArray; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; +import com.fr.performance.profile.PerformancePoint; import com.fr.process.ProcessEventPipe; import com.fr.process.engine.core.CarryMessageEvent; import com.fr.process.engine.core.FineProcessContext; @@ -41,12 +42,14 @@ import com.fr.start.server.ServerTray; import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContextCallback; import com.fr.workspace.Workspace; +import com.fr.workspace.WorkspaceSwitchProcess; import com.fr.workspace.base.WorkspaceAPI; import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.engine.base.FineObjectPool; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import com.fr.workspace.engine.exception.WorkspaceConnectionException; import com.fr.workspace.engine.rpc.WorkspaceProxyPool; +import static javax.swing.JOptionPane.QUESTION_MESSAGE; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; @@ -58,12 +61,11 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Optional; import java.util.Set; -import java.util.HashSet; - -import static javax.swing.JOptionPane.QUESTION_MESSAGE; public class EnvChangeEntrance { private static final String BRANCH_TAG = "#"; @@ -125,48 +127,111 @@ public class EnvChangeEntrance { } } + /** * 切换到新环境 * * @param envName 新工作环境名称 + * @param strategy 提示策略 * @return 是否成功 */ private boolean switch2Env(final String envName, PopTipStrategy strategy) { - DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - DesignerWorkspaceInfo selectedEnv = customUserName(envManager.getWorkspaceInfo(envName)); - DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); - WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); + WorkspaceSwitchProcess lastProcess = WorkContext.getSwitcher().getProcess(); + PerformancePoint performancePoint = PerformancePoint.create(); + + boolean switchStatus = doSwitch2Env(envName, strategy); + + WorkspaceSwitchProcess currentProcess = WorkContext.getSwitcher().getProcess(); + // 如果相同,代表根本没切换 == + if (lastProcess != currentProcess) { + // 记录切换耗时 + recordSwitchInfos(performancePoint, switchStatus); + // 触发切换埋点 + triggerSwitchMetric(); + } + return switchStatus; + } + + /** + * 由云端运维,触发切换埋点 + * 内部空实现 + * 见 实现 + */ + private void triggerSwitchMetric() { + } + + /** + * 切换到新环境 + * 1. 先获取选中的环境 + * 2. 生成工作目录 + * 3. 验证工作目录 + * 4. 触发切换操作 + * 5. 触发可能存在异常的切换后动作 + * 6. 触发切换后动作 + * + * @param envName 新工作环境名称 + * @return 是否成功 + */ + private boolean doSwitch2Env(final String envName, PopTipStrategy strategy) { + + DesignerWorkspaceInfo selectedEnv = getSelectedEnv(envName); try { Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); - boolean checkValid = workspace != null && selectedEnv.checkValid(); - if (!checkValid) { + if (notValid(workspace, selectedEnv)) { return false; } - //如果是相同环境 - if (isSameEnv(workspace)) { - //目前切换到相同环境需要更新一下名字,后续如果有别的操作直接往里面加就行了 - switch2SameEnv(envName); - } else { - //切换到新环境,做下封装 - switch2OtherEnv(workspace, envName); - } - // REPORT-25688如果是war包部署的服务器,给与提示 - if (WorkContext.getCurrent().isWarDeploy()) { - FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"), - Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE); - } - //REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录 - JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (JTemplate.isValid(template)) { - template.refreshToolArea(); - } - PluginErrorDesignReminder.getInstance().remindStartFailedPlugins(); + doSwitchAction(envName, workspace); + afterSwitchWithEx(); } catch (Exception exception) { // 失败的处理 WorkspaceExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); return false; } + afterSwitch(); + return true; + } + + private DesignerWorkspaceInfo getSelectedEnv(String envName) { + + DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); + DesignerWorkspaceInfo selectedEnv = customUserName(envManager.getWorkspaceInfo(envName)); + DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); + return selectedEnv; + } + + private static boolean notValid(Workspace workspace, DesignerWorkspaceInfo selectedEnv) throws Exception { + boolean checkValid = workspace != null && selectedEnv.checkValid(); + return !checkValid; + } + + private void doSwitchAction(String envName, Workspace workspace) { + + //如果是相同环境 + if (isSameEnv(workspace)) { + //目前切换到相同环境需要更新一下名字,后续如果有别的操作直接往里面加就行了 + switch2SameEnv(envName); + } else { + //切换到新环境,做下封装 + switch2OtherEnv(workspace, envName); + } + } + + private static void afterSwitchWithEx() { + // REPORT-25688如果是war包部署的服务器,给与提示 + if (WorkContext.getCurrent().isWarDeploy()) { + FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"), + Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE); + } + //REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录 + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (JTemplate.isValid(template)) { + template.refreshToolArea(); + } + PluginErrorDesignReminder.getInstance().remindStartFailedPlugins(); + } + + private static void afterSwitch() { TemplateTreePane.getInstance().refreshDockingView(); DesignModelAdapter model = DesignModelAdapter.getCurrentModelAdapter(); if (model != null) { @@ -175,7 +240,18 @@ public class EnvChangeEntrance { NotificationCenter.getInstance().clearAllNotifications(); //切换环境后,清空粘贴板里面的内容 TemplateTreeClipboard.getInstance().reset(); - return true; + } + + private static void recordSwitchInfos(PerformancePoint performancePoint, boolean switchSuccess) { + + performancePoint.end(elapsed -> { + WorkspaceSwitchProcess process = WorkContext.getSwitcher().getProcess(); + Optional.ofNullable(process) + .ifPresent((e) -> { + e.recordSwitchElapsed(elapsed); + e.setSwitchSuccess(switchSuccess); + }); + }); } /** diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java index 86e7633be0..ebfd195d8e 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java @@ -1,6 +1,7 @@ package com.fr.design.data.datapane.connect; import com.fr.base.GraphHelper; +import com.fr.data.core.db.dialect.DialectFactory; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.pool.DBCPConnectionPoolAttr; import com.fr.design.dialog.BasicDialog; @@ -31,6 +32,7 @@ import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -43,7 +45,7 @@ public class DBCPAttrPane extends BasicPane { private static final int ORACLE_DEFAULT_FETCHSIZE = 128; private static final int DB2_DEFAULT_FETCHSIZE = 50; private static final int POSTGRE_DEFAULT_FETCHSIZE = 10000; - private static final int EMPTY_FETCHSIZE = -2; + private static final int INVALID_FETCHSIZE = -1; // carl:DBCP的一些属性 private IntegerEditor DBCP_INITIAL_SIZE = new IntegerEditor(); private IntegerEditor DBCP_MIN_IDLE = new IntegerEditor(); @@ -114,12 +116,25 @@ public class DBCPAttrPane extends BasicPane { this.DBCP_MINEVICTABLEIDLETIMEMILLIS.setValue(dbcpAttr.getMinEvictableIdleTimeMillis() / TIME_MULTIPLE); this.DBCP_NUMTESTSPEREVICTIONRUN.setValue(dbcpAttr.getNumTestsPerEvictionRun()); this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.setValue(dbcpAttr.getTimeBetweenEvictionRunsMillis()); - Integer fetchSize = DEFAULT_FETCHSIZE_MAP.get(JDBCConnectionDef.getInstance().getDatabaseName()); - if (fetchSize != null) { - if (jdbcDatabase.getFetchSize() == EMPTY_FETCHSIZE) { - this.FETCHSIZE.setText(StringUtils.EMPTY); + + /* + * 填充FetchSize输入框逻辑: + * + * 1. 如果JDBCDatabaseConnection里的fetchSize是有效值(>0),则显示该有效值 + * 2. 如果JDBCDatabaseConnection里的fetchSize是无效值(<=0): + * 2.1 如果我们对这种数据库有默认值(如oracle、db2、pgsql),就显示对应数据库的默认值,因为要避免性能问题,这几种数据库不支持关闭fetchSize + * 2.2 如果我们对这种数据库无默认值,就显示-1 + */ + + int fetchSize = jdbcDatabase.getFetchSize(); + String databaseName = JDBCConnectionDef.getInstance().getDatabaseName(); + if (DialectFactory.isValidFetchSize(fetchSize)) { + this.FETCHSIZE.setText(String.valueOf(fetchSize)); + } else { + if (DEFAULT_FETCHSIZE_MAP.containsKey(databaseName)) { + this.FETCHSIZE.setText(String.valueOf(DEFAULT_FETCHSIZE_MAP.get(databaseName))); } else { - this.FETCHSIZE.setText(jdbcDatabase.getFetchSize() == -1 ? String.valueOf(fetchSize) : String.valueOf(jdbcDatabase.getFetchSize())); + this.FETCHSIZE.setText(String.valueOf(INVALID_FETCHSIZE)); } } } @@ -137,12 +152,34 @@ public class DBCPAttrPane extends BasicPane { dbcpAttr.setMinEvictableIdleTimeMillis(((Number) this.DBCP_MINEVICTABLEIDLETIMEMILLIS.getValue()).intValue() * TIME_MULTIPLE); dbcpAttr.setNumTestsPerEvictionRun(((Number) this.DBCP_NUMTESTSPEREVICTIONRUN.getValue()).intValue()); dbcpAttr.setTimeBetweenEvictionRunsMillis(((Number) this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.getValue()).intValue()); - Integer fetchSize = DEFAULT_FETCHSIZE_MAP.get(JDBCConnectionDef.getInstance().getDatabaseName()); - if (fetchSize != null) { - if (StringUtils.isEmpty(this.FETCHSIZE.getText())) { - jdbcDatabase.setFetchSize(EMPTY_FETCHSIZE); + + /* + * FetchSize设置逻辑: + * + * 1. 如果客户界面上的fetchSize框留空: + * 1.1 如果我们对这种数据库有默认值(如oracle、db2、pgsql),就存对应数据库的默认值,否则会有性能问题,这几种数据库我们是不支持关闭fetchSize的 + * 1.2 如果我们对这种数据库没有默认值,就置为-1 + * 2. 如果客户界面上的fetchSize框非空: + * 2.1 如果fetchSize是个有效值(>0),就使用该值 + * 2.2 如果fetchSize是个无效值(<=0),就置为-1 + * + * -1带来的结果,就是我们Dialect不会putExecutor,最终不会执行java.sql.Statement.setFetchSize + */ + String fetchSizeText = this.FETCHSIZE.getText(); + String databaseName = JDBCConnectionDef.getInstance().getDatabaseName(); + + if (StringUtils.isEmpty(fetchSizeText)) { + if (DEFAULT_FETCHSIZE_MAP.containsKey(databaseName)) { + Optional.ofNullable(DEFAULT_FETCHSIZE_MAP.get(databaseName)).ifPresent(jdbcDatabase::setFetchSize); + } else { + jdbcDatabase.setFetchSize(INVALID_FETCHSIZE); + } + } else { + int fetchSizeSet = Integer.parseInt(fetchSizeText); + if (DialectFactory.isValidFetchSize(fetchSizeSet)) { + jdbcDatabase.setFetchSize(fetchSizeSet); } else { - jdbcDatabase.setFetchSize(Integer.parseInt(this.FETCHSIZE.getText())); + jdbcDatabase.setFetchSize(INVALID_FETCHSIZE); } } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java index 3c5c2b82a8..11c3f64d64 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java @@ -462,6 +462,7 @@ public abstract class DatabaseConnectionPane params) { SwingUtilities.invokeLater(new Runnable() { @Override diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java index f53930602c..f41c044b74 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java @@ -34,6 +34,7 @@ import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; +import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; @@ -742,7 +743,8 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { } public BasicDialog showLargeWindow(Window window, DialogActionListener l) { - BasicDialog basicDialog = super.showWindowWithCustomSize(window, l, new Dimension(900, 600)); + Dimension dimension = DesignSizeI18nManager.getInstance().i18nDimension(this.getClass().getName()); + BasicDialog basicDialog = super.showWindowWithCustomSize(window, l, dimension); basicDialog.setMinimumSize(new Dimension(900, 600)); basicDialog.setResizable(true); return basicDialog; @@ -1196,7 +1198,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { private void initDescriptionTextArea() { // Description - descriptionTextArea = new UITextArea(DESCRIPTION_TEXT_AREA_ROW,DESCRIPTION_TEXT_AREA_COLUMN); + descriptionTextArea = new UITextArea(DESCRIPTION_TEXT_AREA_ROW, DESCRIPTION_TEXT_AREA_COLUMN); descriptionTextArea.setBackground(Color.white); descriptionTextArea.setLineWrap(true); descriptionTextArea.setWrapStyleWord(true); @@ -1282,7 +1284,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { desScrollPane.setBorder(null); panel.add(this.createNamePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaPane_Formula_Description") + ":", desScrollPane), BorderLayout.CENTER); initVariablesTreeSelectionListener(); - this.add(panel,BorderLayout.CENTER); + this.add(panel, BorderLayout.CENTER); } private void initComponents() { diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java index 93cdc4e4e2..dfece2e133 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java @@ -17,6 +17,7 @@ import com.fr.stable.Nameable; import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; +import javax.swing.BorderFactory; import javax.swing.DefaultListModel; import javax.swing.Icon; import javax.swing.JLabel; @@ -359,6 +360,8 @@ public abstract class JListControlPane extends JControlPane implements ListContr setLayout(new BorderLayout()); this.textLabel = new JLabel(); this.iconLabel = new JLabel(); + this.textLabel.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 1)); + this.iconLabel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 0)); add(this.textLabel, BorderLayout.CENTER); add(this.iconLabel, BorderLayout.WEST); this.iconLabel.setBackground(Color.WHITE); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 76abb74455..00906a3117 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe; import com.fr.base.Parameter; import com.fr.base.TRL; import com.fr.base.extension.FileExtension; +import com.fr.base.info.TemplateSaveInfoContext; import com.fr.base.io.BaseBook; import com.fr.base.iofile.attr.DesignBanCopyAttrMark; import com.fr.base.iofile.attr.TemplateIdAttrMark; @@ -877,7 +878,10 @@ public abstract class JTemplate> return saveAsTemplate(isShowLoc); } collectInfo(); - return this.saveFile(); + TemplateSaveInfoContext.getInstance().startCollect(template); + boolean result = this.saveFile(); + TemplateSaveInfoContext.getInstance().stopCollect(result); + return result; } private boolean isCancelOperation(int operation) { @@ -966,7 +970,9 @@ public abstract class JTemplate> generateNewTemplateIdForSaveAs(); this.editingFILE = editingFILE; + TemplateSaveInfoContext.getInstance().startCollect(template); boolean result = this.saveToNewFile(oldName); + TemplateSaveInfoContext.getInstance().stopCollect(result); if (result) { DesignerFrameFileDealerPane.getInstance().refresh(); collectInfoWhenSaveAs(originID); @@ -1120,7 +1126,6 @@ public abstract class JTemplate> //查找替换 tplMenu.addShortCut(new NameSeparator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Replace_Name_Separate"))); tplMenu.addShortCut((ShortCut) DesignModuleFactory.getITReplaceAction()); - return new MenuDef[]{tplMenu}; } @@ -1781,6 +1786,8 @@ public abstract class JTemplate> CallbackSaveWorker worker = new CallbackSaveWorker(new Callable() { @Override public Boolean call() throws Exception { + TemplateSaveInfoContext.getInstance().startRecord(); + TemplateSaveInfoContext.getInstance().collectInfo(template.suffix()); return saveAs(finalEditingFILE, sourceFile, oldName); } }, this); @@ -1884,6 +1891,8 @@ public abstract class JTemplate> CallbackSaveWorker worker = new CallbackSaveWorker(new Callable() { @Override public Boolean call() throws Exception { + TemplateSaveInfoContext.getInstance().startRecord(); + TemplateSaveInfoContext.getInstance().collectInfo(template.suffix()); return saveRealFileByWorker(); } }, this); @@ -1942,6 +1951,13 @@ public abstract class JTemplate> @Override public void saveDirectly() { + if (isSaving()) { + // 处理连按ctrl+s触发多线程保存的问题 + // 这里为什么可以不用加锁而直接判断isSaving: + // 实测actionPerformed有线程安全的特性,同一时间只有一个AWT线程走到这里,setSaving是线程安全的(SaveTemplateAction.actionPerformed) + // 多线程场景是因为我们用了SwingWorker子线程处理保存 + return; + } new SaveTypeWorker(getSaveTypeCallable(), this) { @Override protected void done() { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java index 7c19278c20..e8b726b2d6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java @@ -7,6 +7,7 @@ import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.mainframe.burying.point.AbstractPointCollector; import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; @@ -184,33 +185,44 @@ public class ChartInfoCollector extends AbstractPointCollector { */ @Override public void collectInfo(String templateId, String originID, TemplateProcessInfo processInfo, int timeConsume) { - if (!shouldCollectInfo()) { - return; - } - if (StringUtils.isEmpty(originID)) { - originID = templateId; - } - boolean testTemplate = isTestTemplate(processInfo); + // 捕获RuntimeException,不中断保存模板核心逻辑,避免出现保存失败弹窗 + try { + if (!shouldCollectInfo()) { + return; + } + if (StringUtils.isEmpty(originID)) { + originID = templateId; + } + boolean testTemplate = isTestTemplate(processInfo); - for (ChartInfo chartInfo : pointInfoMap.values()) { - if (originID.equals(chartInfo.getTemplateId())) { - chartInfo.setTemplateId(templateId); - chartInfo.setTestTemplate(testTemplate); + for (ChartInfo chartInfo : pointInfoMap.values()) { + if (chartInfo != null && originID.equals(chartInfo.getTemplateId())) { + chartInfo.setTemplateId(templateId); + chartInfo.setTestTemplate(testTemplate); + } } - } - for (ChartInfo chartInfo : chartInfoCacheMap.values()) { - BaseBook book = chartInfo.getBook(); - if ((book != null && templateId.equals(book.getTemplateID())) || - originID.equals(chartInfo.getTemplateId())) { - chartInfo.setTemplateId(templateId); - chartInfo.setTestTemplate(testTemplate); - pointInfoMap.put(chartInfo.getChartId(), chartInfo); + for (ChartInfo chartInfo : chartInfoCacheMap.values()) { + if (chartInfo == null) { + continue; + } + BaseBook book = chartInfo.getBook(); + if (accept(templateId, originID, chartInfo, book)) { + chartInfo.setTemplateId(templateId); + chartInfo.setTestTemplate(testTemplate); + pointInfoMap.put(chartInfo.getChartId(), chartInfo); + } } + // 每次更新之后,都同步到暂存文件中 + saveInfo(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } + } - // 每次更新之后,都同步到暂存文件中 - saveInfo(); + private static boolean accept(String templateId, String originID, ChartInfo chartInfo, BaseBook book) { + return (book != null && templateId.equals(book.getTemplateID())) || + originID.equals(chartInfo.getTemplateId()); } private boolean isTestTemplate(TemplateProcessInfo processInfo) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java index 99950edae7..8cef0d5afa 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java @@ -33,6 +33,10 @@ public class ErrorInfo { private String log; private String stackTrace; + private boolean starting; + + private boolean remote; + public ErrorInfo(String username, String uuid, String activekey) { this.username = username; this.uuid = uuid; @@ -51,6 +55,22 @@ public class ErrorInfo { this.username = username; } + public boolean isStarting() { + return starting; + } + + public void setStarting(boolean starting) { + this.starting = starting; + } + + public boolean isRemote() { + return remote; + } + + public void setRemote(boolean remote) { + this.remote = remote; + } + public String getUuid() { return uuid; } @@ -126,6 +146,8 @@ public class ErrorInfo { jo.put("logid", logid); jo.put("log", log); jo.put("stacktrace", stackTrace); + jo.put("starting", starting); + jo.put("remote", remote); saveFileToCache(jo); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java index ca3fd13ccc..03e3694814 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java @@ -1,9 +1,15 @@ package com.fr.design.mainframe.messagecollect; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.errorinfo.ErrorInfo; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; +import com.fr.start.common.DesignerStartupContext; +import com.fr.workspace.WorkContext; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * @@ -15,9 +21,11 @@ public class StartErrorMessageCollector { private static final StartErrorMessageCollector INSTANCE = new StartErrorMessageCollector(); + private ExecutorService executorService = Executors.newSingleThreadExecutor(new NamedThreadFactory(StartErrorMessageCollector.this.getClass())); private String uuid; private String activeKey; + private boolean extraJudgeStart = false; public static StartErrorMessageCollector getInstance() { return INSTANCE; @@ -35,10 +43,29 @@ public class StartErrorMessageCollector { errorInfo.setLogid(id); errorInfo.setLog(msg); errorInfo.setStackTrace(detail); + errorInfo.setStarting(DesignerStartupContext.getInstance().isOnStartup() || extraJudgeStart); + errorInfo.setRemote(!WorkContext.getCurrent().isLocal()); errorInfo.saveAsJSON(); } + /** + * 异步记录 + */ + public void asyncRecord(String id, String msg, String detail) { + executorService.submit(() -> { + record(id, msg, detail); + StartErrorMessageCollector.getInstance().setExtraJudgeStart(false); + }); + } + public void record(String id, String msg) { record(id, msg, StringUtils.EMPTY); } + + public void setExtraJudgeStart(boolean extraJudgeStart) { + this.extraJudgeStart = extraJudgeStart; + } + + + } diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index bfba512a20..fb8e419fbe 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -27,7 +27,6 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.bridge.ObjectHolder; import com.fr.stable.os.OperatingSystem; -import com.fr.stable.plugin.ExtraDesignClassManagerProvider; import com.fr.start.ServerStarter; import com.fr.start.common.DesignerStartupContext; import com.fr.start.common.DesignerStartupUtil; @@ -238,7 +237,7 @@ public class DesignUtils { DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f)); } }); - } else { + } else if (DeepLinkCore.getInstance().accept(line)) { String url = line; UIUtil.invokeLaterIfNeeded(new Runnable() { @Override diff --git a/designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java b/designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java index ed2597f1d7..b7a50a3af1 100644 --- a/designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java @@ -1,5 +1,6 @@ package com.fr.design.worker.save; +import com.fr.base.info.TemplateSaveInfoContext; import com.fr.common.util.Collections; import com.fr.design.mainframe.JTemplate; import java.util.LinkedList; @@ -34,6 +35,8 @@ public class CallbackSaveWorker extends SaveWorker { } successRunnableList = null; failRunnableList = null; + TemplateSaveInfoContext.getInstance().stopRecord(); + TemplateSaveInfoContext.getInstance().setSaveCompleted(success); } private void fireRunnable(List list) { 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 5ed94d82eb..4114420e10 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 @@ -39,6 +39,11 @@ public class DesignerStartupModel { * mode:模式,0-有设计器起动页;1-无设计器起始页 */ private int mode; + + /** + * jdkVersion:JDK版本 + */ + private String jdkVersion; public DesignerStartupModel() { } @@ -73,7 +78,15 @@ public class DesignerStartupModel { public void setInfo(MachineInfo info) { this.info = info; } - + + public String getJdkVersion() { + return jdkVersion; + } + + public void setJdkVersion(String jdkVersion) { + this.jdkVersion = jdkVersion; + } + public int getMode() { return mode; } @@ -83,7 +96,7 @@ public class DesignerStartupModel { } private void fillInfo() { - + this.setJdkVersion(System.getProperty("java.runtime.version")); MachineInfo info = new MachineInfo(); AbstractOperatingSystem operatingSystem = OperatingSystem.getOperatingSystem(); info.setSystem(operatingSystem.getDisplayString()); diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java index 43d2fd9709..a2d9965e50 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java @@ -1,6 +1,7 @@ package com.fr.startup.ui; import com.fr.base.svg.IconUtils; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.UIExpandDialog; import com.fr.design.gui.icontainer.UIScrollPane; @@ -8,6 +9,8 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.VerticalFlowLayout; +import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector; +import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.ColorUtils; import com.fr.design.utils.ThemeUtils; @@ -49,6 +52,8 @@ import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import java.util.List; import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * 启动页 @@ -253,6 +258,7 @@ public class StartupPageWindow extends JFrame { try { Void result = get(); setVisible(false); + StartErrorMessageCollector.getInstance().setExtraJudgeStart(false); } catch (Exception e) { // 处理错误 UIUtil.invokeLaterIfNeeded(() -> { @@ -269,6 +275,9 @@ public class StartupPageWindow extends JFrame { setEnabled(true); }); FineLoggerFactory.getLogger().error(e.getMessage(), e); + StartErrorMessageCollector.getInstance().asyncRecord(DesignerErrorMessage.UNEXCEPTED_START_FAILED.getId(), + DesignerErrorMessage.UNEXCEPTED_START_FAILED.getMessage(), + e.getMessage()); } finally { loadingPanel.hide(); } diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties index 5098bc3c97..bf7aba4f40 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties @@ -25,3 +25,5 @@ com.fr.design.plugin.remind.PluginInvalidateRemindDialog.centerPane=580*369 com.fr.design.report.WatermarkSettingPane=720*600 com.fr.design.file.MultiTemplateTabPane.popUpMenu=350*65 com.fr.design.data.datapane.preview.desensitization.view.rule.DesensitizationRuleChoosePane.ruleEditPane=800*600 +com.fr.design.formula.FormulaPane=900*600 +com.fr.design.formula.FormulaPaneWhenReserveFormula=1200*600 diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties index 6c3ac0e58c..d070015063 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties @@ -24,3 +24,5 @@ com.fr.design.plugin.remind.PluginInvalidateRemindDialog.centerPane=580*369 com.fr.design.report.WatermarkSettingPane=720*600 com.fr.design.file.MultiTemplateTabPane.popUpMenu=240*65 com.fr.design.data.datapane.preview.desensitization.view.rule.DesensitizationRuleChoosePane.ruleEditPane=800*600 +com.fr.design.formula.FormulaPane=900*600 +com.fr.design.formula.FormulaPaneWhenReserveFormula=900*600 diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties index eaa75e14a0..3fd1ffcad1 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties @@ -24,3 +24,5 @@ com.fr.design.plugin.remind.PluginInvalidateRemindDialog.centerPane=580*369 com.fr.design.report.WatermarkSettingPane=720*600 com.fr.design.file.MultiTemplateTabPane.popUpMenu=240*65 com.fr.design.data.datapane.preview.desensitization.view.rule.DesensitizationRuleChoosePane.ruleEditPane=800*600 +com.fr.design.formula.FormulaPane=900*600 +com.fr.design.formula.FormulaPaneWhenReserveFormula=900*600 diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties index d1e84b4618..2a10d13c7f 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties @@ -24,3 +24,5 @@ com.fr.design.plugin.remind.PluginInvalidateRemindDialog.dialog=600*500 com.fr.design.plugin.remind.PluginInvalidateRemindDialog.centerPane=580*369 com.fr.design.report.WatermarkSettingPane=720*600 com.fr.design.file.MultiTemplateTabPane.popUpMenu=170*65 +com.fr.design.formula.FormulaPane=900*600 +com.fr.design.formula.FormulaPaneWhenReserveFormula=900*600 diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties index 82f86a3a43..faa620cfc8 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties @@ -23,3 +23,5 @@ com.fr.design.plugin.remind.PluginInvalidateRemindDialog.dialog=600*500 com.fr.design.plugin.remind.PluginInvalidateRemindDialog.centerPane=580*369 com.fr.design.report.WatermarkSettingPane=720*600 com.fr.design.file.MultiTemplateTabPane.popUpMenu=170*65 +com.fr.design.formula.FormulaPane=900*600 +com.fr.design.formula.FormulaPaneWhenReserveFormula=900*600 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java index 615ee2a96b..bee247d8dd 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java @@ -57,6 +57,10 @@ public class InformationCollector implements XMLReadable, XMLWriter { */ private static final long DELTA = 24 * 3600 * 1000L; private static final long SEND_DELAY = 300 * 1000L; + /** + * 10分钟后再收集信息 + */ + private static final long SEND_DELAY_4_ERROR_INFO = 300 * 1000L * 2; private static final String FILE_NAME = "fr.info"; private static final String XML_START_STOP_LIST = "StartStopList"; private static final String XML_START_STOP = "StartStop"; @@ -64,6 +68,8 @@ public class InformationCollector implements XMLReadable, XMLWriter { private static final String ATTR_START = "start"; private static final String ATTR_STOP = "stop"; + private static final String THREAD_NAME = "ErrorInfoCollector"; + private static InformationCollector collector; /** @@ -143,9 +149,22 @@ public class InformationCollector implements XMLReadable, XMLWriter { */ public void collectStartTime() { this.current.setStartDate(dateToString()); + dealWithErrorInfo(); sendInfo(); } + private void dealWithErrorInfo() { + ScheduledExecutorService service = Executors + .newSingleThreadScheduledExecutor(new NamedThreadFactory(THREAD_NAME)); + service.schedule(() -> { + ErrorInfoUploader.getInstance().dealErrorInfo(false); + }, SEND_DELAY_4_ERROR_INFO, TimeUnit.MILLISECONDS); + service.shutdown(); + } + + /** + * 目前来看这些数据好像没啥用了,但是还是先留着吧,单独把错误信息拿出来用云端运维统一提交 + */ private void sendInfo() { if (!DesignerEnvManager.getEnvManager().isJoinProductImprove() || !FRContext.isChineseEnv()) { return; @@ -157,7 +176,6 @@ public class InformationCollector implements XMLReadable, XMLWriter { SolidCollector.getInstance().sendToCloudCenterAndDeleteFile(); FocusPointMessageUploader.getInstance().sendToCloudCenter(); ChartInfoCollector.getInstance().sendPointInfo(); - ErrorInfoUploader.getInstance().sendErrorInfo(); sendInfoSuccessCallback(); }, SEND_DELAY, TimeUnit.MILLISECONDS); service.shutdown(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java index 73ecf610d1..0a817b89ba 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java @@ -20,9 +20,10 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -37,6 +38,8 @@ public class ErrorInfoUploader { public static final String SUFFIX = ".json"; public static final String FOLDER_NAME = "errorInfo"; + private static final String CLOUD_KEY = "design.error"; + private static ErrorInfoUploader collector; // 在一台不能上网的电脑里发现了10w个errorinfo... private static final int MAX_ERROR_SIZE = 2000; @@ -148,6 +151,15 @@ public class ErrorInfoUploader { // 判断更新解决方案缓存. checkUpdateSolution(); + dealErrorInfo(true); + } + + /** + * 处理错误信息 + * + * @param needSend2Cloud 是否需要上传到云中心 + */ + public void dealErrorInfo(boolean needSend2Cloud) { //读取文件夹里的json, 加入上传队列中. File folder = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FOLDER_NAME)); if (!folder.exists()) { @@ -164,41 +176,65 @@ public class ErrorInfoUploader { } try { - if (ArrayUtils.isNotEmpty(files)) { - JSONArray jsonArray = new JSONArray(); - List tempFiles = new ArrayList<>(); - int count = 0; - for (File file : files) { - count++; - String filePath = file.getPath(); - String suffix = filePath.substring(filePath.lastIndexOf(".")); - - if (suffix.endsWith(SUFFIX)) { - String content = IOUtils.inputStream2String(new FileInputStream(file)); - if (content.length() > MAX_ERROR_SIZE) { - CommonIOUtils.deleteFile(file); - continue; - } - jsonArray.put(new JSONObject(content)); - tempFiles.add(file); - if (jsonArray.length() == MAX_ITEMS || count == files.length) { - String url = CloudCenter.getInstance().acquireUrlByKind("design.error"); - if (StringUtils.isBlank(url)) { - return; - } - if (sendErrorInfo(url, jsonArray)) { - deleteFiles(tempFiles); - } - jsonArray = new JSONArray(); - } + dealFiles(files, needSend2Cloud); + } catch (Exception ignore) { + + } + } + + private void dealFiles(File[] files, boolean needSend2Cloud) throws IOException { + if (ArrayUtils.isNotEmpty(files)) { + JSONArray jsonArray = new JSONArray(); + List tempFiles = new ArrayList<>(); + int count = 0; + for (File file : files) { + count++; + String filePath = file.getPath(); + String suffix = filePath.substring(filePath.lastIndexOf(".")); + + if (suffix.endsWith(SUFFIX)) { + String content = IOUtils.inputStream2String(Files.newInputStream(file.toPath())); + if (content.length() > MAX_ERROR_SIZE) { + CommonIOUtils.deleteFile(file); + continue; + } + jsonArray.put(new JSONObject(content)); + tempFiles.add(file); + if (jsonArray.length() == MAX_ITEMS || count == files.length) { + processInfos(jsonArray, needSend2Cloud, tempFiles); } } } - } catch (Exception ignore) { + } + } + private void processInfos(JSONArray jsonArray, boolean needSend2Cloud, List tempFiles) { + if (needSend2Cloud) { + String url = CloudCenter.getInstance().acquireUrlByKind(CLOUD_KEY); + if (StringUtils.isBlank(url)) { + return; + } + if (sendErrorInfo(url, jsonArray)) { + deleteFiles(tempFiles); + } + jsonArray = new JSONArray(); + } else { + sendInfos4AnalysisAndClearFiles(jsonArray, tempFiles); } } + + /** + * 提供给云端运维监听的方法(beforeExecute) + * + * @param jsonArray 要提交的信息 + * @param tempFiles 要删除的文件 + */ + private void sendInfos4AnalysisAndClearFiles(JSONArray jsonArray, List tempFiles) { + deleteFiles(tempFiles); + } + + private void deleteFiles(List files) { for (File file : files) { CommonIOUtils.deleteFile(file); diff --git a/designer-realize/src/main/java/com/fr/design/widget/ui/CheckBoxDefinePane.java b/designer-realize/src/main/java/com/fr/design/widget/ui/CheckBoxDefinePane.java index 4e0a60fde2..5722382f57 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/ui/CheckBoxDefinePane.java +++ b/designer-realize/src/main/java/com/fr/design/widget/ui/CheckBoxDefinePane.java @@ -15,7 +15,6 @@ import com.fr.general.GeneralContext; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; - import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.Component; @@ -30,6 +29,7 @@ public class CheckBoxDefinePane extends AbstractDataModify { protected static double F = TableLayout.FILL; protected static double P = TableLayout.PREFERRED; + public CheckBoxDefinePane() { this.iniComponents(); } @@ -89,8 +89,8 @@ public class CheckBoxDefinePane extends AbstractDataModify { /** * 插入配置项面板 * - * @param index 插入的位置 - * @param pane 配置项面板 + * @param index 插入的位置 + * @param pane 配置项面板 */ protected void insertShortCut(int index, BasicBeanPane pane) { int size = extraPaneList.size(); diff --git a/designer-realize/src/main/java/com/fr/design/widget/ui/btn/FreeButtonDetailPane.java b/designer-realize/src/main/java/com/fr/design/widget/ui/btn/FreeButtonDetailPane.java index c2f0ed4f34..4e8a9d5e99 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/ui/btn/FreeButtonDetailPane.java +++ b/designer-realize/src/main/java/com/fr/design/widget/ui/btn/FreeButtonDetailPane.java @@ -41,5 +41,4 @@ public class FreeButtonDetailPane extends AbstractExtraButtonPane { public Class classType() { return FreeButton.class; } - } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java index 858eca4977..2fd4a532c8 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java @@ -6,10 +6,15 @@ import com.fr.design.file.HistoryTemplateListCache; import com.fr.event.Event; import com.fr.event.Listener; import com.fr.module.Activator; +import com.fr.module.ModuleContext; +import com.fr.module.engine.FineModule; import com.fr.start.server.FineEmbedServer; +import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; +import com.fr.workspace.WorkspaceSwitchProcess; +import java.util.Optional; import java.util.concurrent.ExecutorService; /** @@ -17,6 +22,46 @@ import java.util.concurrent.ExecutorService; */ public class DesignerWorkspaceActivator extends Activator { + private final Listener stopModuleAction = new Listener(Integer.MIN_VALUE) { + + @Override + public void on(Event event, Workspace current) { + + stopSub(EnvBasedModule.class); + recordModuleStop(); + } + + private void recordModuleStop() { + + WorkspaceSwitchProcess process = WorkContext.getSwitcher().getProcess(); + Optional.ofNullable(process) + .ifPresent((e) -> e.recordModuleStopUsed(() -> { + FineModule module = (FineModule) ModuleContext.getModule(EnvBasedModule.class); + return module.profileStop(); + })); + } + }; + + private final Listener startModuleAction = new Listener(Integer.MAX_VALUE) { + + @Override + public void on(Event event, Workspace current) { + + startSub(EnvBasedModule.class); + recordModuleStart(); + } + + private void recordModuleStart() { + + WorkspaceSwitchProcess process = WorkContext.getSwitcher().getProcess(); + Optional.ofNullable(process) + .ifPresent((e) -> e.recordModuleStartUsed(() -> { + FineModule module = (FineModule) ModuleContext.getModule(EnvBasedModule.class); + return module.profile(); + })); + } + }; + @Override public void start() { @@ -29,23 +74,9 @@ public class DesignerWorkspaceActivator extends Activator { private void registerEnvListener() { /*切换环境前,关闭所有相关模块,最后执行*/ - listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(Integer.MIN_VALUE) { - - @Override - public void on(Event event, Workspace current) { - - stopSub(EnvBasedModule.class); - } - }); + listenEvent(WorkspaceEvent.BeforeSwitch, stopModuleAction); /*切换环境后,重新启动所有相关模块,最先执行*/ - listenEvent(WorkspaceEvent.AfterSwitch, new Listener(Integer.MAX_VALUE) { - - @Override - public void on(Event event, Workspace current) { - - startSub(EnvBasedModule.class); - } - }); + listenEvent(WorkspaceEvent.AfterSwitch, startModuleAction); /*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/ listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(Integer.MAX_VALUE) { 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 d861fa052a..836abb6317 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 @@ -2,6 +2,7 @@ package com.fr.start.module.optimized; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector; import com.fr.design.ui.util.UIUtil; import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; @@ -164,6 +165,7 @@ public class DesignerStartupPageActivator extends Activator { UIUtil.invokeLaterIfNeeded(() -> { // 换到 awt 线程中关闭,不然异步会出现问题。 DesignerStartupContext.getInstance().setOnStartup(false); + StartErrorMessageCollector.getInstance().setExtraJudgeStart(true); recordStartupEnd(stopWatch); }); markComplete();