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 26a2f64bc..499898bbf 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 4cf2af431..5d7beb36a 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; }