From 1a04bcbf92a235300139c77b533141ed3b04aed3 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 8 Jan 2024 16:52:29 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-111337=20=E3=80=90=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E6=80=A7=E8=83=BD=E3=80=91=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E5=8D=A1=E9=A1=BF=E4=BC=98=E5=8C=96=20=E6=89=93=E5=BC=80?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=8A=A8=E7=94=BB=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/file/TemplateTreePane.java | 36 +++++++++------ .../fr/design/mainframe/DesignerFrame.java | 35 +++++++++++---- ...ckLockWorker.java => BaseCheckWorker.java} | 14 +++--- .../design/worker/check/CheckLockResult.java | 30 ------------- .../worker/check/TemplateCheckResult.java | 45 +++++++++++++++++++ 5 files changed, 100 insertions(+), 60 deletions(-) rename designer-base/src/main/java/com/fr/design/worker/check/{BaseCheckLockWorker.java => BaseCheckWorker.java} (74%) delete mode 100644 designer-base/src/main/java/com/fr/design/worker/check/CheckLockResult.java create mode 100644 designer-base/src/main/java/com/fr/design/worker/check/TemplateCheckResult.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 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