From b421538b5b48f816095f2a4b4659d8685b8326a0 Mon Sep 17 00:00:00 2001 From: roger Date: Tue, 25 Apr 2023 09:57:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-94504=20=E5=85=B3=E9=97=AD=E6=89=80?= =?UTF-8?q?=E6=9C=89=E6=A8=A1=E6=9D=BF=EF=BC=8C=E5=BD=93=E5=89=8D=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E6=98=AF=E5=90=A6=E6=9C=89=E6=9C=AA=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=B2=A1=E6=9C=89=E6=A0=A1=E9=AA=8C=EF=BC=8C?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=86=85=E5=AE=B9=E6=9C=89=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E9=A3=8E=E9=99=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/file/MultiTemplateTabPane.java | 5 ++-- .../fr/design/file/SaveSomeTemplatePane.java | 27 ++++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index 901a12154e..f66743717d 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java @@ -322,8 +322,9 @@ public class MultiTemplateTabPane extends JComponent { @Override public void actionPerformed(ActionEvent e) { - SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); - if (saveSomeTempaltePane.showSavePane()) { + //只有关闭所有模板才需要判断当前模板,关闭左侧、右侧、其他都不需要 + SaveSomeTemplatePane saveSomeTemplatePane = new SaveSomeTemplatePane(option == CloseOption.All); + if (saveSomeTemplatePane.showSavePane(option, false)) { JTemplate[] templates = new JTemplate[openedTemplate.size()]; for (int i = 0; i < openedTemplate.size(); i++) { diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index fa8e3d385d..25df1dd3cc 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -17,6 +17,7 @@ import com.fr.design.mainframe.JTemplate; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -162,8 +163,25 @@ public class SaveSomeTemplatePane extends BasicPane { return showSavePane(false); } + /** + * 显示保存模板提醒面板 + * + * @param judgeJTemplateMustSave 模板是否必须保存 + * @return + */ public boolean showSavePane(boolean judgeJTemplateMustSave) { - populate(judgeJTemplateMustSave); + return showSavePane(null, judgeJTemplateMustSave); + } + + /** + * 显示保存模板提醒面板 + * + * @param option 具体关闭操作 + * @param judgeJTemplateMustSave 模板是否必须保存 + * @return + */ + public boolean showSavePane(@Nullable MultiTemplateTabPane.CloseOption option, boolean judgeJTemplateMustSave) { + populate(option, judgeJTemplateMustSave); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 if (!unSavedTemplate.isEmpty()) { dialog.setVisible(true); @@ -177,11 +195,14 @@ public class SaveSomeTemplatePane extends BasicPane { return HistoryTemplateListPane.getInstance().getHistoryList(); } - public void populate(boolean judgeJTemplateMustSave) { + private void populate(@Nullable MultiTemplateTabPane.CloseOption option, boolean judgeJTemplateMustSave) { java.util.List> opendedTemplate = getOpenedTemplatesToProcess(); JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + int currentIndex = opendedTemplate.indexOf(currentTemplate); for (int i = 0; i < opendedTemplate.size(); i++) { - if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { + //满足关闭条件的才继续判断文件是否发生了改动 + boolean needClose = option == null || option.shouldClose(currentIndex, i); + if (needClose && isneedToAdd(opendedTemplate.get(i), currentTemplate)) { unSavedTemplate.add(opendedTemplate.get(i)); } } From 5c535d46ee6a5836e429b405c2a44a642295c37d Mon Sep 17 00:00:00 2001 From: roger Date: Tue, 25 Apr 2023 16:29:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=94=B9=E4=B8=80=E4=B8=8B=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/file/SaveSomeTemplatePane.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index 25df1dd3cc..e371f6ce2b 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -181,7 +181,7 @@ public class SaveSomeTemplatePane extends BasicPane { * @return */ public boolean showSavePane(@Nullable MultiTemplateTabPane.CloseOption option, boolean judgeJTemplateMustSave) { - populate(option, judgeJTemplateMustSave); + initAndPopulate(option, judgeJTemplateMustSave); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 if (!unSavedTemplate.isEmpty()) { dialog.setVisible(true); @@ -195,7 +195,7 @@ public class SaveSomeTemplatePane extends BasicPane { return HistoryTemplateListPane.getInstance().getHistoryList(); } - private void populate(@Nullable MultiTemplateTabPane.CloseOption option, boolean judgeJTemplateMustSave) { + private void initAndPopulate(@Nullable MultiTemplateTabPane.CloseOption option, boolean judgeJTemplateMustSave) { java.util.List> opendedTemplate = getOpenedTemplatesToProcess(); JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); int currentIndex = opendedTemplate.indexOf(currentTemplate);