From 5188dfc04e0b0ff6ed46fbf8f40509701baa00e5 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 21 Dec 2021 16:15:10 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-64656=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=EF=BC=8C=E5=8F=8C=E5=87=BB=E5=B7=B2=E6=89=93?= =?UTF-8?q?=E5=BC=80=E7=9A=84=E6=A8=A1=E6=9D=BF=EF=BC=8C=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E5=AE=9A=E4=BD=8D=E5=88=B0=E5=AF=B9=E5=BA=94=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/file/HistoryTemplateListCache.java | 6 ++++- .../com/fr/design/file/TemplateTreePane.java | 25 +++++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index 6675925526..920ecb78c8 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -253,7 +253,11 @@ public class HistoryTemplateListCache implements CallbackEvent { for (int i = 0; i < vCount; i++) { JTemplate overTemplate = historyList.get(i); - if (overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) { + boolean replaceWithJVirtualTemplate = overTemplate.getEditingFILE().exists() + && overTemplate.isALLSaved() + && overTemplate != editingTemplate + && overTemplate.checkEnable(); + if (replaceWithJVirtualTemplate) { closeVirtualSelectedReport(overTemplate); historyList.set(i, new JVirtualTemplate(overTemplate.getEditingFILE())); } 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 707309a481..bc5e0da6bd 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 @@ -57,6 +57,8 @@ import java.util.Enumeration; import java.util.Objects; import java.util.Observable; import java.util.Observer; +import org.jetbrains.annotations.Nullable; + import static javax.swing.JOptionPane.WARNING_MESSAGE; import static javax.swing.JOptionPane.YES_NO_OPTION; @@ -226,17 +228,17 @@ public class TemplateTreePane extends JPanel implements FileOperations { } String reportPath = reportletsTree.getSelectedTemplatePath(); final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath); - if (hasOpenedTemplate(selectedFilePath)) { - FineLoggerFactory.getLogger().info("{} has been opened in designer tab", selectedFilePath); - return; - } String lock = node.getLock(); - boolean showLockInfo = LockInfoUtils.isCompatibleOperator() || LockInfoUtils.unableGetLockInfo() + boolean showLockInfo = LockInfoUtils.isCompatibleOperator() + || LockInfoUtils.unableGetLockInfo() + || WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(selectedFilePath) ? (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()); + // 对于开发者预览占位锁定 定位到tab中 + checkDevelopForBiddenTemplate(selectedFilePath); LockInfoDialog.show(userInfo); return; } else { @@ -245,14 +247,21 @@ public class TemplateTreePane extends JPanel implements FileOperations { DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false))); } + private void checkDevelopForBiddenTemplate(String selectedFilePath) { + JTemplate template = getOpenedTemplate(selectedFilePath); + if (template != null && template.isForbidden()) { + DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false))); + } + } - private boolean hasOpenedTemplate(String path) { + @Nullable + private JTemplate getOpenedTemplate(String path) { for (JTemplate template : HistoryTemplateListCache.getInstance().getHistoryList()) { if (ComparatorUtils.equals(template.getEditingFILE().getPath(), path)) { - return true; + return template; } } - return false; + return null; } /**