From 20160eae69d617c4f0717903ef6b86eb6d910df3 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 28 Dec 2021 14:42:06 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-65050=20=E8=BF=9C=E7=A8=8B=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E9=94=81=E5=AE=9A=E4=BC=98=E5=8C=96-fvs=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E8=A2=AB=E8=B6=85=E7=AE=A1=E5=9C=A8=E6=9F=90=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E4=B8=8A=E5=BC=BA=E5=88=B6=E8=A7=A3=E9=94=81=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E7=BC=96=E8=BE=91=E8=80=85=E7=82=B9=E5=87=BB=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=97=B6=E4=B8=8D=E4=BC=9A=E8=A7=A6=E5=8F=91=E5=8F=A6?= =?UTF-8?q?=E5=AD=98=E4=B8=BA=E5=BC=B9=E7=AA=97=EF=BC=8C=E8=80=8C=E6=98=AF?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/mainframe/JTemplate.java | 7 ++++++- .../design/worker/save/SaveFailureHandler.java | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) 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 26a2f64bca..499898bbff 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 @@ -967,6 +967,7 @@ public abstract class JTemplate> return false; } try { + checkBeforeSave(); export(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); @@ -985,7 +986,7 @@ public abstract class JTemplate> return isNewCreateTpl; } - protected boolean export() throws Exception { + protected void checkBeforeSave() throws Exception { // 保存前校验下未解锁 if (WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(getEditingFILE().getPath())) { throw new UnLockedException(); @@ -994,6 +995,9 @@ public abstract class JTemplate> if (getEditingFILE().exists() && !WorkContext.getCurrent().get(LockInfoOperator.class).isConsistentLock(getEditingFILE().getPath())) { throw new InconsistentLockException(); } + } + + protected boolean export() throws Exception { return this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(getEditingFILE())); } @@ -1634,6 +1638,7 @@ public abstract class JTemplate> if (editingFILE == null || editingFILE instanceof MemFILE) { return false; } + checkBeforeSave(); export(); this.editingFILE = editingFILE; return true; diff --git a/designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java b/designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java index 4cf2af431a..5d7beb36ae 100644 --- a/designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java +++ b/designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java @@ -6,6 +6,7 @@ import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; +import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.TemplateUtils; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; @@ -31,11 +32,19 @@ public class SaveFailureHandler implements ThrowableHandler { @Override public boolean process(Throwable e) { - for (Handler handler : Handler.values()) { - if (handler.process(e)) { - break; + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + for (Handler handler : Handler.values()) { + try { + if (handler.process(e)) { + break; + } + } catch (Exception ignored) { + } + } } - } + }); return true; }