From 81a4154c7cf173b66b00d7e879081191180bf023 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 8 Dec 2021 17:43:22 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-62438=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=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=97=A8=E6=A7=9B=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/file/TemplateTreePane.java | 7 +++++-- .../com/fr/design/lock/LockInfoUtils.java | 18 +++++++++++++++++ .../com/fr/design/mainframe/JTemplate.java | 2 +- .../com/fr/design/utils/TemplateUtils.java | 20 ++++++++++++++++--- 4 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/lock/LockInfoUtils.java diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index a9b2beaeb..a5826462e 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -12,6 +12,7 @@ import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.lock.LockInfoUtils; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.lock.LockInfoDialog; @@ -230,13 +231,15 @@ public class TemplateTreePane extends JPanel implements FileOperations { return; } String lock = node.getLock(); - boolean showLockInfo = (lock != null && !lock.equals(node.getUserID())) - || WorkContext.getCurrent().get(LockInfoOperator.class).isTplLocked(selectedFilePath); + boolean showLockInfo = LockInfoUtils.isCompatibleOperator() ? (lock != null && !lock.equals(node.getUserID())) + : WorkContext.getCurrent().get(LockInfoOperator.class).isTplLocked(selectedFilePath); if (showLockInfo) { UserInfo userInfo = WorkContext.getCurrent().get(LockInfoOperator.class).getUserInfo(selectedFilePath); node.setLock(UUID.randomUUID().toString()); LockInfoDialog.show(userInfo); return; + } else { + node.setLock(null); } DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false))); } diff --git a/designer-base/src/main/java/com/fr/design/lock/LockInfoUtils.java b/designer-base/src/main/java/com/fr/design/lock/LockInfoUtils.java new file mode 100644 index 000000000..ce8c493e9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/lock/LockInfoUtils.java @@ -0,0 +1,18 @@ +package com.fr.design.lock; + +import com.fr.report.lock.DefaultLockInfoOperator; +import com.fr.report.lock.LockInfoOperator; +import com.fr.workspace.WorkContext; + +/** + * @author hades + * @version 11.0 + * Created by hades on 2021/12/8 + */ +public class LockInfoUtils { + + public static boolean isCompatibleOperator() { + LockInfoOperator lockInfoOperator = WorkContext.getCurrent().get(LockInfoOperator.class); + return lockInfoOperator instanceof DefaultLockInfoOperator; + } +} 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 21f891f1f..a08febe68 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 @@ -991,7 +991,7 @@ public abstract class JTemplate> throw new UnLockedException(); } // 校验锁定信息是否一致 - if (WorkContext.getCurrent().get(LockInfoOperator.class).isConsistentLock(getEditingFILE().getPath())) { + if (getEditingFILE().exists() && !WorkContext.getCurrent().get(LockInfoOperator.class).isConsistentLock(getEditingFILE().getPath())) { throw new InconsistentLockException(); } return this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(getEditingFILE())); 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 b715ec0b8..38eaab2ba 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 @@ -1,7 +1,8 @@ package com.fr.design.utils; import com.fr.base.extension.FileExtension; -import com.fr.design.file.TemplateTreePane; +import com.fr.base.io.BaseBook; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; @@ -15,6 +16,7 @@ import com.fr.stable.CoreConstants; import com.fr.stable.ProductConstants; import com.fr.workspace.WorkContext; import com.fr.workspace.server.lock.TplOperator; +import java.io.ByteArrayOutputStream; import java.io.OutputStream; import javax.swing.SwingWorker; @@ -58,7 +60,19 @@ public class TemplateUtils { @Override protected Void doInBackground() throws Exception { - byte[] content = WorkContext.getWorkResource().readFully(oldPath); + byte[] content = new byte[0]; + if (!needOpen) { + // 从当前编辑模板中生成备份文件 + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + BaseBook target = template.getTarget(); + if (target != null) { + target.export(outputStream); + content = outputStream.toByteArray(); + } + } else { + content = WorkContext.getWorkResource().readFully(oldPath); + } if (ArrayUtils.isEmpty(content)) { throw new Exception(oldPath + " content is empty" ); } @@ -90,7 +104,7 @@ public class TemplateUtils { DesignerContext.getDesignerFrame().openTemplate(file); } } catch (Exception e) { - SaveFailureHandler.Handler.FullDisk.process(e); + SaveFailureHandler.getInstance().process(e); FineLoggerFactory.getLogger().error(e.getMessage(), e); } }