From 2c911b92aa7bbed7a9f685f2b2ad150538d8ea76 Mon Sep 17 00:00:00 2001 From: pengda Date: Thu, 28 Jul 2022 11:52:39 +0800 Subject: [PATCH 01/17] =?UTF-8?q?REPORT-76635=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E5=8F=82=E6=95=B0=E9=BB=98=E8=AE=A4=E5=80=BC=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=E7=BB=84?= =?UTF-8?q?=E5=90=88=E5=9B=BE=E6=9D=A1=E4=BB=B6=E5=B1=9E=E6=80=A7=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E9=94=99=E4=B9=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ColSelectedWithSummaryMethodEditor.java | 27 +++++++++++++++++++ ...anChartCustomPlotConditionAttrTabPane.java | 5 ++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java index 6d7ba7699b..be12d6214a 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java @@ -1,6 +1,10 @@ package com.fr.design.chart.series.SeriesCondition; import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.ChartCommonCondition; +import com.fr.chart.chartattr.Plot; +import com.fr.chart.chartglyph.ConditionAttr; +import com.fr.chart.chartglyph.ConditionCollection; import com.fr.data.DSColumnWithSummaryMethod; import com.fr.data.util.function.AbstractDataFunction; import com.fr.design.chart.ChartDataHelper; @@ -9,8 +13,11 @@ import com.fr.design.editor.editor.Editor; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.type.CustomPlotType; import java.awt.Dimension; +import java.util.List; import javax.swing.DefaultComboBoxModel; public class ColSelectedWithSummaryMethodEditor extends Editor { @@ -88,4 +95,24 @@ public class ColSelectedWithSummaryMethodEditor extends Editor list = ((VanChartCustomPlot) plot).getCustomPlotList(); + VanChartPlot vanChartPlot = list.get(index); + ConditionCollection conditionCollection = vanChartPlot.getConditionCollection(); + ConditionAttr[] conditionAttrs = conditionCollection.getAllConditionAttrList(); + for (ConditionAttr conditionAttr : conditionAttrs) { + if (conditionAttr.getCondition() instanceof ChartCommonCondition) { + ChartCommonCondition chartCommonCondition = (ChartCommonCondition) conditionAttr.getCondition(); + if (chartCommonCondition.getCompare().getValue() instanceof DSColumnWithSummaryMethod) { + DSColumnWithSummaryMethod dsColumnWithSummaryMethod = (DSColumnWithSummaryMethod) chartCommonCondition.getCompare().getValue(); + columnNameComboBoxModel.setSelectedItem(dsColumnWithSummaryMethod.getFieldName()); + summaryMethodComboBoxModel.setSelectedItem(ChartCommonCondition.FORMAT_MAP.get(String.valueOf(dsColumnWithSummaryMethod.getDataFunction().getFormula()))); + return; + } + } + } + } + } + } diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomPlotConditionAttrTabPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomPlotConditionAttrTabPane.java index c9b45162f7..0f23c5050e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomPlotConditionAttrTabPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomPlotConditionAttrTabPane.java @@ -93,9 +93,8 @@ public class VanChartCustomPlotConditionAttrTabPane extends VanChartCustomPlotTa CustomPlotType plotType = CustomPlotFactory.getCustomType(chartPlot); VanChartRichEditorPane.refreshCustomChartTableFieldNames(chart, plotType); ColSelectedWithSummaryMethodEditor.refreshCustomChartTableFieldNames(chart, plotType); - JPanel selectedPane = paneList.get(index); - if (chart != null && chartPlot != null && selectedPane instanceof VanChartConditionAttrPane) { - ((VanChartConditionAttrPane) selectedPane).populateBean(chartPlot); + if (chart != null) { + ColSelectedWithSummaryMethodEditor.update(index, chart.getPlot()); } } } From 366966680d09337a4b4916ffe2debb191a274384 Mon Sep 17 00:00:00 2001 From: Yvan Date: Fri, 29 Jul 2022 11:37:23 +0800 Subject: [PATCH 02/17] =?UTF-8?q?REPORT-75991=20=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=AE=8C=E6=95=B4=E6=80=A7=E6=A0=A1=E9=AA=8C=EF=BC=8C=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E9=93=BE=E6=8E=A5=E5=B8=AE=E5=8A=A9=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=E3=80=91=E5=AE=89=E5=85=A8=E7=B1=BB=E9=9C=80=E6=B1=82?= =?UTF-8?q?=EF=BC=8C=E5=B0=86=E5=8E=9F=E6=9D=A5=E4=BB=85=E5=AF=B9=E5=AE=98?= =?UTF-8?q?=E6=96=B9=E6=8F=92=E4=BB=B6=E5=BC=80=E5=90=AF=E7=9A=84=20?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=AE=8C=E6=95=B4=E6=80=A7=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=EF=BC=8C=E6=89=A9=E5=A4=A7=E5=88=B0=E4=BA=86=20=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E6=8F=92=E4=BB=B6=E3=80=82=E4=BD=86=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E4=B8=8D=E6=98=8E=E7=A1=AE=EF=BC=8C=E5=AF=B9=E4=BA=8E?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BE=A7=E6=B2=A1=E6=9C=89=E9=97=AD=E7=8E=AF?= =?UTF-8?q?=EF=BC=8C=E9=9C=80=E8=A6=81=E6=B7=BB=E5=8A=A0=E5=B8=AE=E5=8A=A9?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E9=93=BE=E6=8E=A5=EF=BC=8C=E5=B8=AE=E5=8A=A9?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B8=85=E6=A5=9A=E5=89=8D=E5=9B=A0=E5=90=8E?= =?UTF-8?q?=E6=9E=9C=E4=B8=8E=E8=A7=A3=E5=86=B3=E6=96=B9=E6=A1=88=E3=80=82?= =?UTF-8?q?=20=E3=80=90=E6=94=B9=E5=8A=A8=E6=96=B9=E6=A1=88=E3=80=911.?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=96=87=E6=A1=88=E5=86=85=E5=AE=B9=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=9B2.=E6=8F=90=E7=A4=BA=E4=B8=AD=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E8=B6=85=E9=93=BE=E6=8E=A5=EF=BC=8C=E5=B0=86=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E8=BF=99=E8=BE=B9=E5=9B=A0=E4=B8=BA"=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=AE=8C=E6=95=B4=E6=80=A7=E6=A0=A1=E9=AA=8C"?= =?UTF-8?q?=E8=80=8C=E5=A4=B1=E8=B4=A5=E7=9A=84=E5=BC=B9=E7=AA=97=E5=8D=95?= =?UTF-8?q?=E7=8B=AC=E5=A4=84=E7=90=86=E4=BA=86=E4=B8=8B=EF=BC=8C=E7=94=B1?= =?UTF-8?q?=E5=8E=9F=E6=9C=AC=E7=9A=84JOptionPane=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BAJEditorPane=20=E3=80=90review=E5=BB=BA=E8=AE=AE?= =?UTF-8?q?=E3=80=91=E5=85=B6=E5=AE=83=E7=9A=84=E5=BC=B9=E7=AA=97=E6=9A=82?= =?UTF-8?q?=E6=97=B6=E6=B2=A1=E6=9C=89=E5=8F=98=E5=8A=A8=E7=9A=84=E9=9C=80?= =?UTF-8?q?=E6=B1=82=EF=BC=8C=E8=B7=9F=E4=BA=A7=E5=93=81=E6=B2=9F=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E4=BA=86=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=BB=A5=E5=90=8E?= =?UTF-8?q?=E6=9C=89=E5=BF=85=E8=A6=81=E7=BB=9F=E4=B8=80=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E5=86=8D=E6=9D=A5=E7=BB=9F=E4=B8=80=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exe/callback/InstallFromDiskCallback.java | 3 +- .../exe/callback/InstallOnlineCallback.java | 3 +- .../exe/callback/UpdateFromDiskCallback.java | 3 +- .../exe/callback/UpdateOnlineCallback.java | 3 +- .../callback/handle/PluginCallBackHelper.java | 70 +++++++++++++++ .../handle/PluginTaskResultErrorDialog.java | 86 +++++++++++++++++++ .../fr/design/standard/system/error_tips.svg | 14 +++ 7 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java create mode 100644 designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginTaskResultErrorDialog.java create mode 100755 designer-base/src/main/resources/com/fr/design/standard/system/error_tips.svg diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java index 92fdd4878a..ea591f3bf4 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java @@ -3,6 +3,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.extra.exe.callback.handle.PluginCallBackHelper; import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; @@ -73,7 +74,7 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { }else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); + PluginCallBackHelper.showErrorMessage(result, pluginInfo); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index 0b1eb33fb9..09c360b4f1 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -4,6 +4,7 @@ import com.fr.design.bridge.exec.JSCallback; import com.fr.design.bridge.exec.JSExecutor; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.extra.exe.callback.handle.PluginCallBackHelper; import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; @@ -63,7 +64,7 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { } else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); + PluginCallBackHelper.showErrorMessage(result, pluginInfo); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java index 21c7871f52..31bf482ebe 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java @@ -3,6 +3,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.extra.exe.callback.handle.PluginCallBackHelper; import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; @@ -72,7 +73,7 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { }else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); + PluginCallBackHelper.showErrorMessage(result, pluginInfo); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java index 8dbad6a541..3469ed1a59 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java @@ -3,6 +3,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.extra.exe.callback.handle.PluginCallBackHelper; import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; @@ -38,7 +39,7 @@ public class UpdateOnlineCallback extends AbstractDealPreTaskCallback { } else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); + PluginCallBackHelper.showErrorMessage(result, pluginInfo); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java new file mode 100644 index 0000000000..fc5f957f63 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java @@ -0,0 +1,70 @@ +package com.fr.design.extra.exe.callback.handle; + +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.dialog.link.MessageWithLink; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.error.PluginErrorCode; +import com.fr.plugin.manage.control.PluginTaskResult; + +/** + * 帮助处理插件操作(安装、更新等)的弹窗 + * @author Yvan + */ +public class PluginCallBackHelper { + + private static final String NEW_LINE_TAG = "
"; + private static final String REFERENCE = Toolkit.i18nText("Fine-Design_Basic_Plugin_File_Validate_Reference"); + private static final String HELP_DOCUMENT_NAME = Toolkit.i18nText("Fine-Design_Basic_Plugin_File_Validate_HELP_DOCUMENT_NAME"); + private static final String CONNECTOR = "-"; + private static final String HELP_DOCUMENT_LINK = Toolkit.i18nText("Fine-Design_Basic_Plugin_File_Validate_HELP_DOCUMENT_LINK"); + + + /** + * 展示插件操作失败后的提示弹窗 + * @param result + * @param pluginInfo + */ + public static void showErrorMessage(PluginTaskResult result, String pluginInfo) { + // 单独处理下插件完整性校验失败的提示 + if (PluginCallBackHelper.needHandleInvalidatePackage(result)) { + MessageWithLink messageWithLink = PluginCallBackHelper.generate4InvalidatePackage(pluginInfo); + PluginTaskResultErrorDialog resultDialog = new PluginTaskResultErrorDialog(null, messageWithLink); + resultDialog.showResult(); + } else { + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); + } + } + + /** + * 判断是否需要处理 插件安装包校验失败 导致的安装失败任务 + * @param result + * @return + */ + private static boolean needHandleInvalidatePackage(PluginTaskResult result) { + return !result.isSuccess() && result.getCode() == PluginErrorCode.InstallPackageValidateFailed; + } + + /** + * 根据插件原始报错信息,构建MessageWithLink + * @param originInfo + * @return + */ + private static MessageWithLink generate4InvalidatePackage(String originInfo) { + + return new MessageWithLink(getSupplementaryMessage(originInfo), HELP_DOCUMENT_NAME, HELP_DOCUMENT_LINK); + } + + /** + * 根据插件原始报错信息,获取增加了补充说明后的信息 + * @param originInfo + * @return + */ + private static String getSupplementaryMessage(String originInfo) { + return new StringBuilder() + .append(originInfo) + .append(NEW_LINE_TAG) + .append(REFERENCE) + .append(CONNECTOR) + .toString(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginTaskResultErrorDialog.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginTaskResultErrorDialog.java new file mode 100644 index 0000000000..da4f432080 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginTaskResultErrorDialog.java @@ -0,0 +1,86 @@ +package com.fr.design.extra.exe.callback.handle; + +import com.fr.base.svg.IconUtils; +import com.fr.design.dialog.link.MessageWithLink; +import com.fr.design.gui.ibutton.UIButton; +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.utils.gui.GUICoreUtils; + +import javax.swing.BorderFactory; +import javax.swing.JDialog; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * 当前仅处理Error提示,之后有需要再扩展 + * @author Yvan + */ +public class PluginTaskResultErrorDialog extends JDialog { + + private static final Dimension LABEL = new Dimension(60, 90); + + private JPanel contentPane; + + private UILabel errorLabel; + + private UIButton confirmButton; + + private MessageWithLink messageWithLink; + + public PluginTaskResultErrorDialog(Frame parent, MessageWithLink messageWithLink) { + super(parent, true); + this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning")); + this.messageWithLink = messageWithLink; + + initContentPane(); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setResizable(false); + this.add(contentPane, BorderLayout.CENTER); + this.setSize(new Dimension( 380, 160)); + GUICoreUtils.centerWindow(this); + } + + /** + * 初始化内容面板 + */ + private void initContentPane() { + this.contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + // error图标 + errorLabel = new UILabel(IconUtils.readIcon("/com/fr/design/standard/system/error_tips.svg")); + errorLabel.setPreferredSize(LABEL); + errorLabel.setBorder(BorderFactory.createEmptyBorder(10, 20, 40, 20)); + // 提示内容 + JPanel messagePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + messagePane.add(errorLabel, BorderLayout.WEST); + messagePane.add(messageWithLink, BorderLayout.CENTER); + messagePane.setBorder(BorderFactory.createEmptyBorder(20, 10, 0, 10)); + this.contentPane.add(messagePane, BorderLayout.CENTER); + // 确定按钮 + confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Button_OK")); + confirmButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + hideResult(); + } + }); + JPanel confirmPane = new JPanel(new VerticalFlowLayout()); + confirmPane.add(confirmButton); + confirmPane.setBorder(BorderFactory.createEmptyBorder(0, 160, 10, 0)); + this.contentPane.add(confirmPane, BorderLayout.SOUTH); + } + + public void showResult() { + this.setVisible(true); + } + + public void hideResult() { + this.setVisible(false); + } +} diff --git a/designer-base/src/main/resources/com/fr/design/standard/system/error_tips.svg b/designer-base/src/main/resources/com/fr/design/standard/system/error_tips.svg new file mode 100755 index 0000000000..900205215b --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/system/error_tips.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + From ccdadb03ba87310e9699e5db77826157dbb3514d Mon Sep 17 00:00:00 2001 From: WeiYanglu Date: Mon, 1 Aug 2022 12:55:33 +0800 Subject: [PATCH 03/17] =?UTF-8?q?REPORT-74376=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=AD=98=E5=82=A8FVS=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 18 +++++ .../simple/SimpleDesignerConfig.java | 70 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 823a551ffe..cec7b921da 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -20,6 +20,7 @@ import com.fr.design.locale.impl.ProductImproveMark; import com.fr.design.login.DesignerLoginType; import com.fr.design.login.config.DesignerLoginConfigManager; import com.fr.design.mainframe.ComponentReuseNotifyUtil; +import com.fr.design.mainframe.simple.SimpleDesignerConfig; import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.notification.SnapChatConfig; @@ -226,6 +227,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private boolean propertiesUsable; + private SimpleDesignerConfig fvsDesignerConfig = SimpleDesignerConfig.getInstance("FvsDesignerConfig"); + /** * DesignerEnvManager. */ @@ -1012,6 +1015,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.designerStartupConfig.setEnabled(enabled); } + public SimpleDesignerConfig getFvsDesignerConfig() { + return fvsDesignerConfig; + } + /** * 返回环境名称迭代器 */ @@ -1863,6 +1870,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { readSnapChatConfig(reader); } else if (name.equals(DesignerLoginConfigManager.XML_TAG)) { readDesignerLoginAttr(reader); + } else if (name.equals(fvsDesignerConfig.getName())) { + readFvsDesignerConfig(reader); } else { readLayout(reader, name); } @@ -2113,6 +2122,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { writeSnapChatConfig(writer); writeComponentReuseNotificationInfo(writer); writeDesignerLoginAttr(writer); + writeFvsDesignerConfig(writer); writer.end(); } @@ -2419,6 +2429,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.designerLoginConfigManager.writeXML(writer); } + private void readFvsDesignerConfig(XMLableReader reader) { + reader.readXMLObject(fvsDesignerConfig); + } + + private void writeFvsDesignerConfig(XMLPrintWriter writer) { + this.fvsDesignerConfig.writeXML(writer); + } + enum XmlHandler { Self; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java b/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java new file mode 100644 index 0000000000..b6e58b9965 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java @@ -0,0 +1,70 @@ +package com.fr.design.mainframe.simple; + +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLable; +import com.fr.stable.xml.XMLableReader; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Wei + * 一个简单属性(字符串)存储类,用于自定义简单属性的存储 + * 如:getInstance("FVSDesignerConfig")可在FineReportEnv.xml中定义一个存储FVS相关配置 + */ +public class SimpleDesignerConfig implements XMLable { + + private static final HashMap configs = new HashMap<>(); + + private SimpleDesignerConfig(String name) { + this.name = name; + } + + public static SimpleDesignerConfig getInstance(String name) { + SimpleDesignerConfig config = configs.get(name); + if(config == null) { + config = new SimpleDesignerConfig(name); + configs.put(name, config); + } + return config; + } + + private String name = ""; + + private final Map content = new HashMap<>(); + + public void addAttr(String key, String value) { + content.put(key, value); + } + + public Map getContent() { + return content; + } + + @Override + public void readXML(XMLableReader reader) { + if (reader.isAttr()) { + content.putAll(reader.getAttrs()); + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + writer.startTAG(name); + content.forEach(writer::attr); + writer.end(); + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} From 3f7f32e086fe62294f47c4380ebc62f6b3c6b05f Mon Sep 17 00:00:00 2001 From: WeiYanglu Date: Mon, 1 Aug 2022 15:46:42 +0800 Subject: [PATCH 04/17] =?UTF-8?q?REPORT-74376=20clone=E4=B8=8Bmap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/simple/SimpleDesignerConfig.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java b/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java index b6e58b9965..37cfbb180b 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java @@ -31,7 +31,7 @@ public class SimpleDesignerConfig implements XMLable { private String name = ""; - private final Map content = new HashMap<>(); + private HashMap content = new HashMap<>(); public void addAttr(String key, String value) { content.put(key, value); @@ -57,7 +57,9 @@ public class SimpleDesignerConfig implements XMLable { @Override public Object clone() throws CloneNotSupportedException { - return super.clone(); + SimpleDesignerConfig cloned = (SimpleDesignerConfig) super.clone(); + cloned.content = new HashMap<>(content); + return cloned; } public String getName() { From 1f1539b84b54d82e327abd168376b5124b21c695 Mon Sep 17 00:00:00 2001 From: Yvan Date: Mon, 1 Aug 2022 18:39:46 +0800 Subject: [PATCH 05/17] =?UTF-8?q?REPORT-77217=20ConnectionProvider-?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B9=8B=E5=90=8E=E6=95=B0=E6=8D=AE=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E4=BF=A1=E6=81=AF=E6=97=A0=E6=B3=95=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91?= =?UTF-8?q?=E4=BA=A7=E7=94=9F=E5=81=87=E4=BF=9D=E5=AD=98=E7=9A=84=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=E6=98=AF=EF=BC=8C=E5=9C=A8=E4=BF=9D=E5=AD=98=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E4=BC=9A=E5=88=A4=E6=96=AD=E7=8E=B0=E6=9C=89?= =?UTF-8?q?=E7=9A=84Connection=E4=B8=8E=E4=BB=A5=E5=89=8D=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E7=9A=84Connection=E6=98=AF=E5=90=A6=E6=9C=89?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E5=B0=B1=E4=BB=A3=E8=A1=A8=E9=9C=80=E8=A6=81=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=80=82=E5=AE=9E=E9=99=85=E4=B8=8A=E6=8F=92=E4=BB=B6=E4=B8=AD?= =?UTF-8?q?=E7=9A=84Connection=E7=9B=B8=E5=85=B3=E7=B1=BB=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=86=99equals=E6=96=B9=E6=B3=95=EF=BC=8C=E7=84=B6?= =?UTF-8?q?=E5=90=8E=E6=96=B0=E6=97=A7Connection=E8=A2=AB=E8=AE=A4?= =?UTF-8?q?=E4=B8=BA=E6=98=AF=E7=9B=B8=E5=90=8C=E4=BA=86=EF=BC=8C=E5=B0=B1?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E8=B5=B0=E5=90=8E=E9=9D=A2=E7=9A=84=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=85=8D=E7=BD=AE=E7=9A=84=E9=80=BB=E8=BE=91=20?= =?UTF-8?q?=E3=80=90=E6=94=B9=E5=8A=A8=E6=96=B9=E6=A1=88=E3=80=91=E6=8B=89?= =?UTF-8?q?rinoux=E3=80=81vito=E3=80=81hugh=E4=B8=80=E8=B5=B7=E6=B2=9F?= =?UTF-8?q?=E9=80=9A=E4=BA=86=E4=B8=8B=E6=96=B9=E6=A1=88=EF=BC=8C=E6=9A=82?= =?UTF-8?q?=E6=97=B6=E4=B8=BB=E4=BB=A3=E7=A0=81=E9=87=8C=E5=81=9A=E4=B8=AA?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=EF=BC=8C=E8=AE=A9=E4=B8=BB=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=86=85=E7=BD=AE=E7=9A=84=E4=B8=A4=E7=A7=8DConnection?= =?UTF-8?q?=E5=8E=BB=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E8=A6=81=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=EF=BC=8C=E5=85=B6=E4=BD=99=E7=9A=84Connection?= =?UTF-8?q?=EF=BC=88=E6=8F=92=E4=BB=B6Connection=EF=BC=89=E9=83=BD?= =?UTF-8?q?=E5=BF=85=E9=A1=BB=E6=9B=B4=E6=96=B0=20=E3=80=90review=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/data/MapCompareUtils.java | 42 ++++++++++++++++++- .../datapane/connect/ConnectionListPane.java | 26 ++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java b/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java index f7492aefcc..331e980834 100644 --- a/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java +++ b/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java @@ -16,6 +16,8 @@ public final class MapCompareUtils { /** * 对比两个map 查找出相比orig,other中有哪些是新增的、删除的或者被修改的,并分别进行处理 * + * 对比时默认用equals方法来判断是否为 EntryEventKind#UPDATED + * * @param orig 原始map * @param other 参考的新map * @param eventHandler 有区别时的事件处理器 @@ -24,12 +26,29 @@ public final class MapCompareUtils { */ public static void contrastMapEntries(@NotNull Map orig, @NotNull Map other, @NotNull EventHandler eventHandler) { + contrastMapEntries(orig, other, eventHandler, UpdateRule.DEFAULT); + } + + /** + * 对比两个map 查找出相比orig,other中有哪些是新增的、删除的或者被修改的,并分别进行处理 + * + * 对比时用自定义的规则来判断是否为 EntryEventKind#UPDATED + * + * @param orig 原始map + * @param other 参考的新map + * @param eventHandler 有区别时的事件处理器 + * @param updateRule 自定义的Update事件判定规则 + * @param + * @param + */ + public static void contrastMapEntries(@NotNull Map orig, @NotNull Map other, @NotNull EventHandler eventHandler, @NotNull UpdateRule updateRule) { + Map copiedOrig = new LinkedHashMap<>(orig); other.forEach((k, v) -> { V existedV = copiedOrig.remove(k); if (existedV != null) { - if (!v.equals(existedV)) { + if (updateRule.needUpdate(existedV, v)) { eventHandler.on(EntryEventKind.UPDATED, k, v); } } else { @@ -41,10 +60,31 @@ public final class MapCompareUtils { } + /** + * 事件处理器,对应比较后的三种结果的事件处理 + * @param + * @param + */ public interface EventHandler { void on(EntryEventKind entryEventKind, K k, V v); } + /** + * 数据被修改(EntryEventKind.UPDATED) 的判定规则 + * @param + * @param + */ + public interface UpdateRule { + + EntryEventKind eventKind = EntryEventKind.UPDATED; + + UpdateRule DEFAULT = new UpdateRule() {}; + + default boolean needUpdate(V origin, V v) { + return !v.equals(origin); + } + } + public enum EntryEventKind { ADDED, REMOVED, diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java index e750fa3488..f9ae5948f5 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -192,6 +192,32 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh default: break; } + }, new MapCompareUtils.UpdateRule() { + @Override + public boolean needUpdate(Connection origin, Connection connection) { + return needUpdate0(origin, connection); + } + + /** + * 是否需要更新处理 + * 1. Connection本身equals为false,代表字段修改 + * 2. 非内置的Connection,即插件提供的Connection + * todo 原本一个equals方法就可以搞定,但是插件里面没有实现equals,结果导致不能正确判断,只能主代码里做兼容,很恶心,先记个todo,以后看有没有办法改掉 + * @param origin + * @param connection + * @return + */ + private boolean needUpdate0(Connection origin, Connection connection) { + return !connection.equals(origin) || !isEmbedConnection(connection); + } + + /** + * 是否是主工程里内置的Connection + * @return + */ + private boolean isEmbedConnection(Connection connection) { + return connection instanceof JDBCDatabaseConnection || connection instanceof JNDIDatabaseConnection; + } }); this.validateConnections(addedOrUpdatedConnections); From 36289f383129d5008e7c6147d0dd7dbf898e08e3 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Wed, 3 Aug 2022 22:26:07 +0800 Subject: [PATCH 06/17] =?UTF-8?q?REPORT-74376=20=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simple/SimpleDesignerConfig.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java b/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java index 37cfbb180b..0f14fef756 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java @@ -1,5 +1,7 @@ package com.fr.design.mainframe.simple; +import com.fr.json.JSONObject; +import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLableReader; @@ -14,7 +16,7 @@ import java.util.Map; */ public class SimpleDesignerConfig implements XMLable { - private static final HashMap configs = new HashMap<>(); + private static final Map configs = new HashMap<>(); private SimpleDesignerConfig(String name) { this.name = name; @@ -22,7 +24,7 @@ public class SimpleDesignerConfig implements XMLable { public static SimpleDesignerConfig getInstance(String name) { SimpleDesignerConfig config = configs.get(name); - if(config == null) { + if (config == null) { config = new SimpleDesignerConfig(name); configs.put(name, config); } @@ -31,42 +33,51 @@ public class SimpleDesignerConfig implements XMLable { private String name = ""; - private HashMap content = new HashMap<>(); + private JSONObject content = new JSONObject(); public void addAttr(String key, String value) { content.put(key, value); } - public Map getContent() { + public JSONObject getContent() { return content; } + public void setContent(JSONObject content) { + this.content = content; + } + + @Override public void readXML(XMLableReader reader) { if (reader.isAttr()) { - content.putAll(reader.getAttrs()); + String rawContent = reader.getAttrAsString("content", null); + if (StringUtils.isNotBlank(rawContent)) { + this.content = new JSONObject(rawContent); + } } } @Override public void writeXML(XMLPrintWriter writer) { writer.startTAG(name); - content.forEach(writer::attr); + if (this.content != null) { + writer.attr("content", this.content.toString()); + } writer.end(); } @Override public Object clone() throws CloneNotSupportedException { SimpleDesignerConfig cloned = (SimpleDesignerConfig) super.clone(); - cloned.content = new HashMap<>(content); + if (this.content != null) { + cloned.content = new JSONObject(this.content.toString()); + } + cloned.name = this.name; return cloned; } public String getName() { return name; } - - public void setName(String name) { - this.name = name; - } } From c09f84a5106b3199aed01293103dca79d9dccda6 Mon Sep 17 00:00:00 2001 From: Harrison Date: Mon, 8 Aug 2022 16:32:14 +0800 Subject: [PATCH 07/17] =?UTF-8?q?REPORT-76079=E3=80=90=E8=BF=AD=E4=BB=A3?= =?UTF-8?q?=E3=80=91=E3=80=90=E8=B5=B7=E5=A7=8B=E9=A1=B5=E3=80=91=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E9=97=AE=E9=A2=98=201.=20=E8=B5=B7=E5=A7=8B=E9=A1=B5?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E7=BC=BA=E5=A4=B1=203.=20=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E5=A4=84=E7=90=86=204.=20=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=205.=20=E6=82=AC=E6=B5=AE=E6=9C=89=E7=82=B9=E8=99=9A=E7=9A=84?= =?UTF-8?q?=E6=95=88=E6=9E=9C=206.=20=E5=8F=AA=E6=98=BE=E7=A4=BA=E5=89=8D?= =?UTF-8?q?=E5=85=AD=E5=BC=A0=E5=8D=B3=E5=8F=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/startup/ui/StartupPageWindow.java | 18 +++++++++- .../startup/ui/StartupPageWorkspacePanel.java | 35 +++++++++++++------ .../fr/startup/ui/StartupPageWindowTest.java | 8 ++--- 3 files changed, 45 insertions(+), 16 deletions(-) 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 fefe6e8eca..40a1cb5544 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 @@ -12,7 +12,9 @@ import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.ColorUtils; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.GeneralUtils; import com.fr.log.FineLoggerFactory; +import com.fr.stable.ProductConstants; import com.fr.stable.collections.CollectionUtils; import org.jetbrains.annotations.NotNull; @@ -135,6 +137,7 @@ public class StartupPageWindow extends JFrame { // Workspace-detail setSize(SCREEN_SIZE); + setDefaultTitle(); repaint(); validate(); @@ -143,6 +146,19 @@ public class StartupPageWindow extends JFrame { GUICoreUtils.centerWindow(this); } + private void setDefaultTitle() { + + StringBuilder sb = new StringBuilder(); + sb.append(ProductConstants.APP_NAME); + sb.append(" "); + sb.append(GeneralUtils.getVersion()); + sb.append(" "); + sb.append(ProductConstants.BRANCH); + sb.append(" "); + sb.append(Toolkit.i18nText("Fine-Design_Startup_Page_Title")); + setTitle(sb.toString()); + } + private void patchUIAction(StartupPageModel pageModel) { Runnable selectAndOpenLastTemplateRunnable = pageModel.getOpenLastTemplateRunnable(); @@ -317,7 +333,7 @@ public class StartupPageWindow extends JFrame { recentOpenGroupPanel.setPreferredSize(new Dimension(GROUP_WIDTH, (int) preferredSize.getHeight())); if (needScroll) { - int scrollHeight = (int) Math.round(itemHeight * RECENT_FILE_LIMIT + ITEM_VERTICAL_GAP * (RECENT_FILE_SCROLL)); + int scrollHeight = (int) Math.round(itemHeight * RECENT_FILE_LIMIT + ITEM_VERTICAL_GAP * (RECENT_FILE_LIMIT)); UIScrollPane scrollPane = new UIScrollPane(recentOpenGroupPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0)); scrollPane.setPreferredSize(new Dimension(GROUP_WIDTH, scrollHeight)); diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java index a22c32b03b..297feaa253 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java @@ -95,12 +95,14 @@ public class StartupPageWorkspacePanel extends JPanel { this.contentPanel = generateLimitContentPanel(partitions); this.add(contentPanel, BorderLayout.NORTH); - this.tailPanel = generateTailPanel(); + if (partitions.size() > 2) { + this.tailPanel = generateTailPanel(); + this.add(tailPanel, BorderLayout.SOUTH); + } this.createNewTemplateRunnable = pageModel.getCreateNewTemplateRunnable(); this.openEmptyTemplateRunnable = pageModel.getOpenEmptyTemplateRunnable(); - this.add(tailPanel, BorderLayout.SOUTH); this.repaint(); } @@ -293,10 +295,8 @@ public class StartupPageWorkspacePanel extends JPanel { int roundOffset = 15; // 画一个圆角 int fixRoundWidth = getWidth() - rectOffset; - int fixRoundHeight = getHeight() - BORDER_THIN; - g2d.drawRoundRect(strokeOffset, strokeOffset, fixRoundWidth, fixRoundHeight, ARC_DIAMETER, ARC_DIAMETER); - // 画一个直角 - g2d.drawRoundRect(getWidth() - roundOffset, strokeOffset, roundOffset - strokeOffset, getHeight() - BORDER_THIN, 0, 0); + int fixRoundHeight = getHeight() - BORDER_THIN * 2; + g2d.drawRoundRect(BORDER_THIN, BORDER_THIN, fixRoundWidth, fixRoundHeight, ARC_DIAMETER, ARC_DIAMETER); g2d.setColor(backColor); @@ -306,8 +306,13 @@ public class StartupPageWorkspacePanel extends JPanel { // 偏左一点的 fixedX int fixedX = getWidth() - roundOffset - BORDER_THIN; // 圆角和直角相交的区域 - int coverWidth = 10; + int coverWidth = 15; g2d.fillRect(fixedX, BORDER_THIN, coverWidth, coverHeight); + + g2d.setColor(borderColor); + g2d.drawLine(getWidth() / 2, BORDER_THIN, getWidth(), BORDER_THIN); + g2d.drawLine(getWidth() / 2, getHeight() - BORDER_THIN, getWidth(), getHeight() - BORDER_THIN); + g2d.drawLine(getWidth() - strokeOffset, BORDER_THIN, getWidth() - strokeOffset, getHeight() - BORDER_THIN); } } }; @@ -335,6 +340,7 @@ public class StartupPageWorkspacePanel extends JPanel { Font font = nameLabel.getFont(); Font newSizeFont = font.deriveFont(font.getStyle(), NAME_LABEL_SIZE); nameLabel.setFont(newSizeFont); + nameLabel.setPreferredSize(PATH_DIMENSION); Color nameForeground = nameLabel.getForeground(); simpleDescPanel.add(nameLabel,BorderLayout.NORTH); @@ -450,12 +456,19 @@ public class StartupPageWorkspacePanel extends JPanel { if (borderColor != null) { g2d.setColor(borderColor); g2d.setStroke(new BasicStroke(BORDER_THIN)); + + int borderOffset = BORDER_THIN * 2; // 画画的笔触需要调整一下 - g2d.drawRoundRect(strokeOffset, strokeOffset, getWidth() - rectOffset, getHeight() - BORDER_THIN, 0, 0); - g2d.drawRoundRect(getWidth() - fixedRoundOffset, strokeOffset, roundOffset - strokeOffset, getHeight() - BORDER_THIN, ARC_DIAMETER, ARC_DIAMETER); + //g2d.drawRoundRect(strokeOffset, strokeOffset, getWidth() - rectOffset, getHeight() - BORDER_THIN, 0, 0); + g2d.drawRoundRect(BORDER_THIN, BORDER_THIN, getWidth() - borderOffset, getHeight() - borderOffset, ARC_DIAMETER, ARC_DIAMETER); g2d.setColor(backColor); - int fillWidth = 11; - g2d.fillRect(getWidth() - fixedRoundOffset - BORDER_THIN, BORDER_THIN, fillWidth, getHeight() - BORDER_THIN * 2); + int fillWidth = 15; + g2d.fillRect(0, 0, fillWidth, getHeight()); + + g2d.setColor(borderColor); + g2d.drawLine(BORDER_THIN, BORDER_THIN, fillWidth, BORDER_THIN); + g2d.drawLine(BORDER_THIN, getHeight() - BORDER_THIN, fillWidth, getHeight() - BORDER_THIN); + g2d.drawLine(BORDER_THIN, BORDER_THIN, BORDER_THIN, getHeight() - BORDER_THIN); } } diff --git a/designer-base/src/test/java/com/fr/startup/ui/StartupPageWindowTest.java b/designer-base/src/test/java/com/fr/startup/ui/StartupPageWindowTest.java index c1d33a66a6..804bb7d3fb 100644 --- a/designer-base/src/test/java/com/fr/startup/ui/StartupPageWindowTest.java +++ b/designer-base/src/test/java/com/fr/startup/ui/StartupPageWindowTest.java @@ -16,13 +16,13 @@ public class StartupPageWindowTest { @Override public void run() { HashMap> recentOpenFileMap = new HashMap<>(); - recentOpenFileMap.put("111", Lists.newArrayList("111.cpt", "222//3333.cpt","333.cpt", "444.cpt", "555.cpt", "666.cpt")); + recentOpenFileMap.put("111", Lists.newArrayList("111.cpt", "222//3333.cpt","333.cpt", "444.cpt", "555.cpt", "666.cpt", "777.cpt")); StartupPageModel model = new StartupPageModel(Stream.of( StartupWorkspaceBean.create("111", "222333344455556663333444555566633334445555666"), StartupWorkspaceBean.create("113", "222"), StartupWorkspaceBean.create("114", "222"), StartupWorkspaceBean.create("115", "222"), StartupWorkspaceBean.create("116", "222"), - StartupWorkspaceBean.create("117", "222"), StartupWorkspaceBean.create("118", "222"), StartupWorkspaceBean.create("119", "222"), - StartupWorkspaceBean.create("121", "222"), StartupWorkspaceBean.create("122", "222"), StartupWorkspaceBean.create("123", "222"), - StartupWorkspaceBean.create("124", "222"), StartupWorkspaceBean.create("125", "222"), StartupWorkspaceBean.create("126", "222") + //StartupWorkspaceBean.create("117", "222"), StartupWorkspaceBean.create("118", "222"), StartupWorkspaceBean.create("119", "222"), + //StartupWorkspaceBean.create("121", "222"), StartupWorkspaceBean.create("122", "222"), StartupWorkspaceBean.create("123", "222"), + StartupWorkspaceBean.create("1245678888888", "222"), StartupWorkspaceBean.create("125", "222"), StartupWorkspaceBean.create("126", "222") ).collect(Collectors.toList()), recentOpenFileMap); StartupPageWindow window = new StartupPageWindow(model); window.setVisible(true); From ec842468f8634e82d5465c65a358bf6dc1723973 Mon Sep 17 00:00:00 2001 From: Harrison Date: Mon, 8 Aug 2022 16:40:34 +0800 Subject: [PATCH 08/17] =?UTF-8?q?REPORT-76040=20=E3=80=90=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E3=80=91=E3=80=90=E8=B5=B7=E5=A7=8B=E9=A1=B5=E3=80=91?= =?UTF-8?q?=E6=89=93=E5=BC=80=E8=B5=B7=E5=A7=8B=E9=A1=B5=E5=86=8D=E5=85=B3?= =?UTF-8?q?=E9=97=AD=EF=BC=8C=E4=B8=8A=E6=AC=A1=E7=9A=84=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E5=BA=94=E8=AF=A5=E6=9D=80=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/startup/ui/StartupPageWindow.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 40a1cb5544..b73d13d9f9 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 @@ -12,6 +12,7 @@ import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.ColorUtils; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.exit.DesignerExiter; import com.fr.general.GeneralUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.ProductConstants; @@ -41,6 +42,8 @@ import java.awt.LayoutManager; import java.awt.RenderingHints; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.util.List; import java.util.Map; @@ -138,6 +141,7 @@ public class StartupPageWindow extends JFrame { // Workspace-detail setSize(SCREEN_SIZE); setDefaultTitle(); + addDefaultListeners(); repaint(); validate(); @@ -146,6 +150,16 @@ public class StartupPageWindow extends JFrame { GUICoreUtils.centerWindow(this); } + private void addDefaultListeners() { + + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + DesignerExiter.getInstance().execute(); + } + }); + } + private void setDefaultTitle() { StringBuilder sb = new StringBuilder(); From 2beab53c22b5d8cd410c4e34230302d701d3c00b Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 9 Aug 2022 09:48:12 +0800 Subject: [PATCH 09/17] =?UTF-8?q?REPORT-76091=20&&=20REPORT-76041=201-?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E5=86=B3=E7=AD=96=E6=8A=A5=E8=A1=A8=202-fvs?= =?UTF-8?q?=20npe=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/DesignTableDataManager.java | 2 +- .../design/file/HistoryTemplateListCache.java | 6 +- .../fr/design/mainframe/DesignerFrame.java | 7 + .../fr/design/mainframe/JNullTemplate.java | 207 ++++++++++++++++++ .../com/fr/design/mainframe/JTemplate.java | 11 +- 5 files changed, 229 insertions(+), 4 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/JNullTemplate.java diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index 468982d96f..a756a544b1 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -188,7 +188,7 @@ public abstract class DesignTableDataManager { public static void addDsChangeListener(ChangeListener l) { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); String key = StringUtils.EMPTY; - if (template != null) { + if (JTemplate.isValid(template)) { key = template.getPath(); } List dsListeners = dsListenersMap.get(key); diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index 296c1f2de5..b21519513c 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -26,7 +26,6 @@ import java.util.HashMap; import java.util.List; import java.util.ListIterator; import java.util.Map; -import java.util.Set; /** * 历史模板缓存 @@ -109,8 +108,11 @@ public class HistoryTemplateListCache implements CallbackEvent { */ public void setCurrentEditingTemplate(JTemplate jt) { this.editingTemplate = jt; + + if (!JTemplate.isValid(jt)) { + return; + } //如果当前历史面板中没有 - if (contains(jt) == -1) { addHistory(); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index da8f28f60d..aa6d4873e3 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -815,6 +815,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta basePane.remove(layout.getLayoutComponent(BorderLayout.EAST)); basePane.add(designerOpenEmptyPanel, BorderLayout.CENTER); + resetToolkitByPlus(ToolBarMenuDock.NULLAVOID); + + // 这里挺恶心的,是为了保证对插件的兼容性适配 + // 不然的话,插件就会 npe + // 见 https://work.fineres.com/browse/REPORT-76091 + HistoryTemplateListCache.getInstance().setCurrentEditingTemplate(JNullTemplate.NULL); + layeredPane.repaint(); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JNullTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JNullTemplate.java new file mode 100644 index 0000000000..d10df810a2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/JNullTemplate.java @@ -0,0 +1,207 @@ +package com.fr.design.mainframe; + +import com.fr.design.DesignModelAdapter; +import com.fr.design.designer.TargetComponent; +import com.fr.design.gui.frpane.HyperlinkGroupPane; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; +import com.fr.design.gui.imenu.UIMenuItem; +import com.fr.design.mainframe.template.info.TemplateProcessInfo; +import com.fr.design.menu.ShortCut; +import com.fr.design.menu.ToolBarDef; + +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JPanel; + +/** + * created by Harrison on 2022/08/09 + **/ +public class JNullTemplate extends JTemplate { + + public static final JTemplate NULL = new JNullTemplate(); + + @Override + public void copy() { + + } + + @Override + public boolean paste() { + return false; + } + + @Override + public boolean cut() { + return false; + } + + @Override + public AuthorityEditPane createAuthorityEditPane() { + return null; + } + + @Override + public JPanel getEastUpPane() { + return null; + } + + @Override + public JPanel getEastDownPane() { + return null; + } + + @Override + public ToolBarDef[] toolbars4Target() { + return new ToolBarDef[0]; + } + + @Override + public JComponent[] toolBarButton4Form() { + return new JComponent[0]; + } + + @Override + public void refreshEastPropertiesPane() { + + } + + @Override + public TargetComponent getCurrentElementCasePane() { + return null; + } + + @Override + public JComponent getCurrentReportComponentPane() { + return null; + } + + @Override + public TemplateProcessInfo getProcessInfo() { + return null; + } + + @Override + public void setJTemplateResolution(int resolution) { + + } + + @Override + public int getJTemplateResolution() { + return 0; + } + + @Override + protected JComponent createCenterPane() { + return null; + } + + @Override + public void removeTemplateSelection() { + + } + + @Override + public void refreshContainer() { + + } + + @Override + public void removeParameterPaneSelection() { + + } + + @Override + public void setScale(int resolution) { + + } + + @Override + public int getScale() { + return 0; + } + + @Override + public int selfAdaptUpdate() { + return 0; + } + + @Override + protected DesignModelAdapter createDesignModel() { + return null; + } + + @Override + public UIMenuItem[] createMenuItem4Preview() { + return new UIMenuItem[0]; + } + + @Override + protected BaseUndoState createUndoState() { + return null; + } + + @Override + protected void applyUndoState(BaseUndoState baseUndoState) { + + } + + @Override + public String suffix() { + return null; + } + + @Override + public ShortCut[] shortcut4TemplateMenu() { + return new ShortCut[0]; + } + + @Override + public ShortCut[] shortCuts4Authority() { + return new ShortCut[0]; + } + + @Override + public boolean isJWorkBook() { + return false; + } + + @Override + public HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + return null; + } + + @Override + public HyperlinkGroupPane getHyperLinkPaneNoPop(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + return null; + } + + @Override + public void setAuthorityMode(boolean isUpMode) { + + } + + @Override + public Icon getIcon() { + return null; + } + + @Override + public String route() { + return null; + } + + @Override + public JPanel[] toolbarPanes4Form() { + return new JPanel[0]; + } + + @Override + public JComponent toolBar4Authority() { + return null; + } + + @Override + public int getToolBarHeight() { + return 0; + } +} 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 eaf4b84bfa..29cfcadbb5 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 @@ -1973,5 +1973,14 @@ public abstract class JTemplate> public void setDesignerUIMode() { DesignerUIModeConfig.getInstance().setAbsoluteMeasureUIMode(); } - + + /** + * 判断当前的模板是否是有效的模板 + * + * @param jt 模板 + * @return 是/否 + */ + public static boolean isValid(JTemplate jt) { + return jt != null && jt != JNullTemplate.NULL; + } } From 2afb8c3d2af2c18c230350a0f0978c6e993b8926 Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 9 Aug 2022 09:57:42 +0800 Subject: [PATCH 10/17] =?UTF-8?q?REPORT-76086=20=E3=80=90=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E3=80=91=E3=80=90=E8=B5=B7=E5=A7=8B=E9=A1=B5=E3=80=91?= =?UTF-8?q?=E5=9C=A8=E8=B5=B7=E5=A7=8B=E9=A1=B5=E4=B8=8D=E5=81=9A=E4=BB=BB?= =?UTF-8?q?=E4=BD=95=E6=93=8D=E4=BD=9C=EF=BC=8C=E4=BC=9A=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E9=A2=84=E6=9C=9F=E5=A4=96=E7=9A=84=E5=90=AF=E5=8A=A8=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=20=E5=9C=A8=E5=AD=90=E8=BF=9B=E7=A8=8B=E7=9A=84?= =?UTF-8?q?=E7=9B=91=E5=90=AC=E4=B8=AD=E5=B1=8F=E8=94=BD=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E9=A1=B5=E7=9A=84=E5=BD=B1=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/start/DesignerSubListener.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/start/DesignerSubListener.java b/designer-realize/src/main/java/com/fr/start/DesignerSubListener.java index 52d364f6cd..50134622da 100644 --- a/designer-realize/src/main/java/com/fr/start/DesignerSubListener.java +++ b/designer-realize/src/main/java/com/fr/start/DesignerSubListener.java @@ -8,6 +8,7 @@ import com.fr.exit.DesignerExiter; import com.fr.process.engine.core.CarryMessageEvent; import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessEngineEvent; +import com.fr.start.common.DesignerStartupContext; /** * @author hades @@ -31,6 +32,10 @@ public class DesignerSubListener { FineProcessContext.getParentPipe().listen(FineProcessEngineEvent.READY, new Listener() { @Override public void on(Event event, Null param) { + // 如果是在起始页的等待过程中 + if (DesignerStartupContext.getInstance().isOnWaiting()) { + return; + } if (DesignerContext.getDesignerFrame() == null || !DesignerContext.getDesignerFrame().isShowing()) { DesignerExiter.getInstance().exitUnexpectedly(() -> { From b02e8fd991e060b30349402a9fdcf5962b0e5341 Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 9 Aug 2022 10:30:29 +0800 Subject: [PATCH 11/17] =?UTF-8?q?REPORT-76098=20=E3=80=90=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E3=80=91=E3=80=90=E8=B5=B7=E5=A7=8B=E9=A1=B5=E3=80=91?= =?UTF-8?q?=E8=B5=B7=E5=A7=8B=E9=A1=B5=E5=92=8C=E7=A9=BA=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E9=85=8D=E7=BD=AE=E9=A1=B9=E5=9D=87=E5=BC=80?= =?UTF-8?q?=E5=90=AF=EF=BC=8C=E7=82=B9=E5=87=BB=E6=9C=80=E8=BF=91=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E6=A8=A1=E6=9D=BF=E5=90=AF=E5=8A=A8=EF=BC=8C?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=89=93=E5=BC=80=E5=AF=B9=E5=BA=94=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=20=E4=BC=98=E5=85=88=E5=88=A4=E6=96=AD=E8=B5=B7?= =?UTF-8?q?=E5=A7=8B=E9=A1=B5=EF=BC=8C=E5=86=8D=E5=88=A4=E6=96=AD=E8=80=81?= =?UTF-8?q?=E7=9A=84=E6=89=93=E5=BC=80=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/start/BaseDesigner.java | 66 ++++++++++++------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/designer-base/src/main/java/com/fr/start/BaseDesigner.java b/designer-base/src/main/java/com/fr/start/BaseDesigner.java index 89c928e2c4..674f38168d 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -38,6 +38,7 @@ import com.fr.workspace.base.WorkspaceStatus; import java.awt.Window; import java.lang.reflect.Method; +import java.util.concurrent.atomic.AtomicBoolean; /** * The main class of Report Designer. @@ -142,7 +143,33 @@ public abstract class BaseDesigner extends ToolBarMenuDock { } private boolean openFile(final DesignerFrame df, boolean isException, FILE file) { - + + AtomicBoolean isExWrapper = new AtomicBoolean(isException); + openTemplate(df, isExWrapper, file); + + if (OperatingSystem.isMacOS()) { + enableFullScreenMode(df); + } + + JTemplate selectedJTemplate = df.getSelectedJTemplate(); + if (selectedJTemplate != null) { + selectedJTemplate.requestGridFocus(); + } + return isExWrapper.get(); + } + + private void openTemplate(DesignerFrame df, AtomicBoolean isException, FILE file) { + + // 如果是起始页启动中 + if (openTemplateOnStartup(df, isException, file)) { + return; + } + + openTemplate0(df, isException, file); + } + + private void openTemplate0(DesignerFrame df, AtomicBoolean isException, FILE file) { + //启动时打开指定文件的接口 DesignerStartOpenFileProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerStartOpenFileProcessor.XML_TAG); // 如果插件没有,且又开启了启动时打开空文件,则使用启动时打开空文件 @@ -154,24 +181,20 @@ public abstract class BaseDesigner extends ToolBarMenuDock { if (f != null) { file = f;//避免null } else { - isException = true;//此时有文件nullpointer异常,执行打开空文件 + isException.set(true);//此时有文件nullpointer异常,执行打开空文件 } } - openTemplate(df, isException, file); - - if (OperatingSystem.isMacOS()) { - enableFullScreenMode(df); - } - - JTemplate selectedJTemplate = df.getSelectedJTemplate(); - if (selectedJTemplate != null) { - selectedJTemplate.requestGridFocus(); + if (file != null && file.exists() && !isException.get()) { + df.openTemplate(file); + } else { + df.addAndActivateJTemplate(); + // 如果没有模板,则需要确认一下 + MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } - return isException; } - private void openTemplate(DesignerFrame df, boolean isException, FILE file) { + private boolean openTemplateOnStartup(DesignerFrame df, AtomicBoolean isException, FILE file) { boolean onStartup = DesignerStartupContext.getInstance().isSupport(); if (onStartup) { @@ -180,27 +203,20 @@ public abstract class BaseDesigner extends ToolBarMenuDock { df.addAndActivateJTemplate(); // 如果没有模板,则需要确认一下 MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - return; + return true; } if (context.isOpenLastFile()) { - if (file != null && file.exists() && !isException) { + if (file != null && file.exists() && !isException.get()) { df.openTemplate(file); - return; + return true; } } if (context.isOpenEmpty()) { df.showEmptyJTemplate(); - return; + return true; } } - - if (file != null && file.exists() && !isException) { - df.openTemplate(file); - } else { - df.addAndActivateJTemplate(); - // 如果没有模板,则需要确认一下 - MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - } + return false; } private void enableFullScreenMode(Window window) { From 90a2f720954c14ea216be646a02fdc9bf4f4acf8 Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 9 Aug 2022 14:33:47 +0800 Subject: [PATCH 12/17] =?UTF-8?q?REPORT-76079=E3=80=90=E8=BF=AD=E4=BB=A3?= =?UTF-8?q?=E3=80=91=E3=80=90=E8=B5=B7=E5=A7=8B=E9=A1=B5=E3=80=91=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E9=97=AE=E9=A2=98=207.=20=E5=B1=95=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E4=B8=8D=E5=A4=9F=E5=B1=85=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/start/common/DesignerOpenEmptyPanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java b/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java index e89598ae27..41ab4edff7 100644 --- a/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java +++ b/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java @@ -68,7 +68,7 @@ public class DesignerOpenEmptyPanel extends JPanel { this.body.add(createIcon, BorderLayout.NORTH); this.body.add(createButtonPanel, BorderLayout.SOUTH); - setLayout(FRGUIPaneFactory.createCenterLayout(this.body)); + setLayout(FRGUIPaneFactory.createCenterLayout(this.body, 0.4d)); ColorUtils.syncBackground(this, Color.WHITE); From 6bb2e7c4caa793e84de2b35427678d199e987ddd Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 9 Aug 2022 14:34:09 +0800 Subject: [PATCH 13/17] =?UTF-8?q?REPORT-76079=E3=80=90=E8=BF=AD=E4=BB=A3?= =?UTF-8?q?=E3=80=91=E3=80=90=E8=B5=B7=E5=A7=8B=E9=A1=B5=E3=80=91=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E9=97=AE=E9=A2=98=207.=20=E5=B1=95=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E4=B8=8D=E5=A4=9F=E5=B1=85=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/layout/FRGUIPaneFactory.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java index 401fae8497..3a2e56d220 100644 --- a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java @@ -152,15 +152,18 @@ public class FRGUIPaneFactory { return new FRGridLayout(nColumn); } + public static LayoutManager createCenterLayout(JComponent centerBody) { + return createCenterLayout(centerBody, 0.3d); + } + /** * 将 centerBody 为中心,创建一个布局 * 注:只有当且仅当有一个组件,且希望组件 上下左右 居中时使用 * @param centerBody 中心组件 * @return 布局方式 */ - public static LayoutManager createCenterLayout(JComponent centerBody) { + public static LayoutManager createCenterLayout(JComponent centerBody, double factor) { - final double yFactor = 0.30; return new LayoutManager() { @Override @@ -186,7 +189,7 @@ public class FRGUIPaneFactory { int bodyWidth = centerBody.getPreferredSize().width; int bodyHeight = centerBody.getPreferredSize().height; int labelX = (width - bodyWidth) / 2; - int labelY = (int) ((height - bodyHeight) * yFactor); + int labelY = (int) ((height - bodyHeight) * factor); centerBody.setBounds(labelX, labelY, bodyWidth, bodyHeight); } From 7c5328b14b13d912f60e0848da189f06bae2c061 Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 9 Aug 2022 14:35:02 +0800 Subject: [PATCH 14/17] =?UTF-8?q?REPORT-76091=20=E3=80=90=E8=BF=AD?= =?UTF-8?q?=E4=BB=A3=E3=80=91=E3=80=90=E8=B5=B7=E5=A7=8B=E9=A1=B5=E3=80=91?= =?UTF-8?q?=E4=B8=8D=E6=89=93=E5=BC=80=E4=BB=BB=E4=BD=95=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E5=90=AF=E5=8A=A8=EF=BC=8C=E4=B8=8D=E8=83=BD=E6=96=B0?= =?UTF-8?q?=E5=BB=BAfvs=20=E5=85=BC=E5=AE=B9=20fvs=20=E7=9A=84=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E5=B9=B6=E4=B8=94=E8=A7=84=E9=81=BF=20npe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/file/HistoryTemplateListCache.java | 2 ++ .../src/main/java/com/fr/design/mainframe/DesignerFrame.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index b21519513c..61093401f2 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -19,6 +19,7 @@ import com.fr.plugin.context.PluginContext; import com.fr.stable.CoreConstants; import com.fr.stable.StringUtils; import com.fr.third.org.apache.commons.io.FilenameUtils; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collections; @@ -98,6 +99,7 @@ public class HistoryTemplateListCache implements CallbackEvent { } + @Nullable public JTemplate getCurrentEditingTemplate() { return this.editingTemplate; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index aa6d4873e3..ec6a982485 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -1088,7 +1088,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jt != null) { + if (JTemplate.isValid(jt)) { DesignerEnvManager.getEnvManager().setLastOpenFile(jt.getEditingFILE().getPath()); } From 85e779da5efe3738a5338777de04d1d15acad41b Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 9 Aug 2022 14:51:05 +0800 Subject: [PATCH 15/17] =?UTF-8?q?REPORT-76057=E3=80=90=E8=BF=AD=E4=BB=A3?= =?UTF-8?q?=E3=80=91=E3=80=90=E8=B5=B7=E5=A7=8B=E9=A1=B5=E3=80=91=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E7=9A=84=E4=B8=80=E7=9B=B4=E9=83=BD=E6=98=AF=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=B7=A5=E4=BD=9C=E7=9B=AE=E5=BD=95=20=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E5=B7=A5=E4=BD=9C=E7=9B=AE=E5=BD=95=E5=89=8D=EF=BC=8C?= =?UTF-8?q?=E5=85=88=E5=B0=86=E7=8E=AF=E5=A2=83=E5=87=86=E5=A4=87=E5=A5=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/startup/ui/StartupPageWorkspacePanel.java | 7 ++++--- .../optimized/DesignerStartupPageActivator.java | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java index 297feaa253..c20f623f8c 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java @@ -223,7 +223,7 @@ public class StartupPageWorkspacePanel extends JPanel { layoutSelectWorkspacePanel(workspaceInfo, workspaceItemDesc); - layoutSelectAndCreatePanel(workspaceItemDesc); + layoutSelectAndCreatePanel(workspaceInfo, workspaceItemDesc); partitionPanel.add(workspaceItemDesc); @@ -378,7 +378,7 @@ public class StartupPageWorkspacePanel extends JPanel { public void mousePressed(MouseEvent e) { int clickCount = e.getClickCount(); - if (clickCount == BORDER_THIN) { + if (clickCount == 2) { pageModel.setSelectWorkspaceInfo(workspaceInfo); openEmptyTemplateRunnable.run(); return; @@ -426,7 +426,7 @@ public class StartupPageWorkspacePanel extends JPanel { workspaceItemDesc.add(selectWorkspacePanel, BorderLayout.WEST); } - private void layoutSelectAndCreatePanel(JPanel workspaceItemDesc) { + private void layoutSelectAndCreatePanel(StartupWorkspaceBean workspaceInfo, JPanel workspaceItemDesc) { // 选择并新建 AtomicReference borderColorRef = new AtomicReference<>(null); @@ -497,6 +497,7 @@ public class StartupPageWorkspacePanel extends JPanel { } @Override public void mousePressed(MouseEvent e) { + pageModel.setSelectWorkspaceInfo(workspaceInfo); createNewTemplateRunnable.run(); } }); 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 12e1e1f7c0..98ff33466d 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 @@ -1,5 +1,6 @@ package com.fr.start.module.optimized; +import com.fr.design.DesignerEnvManager; import com.fr.design.ui.util.UIUtil; import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; @@ -10,6 +11,7 @@ import com.fr.start.util.DesignerStartupPageUtil; import com.fr.start.warmup.DesignerPreWarmTask; import com.fr.startup.ui.StartupPageModel; import com.fr.startup.ui.StartupPageWindow; +import com.fr.startup.ui.StartupWorkspaceBean; import com.fr.third.org.apache.commons.lang3.time.StopWatch; import com.fr.value.NotNullLazyValue; import org.jetbrains.annotations.NotNull; @@ -66,18 +68,21 @@ public class DesignerStartupPageActivator extends Activator { // selectAndOpenLast model.setOpenLastTemplateRunnable(() -> { context.setOpenLastFile(true); + handleModel(model); launchAfterWarmup(warmTask); }); // selectAndOpenEmpty model.setOpenEmptyTemplateRunnable(() -> { context.setOpenEmpty(true); + handleModel(model); launchAfterWarmup(warmTask); }); // selectAndCreateNew model.setCreateNewTemplateRunnable(() -> { context.setCreateNew(true); + handleModel(model); launchAfterWarmup(warmTask); }); @@ -87,6 +92,13 @@ public class DesignerStartupPageActivator extends Activator { }); } + private void handleModel(StartupPageModel model) { + + // 将选中的环境设置为当前环境 + StartupWorkspaceBean selectWorkspaceInfo = model.getSelectWorkspaceInfo(); + DesignerEnvManager.getEnvManager().setCurEnvName(selectWorkspaceInfo.getName()); + } + private void launchAfterWarmup(DesignerPreWarmTask warmTask) { StopWatch stopWatch = StopWatch.createStarted(); From 234b828b4d2d05d77bbac6791ea27851c15f4841 Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 11 Aug 2022 15:12:41 +0800 Subject: [PATCH 16/17] =?UTF-8?q?REPORT-76049=E3=80=90=E8=BF=AD=E4=BB=A3?= =?UTF-8?q?=E3=80=91=E3=80=90=E8=B5=B7=E5=A7=8B=E9=A1=B5=E3=80=91=E4=BA=91?= =?UTF-8?q?=E7=AB=AF=E8=BF=90=E7=BB=B4=E6=8F=92=E4=BB=B6=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=EF=BC=8C=E9=A2=84=E7=83=AD=E8=BF=87=E7=A8=8B=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/DesignerFrame.java | 2 +- .../start/common/DesignerStartupExecutor.java | 10 -------- .../com/fr/startup/ui/StartupPageModel.java | 15 +++++++++++ .../optimized/DesignUpdateActivator.java | 25 +++++++++++++++++++ 4 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 designer-realize/src/main/java/com/fr/start/module/optimized/DesignUpdateActivator.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index ec6a982485..dfd2a20cd0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -696,7 +696,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta username = connection == null ? StringUtils.EMPTY : connection.getUserName(); } defaultTitleSB.append(username).append("@").append(envName).append("[").append(workspace.getDescription()).append("]"); - if (editingTemplate != null) { + if (JTemplate.isValid(editingTemplate)) { String path = editingTemplate.getPath(); if (!editingTemplate.getEditingFILE().exists()) { path = FILEFactory.MEM_PREFIX + path; diff --git a/designer-base/src/main/java/com/fr/start/common/DesignerStartupExecutor.java b/designer-base/src/main/java/com/fr/start/common/DesignerStartupExecutor.java index 1a033e8cd2..b4358f047b 100644 --- a/designer-base/src/main/java/com/fr/start/common/DesignerStartupExecutor.java +++ b/designer-base/src/main/java/com/fr/start/common/DesignerStartupExecutor.java @@ -1,15 +1,10 @@ package com.fr.start.common; -import java.util.ArrayList; -import java.util.List; - /** * created by Harrison on 2022/07/03 **/ public class DesignerStartupExecutor { - private List warmupTasks = new ArrayList<>(); - public void execute(Runnable runnable) { if (!DesignerStartupContext.getInstance().onWarmup()) { @@ -17,11 +12,6 @@ public class DesignerStartupExecutor { } } - public void reset() { - - warmupTasks.clear(); - } - public static DesignerStartupExecutor getInstance() { return DesignerStartupExecutorHolder.INSTANCE; } diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java index 4b82545a01..0f71e4932b 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java @@ -3,10 +3,12 @@ package com.fr.startup.ui; import com.fr.design.DesignerEnvManager; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; +import com.fr.stable.StringUtils; import com.fr.third.guava.collect.Lists; import com.fr.workspace.connect.WorkspaceConnectionInfo; import java.util.ArrayList; +import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -33,6 +35,7 @@ public class StartupPageModel { public static StartupPageModel create() { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); + String curEnvName = envManager.getCurEnvName(); Iterator envNameIterator = envManager.getEnvNameIterator(); List infos = Lists.newArrayList(envNameIterator) .stream() @@ -45,6 +48,18 @@ public class StartupPageModel { return new StartupWorkspaceBean(e, workspaceInfo.getPath(), workspaceInfo.getType()); } }) + .sorted(new Comparator() { + @Override + public int compare(StartupWorkspaceBean o1, StartupWorkspaceBean o2) { + if (StringUtils.equals(curEnvName, o1.getName())) { + return -1; + } + if (StringUtils.equals(curEnvName, o2.getName())) { + return 1; + } + return 0; + } + }) .collect(Collectors.toList()); Map> recentFileMap = new HashMap<>(); for (StartupWorkspaceBean info : infos) { diff --git a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignUpdateActivator.java b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignUpdateActivator.java new file mode 100644 index 0000000000..b6ad5ce2a6 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignUpdateActivator.java @@ -0,0 +1,25 @@ +package com.fr.start.module.optimized; + +import com.fr.start.common.DesignerStartupContext; +import com.fr.update.activator.BasicUpdateActivator; +import com.fr.update.base.FineUpdateUnit; + +/** + * created by Harrison on 2022/08/11 + **/ +public class DesignUpdateActivator extends BasicUpdateActivator { + + @Override + public void start() { + + if (DesignerStartupContext.getInstance().onWarmup()) { + try { + prepare4Start(); + FineUpdateUnit.makeNew(); + } catch (Throwable ignore) { + } + } else { + super.start(); + } + } +} From d896eaca451fa19fbc8284e5de8fee48f5c906ed Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 11 Aug 2022 17:44:51 +0800 Subject: [PATCH 17/17] =?UTF-8?q?=E6=97=A0=20JIRA=20=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=EF=BC=8C=E5=A4=84=E7=90=86=E5=9C=88=E5=A4=8D=E6=9D=82=E5=BA=A6?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/start/BaseDesigner.java | 59 +++++++++++++------ .../com/fr/startup/ui/StartupPageModel.java | 28 +++++---- .../startup/ui/StartupPageWorkspacePanel.java | 9 ++- 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/designer-base/src/main/java/com/fr/start/BaseDesigner.java b/designer-base/src/main/java/com/fr/start/BaseDesigner.java index 674f38168d..68cb616e17 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -169,6 +169,19 @@ public abstract class BaseDesigner extends ToolBarMenuDock { } private void openTemplate0(DesignerFrame df, AtomicBoolean isException, FILE file) { + + file = getExtraFILE(isException, file); + + if (file != null && file.exists() && !isException.get()) { + df.openTemplate(file); + } else { + df.addAndActivateJTemplate(); + // 如果没有模板,则需要确认一下 + MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + } + } + + private FILE getExtraFILE(AtomicBoolean isException, FILE file) { //启动时打开指定文件的接口 DesignerStartOpenFileProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerStartOpenFileProcessor.XML_TAG); @@ -184,14 +197,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { isException.set(true);//此时有文件nullpointer异常,执行打开空文件 } } - - if (file != null && file.exists() && !isException.get()) { - df.openTemplate(file); - } else { - df.addAndActivateJTemplate(); - // 如果没有模板,则需要确认一下 - MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - } + return file; } private boolean openTemplateOnStartup(DesignerFrame df, AtomicBoolean isException, FILE file) { @@ -200,25 +206,40 @@ public abstract class BaseDesigner extends ToolBarMenuDock { if (onStartup) { DesignerStartupContext context = DesignerStartupContext.getInstance(); if (context.isCreateNew()) { - df.addAndActivateJTemplate(); - // 如果没有模板,则需要确认一下 - MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - return true; + return createNewTemplate(df); } - if (context.isOpenLastFile()) { - if (file != null && file.exists() && !isException.get()) { - df.openTemplate(file); - return true; - } + if (isOpenTemplate(isException, file, context)) { + return openTemplate(df, file); } if (context.isOpenEmpty()) { - df.showEmptyJTemplate(); - return true; + return openEmpty(df); } } return false; } + private boolean isOpenTemplate(AtomicBoolean isException, FILE file, DesignerStartupContext context) { + + return context.isOpenLastFile() && file != null && file.exists() && !isException.get(); + } + + private boolean openEmpty(DesignerFrame df) { + df.showEmptyJTemplate(); + return true; + } + + private boolean openTemplate(DesignerFrame df, FILE file) { + df.openTemplate(file); + return true; + } + + private boolean createNewTemplate(DesignerFrame df) { + df.addAndActivateJTemplate(); + // 如果没有模板,则需要确认一下 + MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + return true; + } + private void enableFullScreenMode(Window window) { String className = "com.apple.eawt.FullScreenUtilities"; String methodName = "setWindowCanFullScreen"; diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java index 0f71e4932b..c345c8991d 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java @@ -37,6 +37,8 @@ public class StartupPageModel { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); String curEnvName = envManager.getCurEnvName(); Iterator envNameIterator = envManager.getEnvNameIterator(); + + Comparator startupWorkspaceBeanComparator = convertComparator(curEnvName); List infos = Lists.newArrayList(envNameIterator) .stream() .map((e) -> { @@ -48,18 +50,7 @@ public class StartupPageModel { return new StartupWorkspaceBean(e, workspaceInfo.getPath(), workspaceInfo.getType()); } }) - .sorted(new Comparator() { - @Override - public int compare(StartupWorkspaceBean o1, StartupWorkspaceBean o2) { - if (StringUtils.equals(curEnvName, o1.getName())) { - return -1; - } - if (StringUtils.equals(curEnvName, o2.getName())) { - return 1; - } - return 0; - } - }) + .sorted(startupWorkspaceBeanComparator) .collect(Collectors.toList()); Map> recentFileMap = new HashMap<>(); for (StartupWorkspaceBean info : infos) { @@ -123,4 +114,17 @@ public class StartupPageModel { public void setOpenEmptyTemplateRunnable(Runnable openEmptyTemplateRunnable) { this.openEmptyTemplateRunnable = openEmptyTemplateRunnable; } + + private static Comparator convertComparator(String curEnvName) { + + return (o1, o2) -> { + if (StringUtils.equals(curEnvName, o1.getName())) { + return -1; + } + if (StringUtils.equals(curEnvName, o2.getName())) { + return 1; + } + return 0; + }; + } } diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java index c20f623f8c..5251509d3c 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java @@ -63,7 +63,10 @@ public class StartupPageWorkspacePanel extends JPanel { private static final Dimension PATH_DIMENSION = new Dimension(100, 20); private static final Dimension SELECT_WORKSPACE_DIMENSION = new Dimension(210, 72); private static final Dimension SELECT_CREATE_DIMENSION = new Dimension(60, 72); - public static final int COLUMN_LIMIT = 3; + + private static final int COLUMN_LIMIT = 3; + private static final int DOUBLE_CLICK_COUNT = 2; + public static final int PARTITION_LIMIT = 2; /* model */ @@ -95,7 +98,7 @@ public class StartupPageWorkspacePanel extends JPanel { this.contentPanel = generateLimitContentPanel(partitions); this.add(contentPanel, BorderLayout.NORTH); - if (partitions.size() > 2) { + if (partitions.size() > PARTITION_LIMIT) { this.tailPanel = generateTailPanel(); this.add(tailPanel, BorderLayout.SOUTH); } @@ -378,7 +381,7 @@ public class StartupPageWorkspacePanel extends JPanel { public void mousePressed(MouseEvent e) { int clickCount = e.getClickCount(); - if (clickCount == 2) { + if (clickCount == DOUBLE_CLICK_COUNT) { pageModel.setSelectWorkspaceInfo(workspaceInfo); openEmptyTemplateRunnable.run(); return;