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 3d4e94a120..58c73d24a8 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 @@ -19,8 +19,8 @@ import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; import com.fr.design.mainframe.manager.search.searcher.control.pane.TemplateSearchRemindPane; import com.fr.design.mainframe.vcs.common.VcsHelper; -import com.fr.design.worker.check.CheckLockResult; -import com.fr.design.worker.check.BaseCheckLockWorker; +import com.fr.design.worker.check.TemplateCheckResult; +import com.fr.design.worker.check.BaseCheckWorker; import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; @@ -242,45 +242,53 @@ public class TemplateTreePane extends JPanel implements FileOperations { String reportPath = reportletsTree.getSelectedTemplatePath(); final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath); - BaseCheckLockWorker checkLockWorker = getCheckLockWorker(node, selectedFilePath); + BaseCheckWorker checkLockWorker = getCheckLockWorker(node, selectedFilePath); checkLockWorker.execute(); - CheckLockResult checkLockResult = checkLockWorker.getResult(); + TemplateCheckResult checkLockResult = checkLockWorker.getResult(); processLockResult(checkLockResult, node ,selectedFilePath); } @NotNull - private BaseCheckLockWorker getCheckLockWorker(FileNode node, String selectedFilePath) { + private BaseCheckWorker getCheckLockWorker(FileNode node, String selectedFilePath) { String lock = node.getLock(); - BaseCheckLockWorker checkLockWorker = new BaseCheckLockWorker(() -> { + return new BaseCheckWorker(() -> { boolean showLockInfo = needShowLockInfo(lock, selectedFilePath, node); UserInfo userInfo = null; + FileNodeFILE file = null; + boolean fileEnable = false; if (showLockInfo) { userInfo = WorkContext.getCurrent().get(LockInfoOperator.class).getUserInfo(selectedFilePath); } - return new CheckLockResult(showLockInfo, userInfo); + file = new FileNodeFILE(new FileNode(selectedFilePath, false)); + fileEnable = file.exists(); + return new TemplateCheckResult(showLockInfo, userInfo, file, fileEnable); }) { @Override - public void dealResultWhenSlowly(CheckLockResult result) { + public void dealResultWhenSlowly(TemplateCheckResult result) { processLockResult(result, node, selectedFilePath); } }; - return checkLockWorker; } - private void processLockResult(CheckLockResult checkLockResult, FileNode node, String selectedFilePath) { - if (checkLockResult != null) { - boolean showLockInfo = checkLockResult.isLock(); + private void processLockResult(TemplateCheckResult checkResult, FileNode node, String selectedFilePath) { + if (checkResult != null) { + boolean showLockInfo = checkResult.isLock(); if (showLockInfo) { node.setLock(UUID.randomUUID().toString()); // 对于开发者预览占位锁定 定位到tab中 checkDevelopForBiddenTemplate(selectedFilePath); - LockInfoDialog.show(checkLockResult.getUserInfo()); + LockInfoDialog.show(checkResult.getUserInfo()); DesignerContext.getDesignerFrame().hideCover(); return; } else { node.setLock(null); } - DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false))); + if (!checkResult.isFileEnable()) { + // 文件不可用就弹窗并返回 + DesignerContext.getDesignerFrame().processTplFileNotAvailable(); + return; + } + DesignerContext.getDesignerFrame().openTemplateWithoutCheckFile(checkResult.getFile()); } else { if (!reportletsTree.getSelectedFileNode().isDirectory()) { DesignerContext.getDesignerFrame().showOpenStatusLightly(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index ec5e0dfced..5717f9870e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -1033,16 +1033,35 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta // p:判断一下,如何文件为空或者文件不存在,直接返回. if (tplFile == null || !tplFile.exists()) { - FineJOptionPane.showMessageDialog( - this, - Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), - JOptionPane.INFORMATION_MESSAGE - ); - DesignerFrameFileDealerPane.getInstance().refresh(); + processTplFileNotAvailable(); return; } + openTemplate0(tplFile); + } + + /** + * 处理文件不可用的情况 + */ + public void processTplFileNotAvailable() { + // 如果不可用 + FineJOptionPane.showMessageDialog( + this, + Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + JOptionPane.INFORMATION_MESSAGE + ); + DesignerFrameFileDealerPane.getInstance().refresh(); + } + /** + * 不经过文件校验直接打开模板(需要前面的逻辑已经手动校验过) + */ + public void openTemplateWithoutCheckFile(FILE tplFile) { + openTemplate0(tplFile); + } + + + private void openTemplate0(FILE tplFile) { try { openFile(tplFile); } catch (DecryptTemplateException e) { @@ -1065,9 +1084,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } addAndActivateJTemplate(); } - } - /** * 是否不合版本的设计器 * diff --git a/designer-base/src/main/java/com/fr/design/worker/check/BaseCheckLockWorker.java b/designer-base/src/main/java/com/fr/design/worker/check/BaseCheckWorker.java similarity index 74% rename from designer-base/src/main/java/com/fr/design/worker/check/BaseCheckLockWorker.java rename to designer-base/src/main/java/com/fr/design/worker/check/BaseCheckWorker.java index bf9870a909..425a1e3124 100644 --- a/designer-base/src/main/java/com/fr/design/worker/check/BaseCheckLockWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/check/BaseCheckWorker.java @@ -14,18 +14,18 @@ import java.util.concurrent.TimeoutException; * @since 11.0 * Created on 2024/1/8 */ -public abstract class BaseCheckLockWorker extends SwingWorker { +public abstract class BaseCheckWorker extends SwingWorker { private static final int TIME_OUT = 50; private boolean slowly = false; - private final Callable doInBackground; - private CheckLockResult result; + private final Callable doInBackground; + private TemplateCheckResult result; - public BaseCheckLockWorker(Callable doInBackground) { + public BaseCheckWorker(Callable doInBackground) { this.doInBackground = doInBackground; } @Override - protected CheckLockResult doInBackground() throws Exception { + protected TemplateCheckResult doInBackground() throws Exception { return this.doInBackground.call(); } @@ -44,7 +44,7 @@ public abstract class BaseCheckLockWorker extends SwingWorker