From 92c88eef13efdc9bd63a3256562f9cdccb95121f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Thu, 6 Apr 2023 15:01:35 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-92893=20=E9=94=81=E5=AE=9A=E7=9A=84?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=EF=BC=8C=E9=87=8D=E5=A4=8D=E5=8F=A6=E5=AD=98?= =?UTF-8?q?=E5=89=AF=E6=9C=AC=EF=BC=8C=E8=AE=BE=E8=AE=A1=E5=99=A8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=A8=A1=E6=9D=BF=E5=86=85=E5=AE=B9=E4=B8=8D=E6=9B=B4?= =?UTF-8?q?=E6=96=B0--=E6=96=B9=E6=B3=95=E6=8B=86=E4=B8=A4=E5=8D=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/utils/TemplateUtils.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java b/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java index 11b98883e0..77c9d2eb8e 100644 --- a/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java @@ -130,9 +130,17 @@ public class TemplateUtils { return null; } - private static void createAndOpenTemplate0(FILE file, String oldPath, boolean createByEditingTemplate, boolean openNewTemplate, @Nullable JTemplate template) { - - CompletableFuture createTemplate = CompletableFuture.supplyAsync(() -> { + /** + * 创建新的模板文件并打开模板,并在创建备份模板成功后执行doAfterCreate + * + * @param file saveAs的模板文件 + * @param createByEditingTemplate 是否根据 当前编辑模板 来创建新模板 + * 为true时以CurrentEditingTemplate为准创建新模板 + * 为false时以传入的File文件为准创建新模板,此文件可以不是编辑状态 + * @param oldPath 被saveAs的文件路径 + */ + private static CompletableFuture createTemplate(FILE file, String oldPath, boolean createByEditingTemplate) { + return CompletableFuture.supplyAsync(() -> { try { // 读取模板数据 byte[] content = getTemplateData(createByEditingTemplate, oldPath); @@ -163,8 +171,10 @@ public class TemplateUtils { return false; } }); + } - createTemplate.thenApply((Function) aBoolean -> { + private static void createAndOpenTemplate0(FILE file, String oldPath, boolean createByEditingTemplate, boolean openNewTemplate, @Nullable JTemplate template) { + createTemplate(file, oldPath, createByEditingTemplate).thenApply((Function) aBoolean -> { if (!aBoolean) { //备份失败直接返回 return null;