From 7ada3e18e010964529dbba1b79422cf0b3d9f313 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 28 Sep 2021 18:03:10 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-59959=20=E8=AE=BE=E8=AE=A1=E5=99=A8-?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E6=93=8D=E4=BD=9C-11=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E5=88=B6=E4=BD=9C=E7=9A=84=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=EF=BC=8C10=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=89=93=E5=BC=80=EF=BC=9B=E4=BD=86=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E7=9A=8411=E5=81=9A=E7=9A=84=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=EF=BC=8C=E5=B0=9D=E8=AF=95=E7=94=A810=E6=89=93=E5=BC=80?= =?UTF-8?q?=E6=97=B6=E9=83=BD=E4=BC=9A=E6=AD=A3=E5=B8=B8=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E6=89=93=E4=B8=8D=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/DesktopCardPane.java | 5 +-- .../com/fr/design/mainframe/JTemplate.java | 32 ++++++++++++++++--- .../fr/design/mainframe/OpenFailedPane.java | 10 +++++- .../com/fr/design/worker/open/OpenWorker.java | 26 ++++++++++++--- 4 files changed, 62 insertions(+), 11 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java index 0e26ff3de..a2c6efcb2 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java @@ -86,7 +86,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener } else if (jt.isOpening()) { showOpenStatus(); } else if (jt.isOpenFailed()) { - showOpenFailedCover(); + showOpenFailedCover(jt.getTemplateOpenFailedTip()); } else { hideCover(); } @@ -115,7 +115,8 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener layeredPane.moveToFront(loadingPane); } - public void showOpenFailedCover() { + public void showOpenFailedCover(String text) { + failedPane.setFailedTip(text); layeredPane.moveToFront(failedPane); } 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 d4931763c..a4db8e88f 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 @@ -114,6 +114,8 @@ public abstract class JTemplate> private JComponent centerPane; private DesignModelAdapter designModel; private PreviewProvider previewType; + private String templateOpenFailedTip; + /** * 统计模板制作耗时 * @@ -1051,35 +1053,49 @@ public abstract class JTemplate> /** * 判断是否是新版设计器 * + * @param showTipPane 是否需要展示弹窗 * @return 是返回true */ - public boolean isNewDesigner() { + public boolean isNewDesigner(boolean showTipPane) { String xmlDesignerVersion = getTarget().getXMLDesignerVersion(); if (isLowerThanHBB(xmlDesignerVersion)) { String info = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Open-New_Form_Tip"); String moreInfo = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Server_Version_Tip_More_Info"); - new InformationWarnPane(info, moreInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")).show(); + if (showTipPane) { + new InformationWarnPane(info, moreInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")).show(); + } return true; } return false; } + public boolean isNewDesigner() { + return isNewDesigner(true); + } + /** * 是否是就版本设计器 * + * @param showTipPane 是否需要展示弹窗 * @return 是就返回true */ - public boolean isOldDesigner() { + public boolean isOldDesigner(boolean showTipPane) { String xmlDesignerVersion = getTarget().getXMLDesignerVersion(); if (isHigherThanCurrent(xmlDesignerVersion)) { String infor = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_Version_Not_Match", DesignUtils.parseVersion(xmlDesignerVersion)); String moreInfo = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Server_Version_Tip_More_Info"); - new InformationWarnPane(infor, moreInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")).show(); + if (showTipPane) { + new InformationWarnPane(infor, moreInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")).show(); + } return true; } return false; } + public boolean isOldDesigner() { + return isOldDesigner(true); + } + /** * */ @@ -1628,4 +1644,12 @@ public abstract class JTemplate> public String getRuntimeId() { return runtimeId; } + + public String getTemplateOpenFailedTip() { + return templateOpenFailedTip; + } + + public void setTemplateOpenFailedTip(String templateOpenFailedTip) { + this.templateOpenFailedTip = templateOpenFailedTip; + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/OpenFailedPane.java b/designer-base/src/main/java/com/fr/design/mainframe/OpenFailedPane.java index 132569c23..63ab984da 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/OpenFailedPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/OpenFailedPane.java @@ -24,6 +24,7 @@ public class OpenFailedPane extends JPanel { private UILabel label; private MessageWithLink link; + private String defaultFailedText; public OpenFailedPane() { this.setLayout(new LayoutManager() { @@ -83,11 +84,18 @@ public class OpenFailedPane extends JPanel { }); } }; + this.defaultFailedText = link.getText(); link.setBackground(Color.WHITE); this.add(label); this.add(link); } - + public void setFailedTip(String text) { + if (StringUtils.isEmpty(text)) { + this.link.setText(defaultFailedText); + } else { + this.link.setText(text); + } + } } diff --git a/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java b/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java index 819660a99..1c03c6759 100644 --- a/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java @@ -7,12 +7,14 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.JTemplate; +import com.fr.design.utils.DesignUtils; import com.fr.design.worker.WorkerManager; import com.fr.exception.DecryptTemplateException; import com.fr.file.FILE; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; import javax.swing.JOptionPane; import javax.swing.SwingWorker; import javax.swing.UIManager; @@ -51,6 +53,7 @@ public class OpenWorker extends SwingWorker { @Override protected T doInBackground() throws Exception { + TimeUnit.SECONDS.sleep(5); return this.callable.call(); } @@ -61,7 +64,7 @@ public class OpenWorker extends SwingWorker { } catch (CancellationException ignored) { return; } catch (Throwable t) { - processFailed(); + processFailed(StringUtils.EMPTY); Throwable cause = t.getCause(); if (cause instanceof DecryptTemplateException) { FineJOptionPane.showMessageDialog( @@ -91,6 +94,11 @@ public class OpenWorker extends SwingWorker { if (slowly && templateCallable != null) { try { JTemplate book = templateCallable.call(); + if (inValidDesigner(book)) { + String text = Toolkit.i18nText("Fine-Design_Report_Template_Version_Not_Match", DesignUtils.parseVersion(book.getTarget().getDesignerVersion())); + processFailed(text); + return; + } FILE tplFile = book.getEditingFILE(); JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); // 当前tab页是正在打开的模板 @@ -117,11 +125,21 @@ public class OpenWorker extends SwingWorker { WorkerManager.getInstance().removeWorker(taskName); } - private void processFailed() { + private boolean inValidDesigner(JTemplate jt) { + return jt.isOldDesigner(false) || (!jt.isJWorkBook() && jt.isNewDesigner(false)); + } + + private void processFailed(String text) { this.template.setOpenFailed(true); this.template.setOpening(false); - DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showOpenFailedCover(); - DesignerFrameFileDealerPane.getInstance().stateChange(); + JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + // 需要判断当前打开的模板是不是异步执行后失败的模板 是的话立即展示失败后的提示内容 否则只设置下失败的提示内容 + if (ComparatorUtils.equals(currentTemplate.getEditingFILE().getName(), this.template.getName())) { + DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showOpenFailedCover(text); + DesignerFrameFileDealerPane.getInstance().stateChange(); + } else { + this.template.setTemplateOpenFailedTip(text); + } WorkerManager.getInstance().removeWorker(taskName); }