From 52a7153ff0d45420cad706ba4d90b1a47a3cb945 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 13 Oct 2022 11:22:34 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-81880=20=E4=BC=98=E5=8C=96=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=AE=9A=E4=BD=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/replace/ui/ITTableButton.java | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java index 1a73d3fcb3..40e05e615d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java @@ -6,10 +6,12 @@ import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILE; import com.fr.file.FILEFactory; import com.fr.general.GeneralUtils; import com.fr.stable.StringUtils; -import com.fr.stable.project.ProjectConstants; + import javax.swing.AbstractCellEditor; @@ -44,11 +46,43 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) { ITReplaceMainDialog.setITReplaceFlag(true); TRL trl = new TRL(GeneralUtils.objectToString(content.getTrlString())); - DesignerContext.getDesignerFrame().openTemplate(FILEFactory.createFILE(content.getTemplatePath())); - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl); + FILE tplFile = FILEFactory.createFILE(content.getTemplatePath()); + if (tplFile != null && tplFile.exists()) { + //模板已保存 + navigate2ExistedTemplate(tplFile, trl); + } else { + //模板未保存 + navigate2NotExistedTemplate(content, trl); + } } ITReplaceMainDialog.setITReplaceFlag(false); } + + /** + * 模板未保存的跳转逻辑 + * @param content 存储模板名称的数据结构 + * @param trl 跳转链接 + */ + private void navigate2NotExistedTemplate(ITContent content, TRL trl) { + java.util.List> openTemplates = HistoryTemplateListCache.getInstance().getHistoryList(); + for (int i = 0, len = openTemplates.size(); i < len; i++) { + if (StringUtils.equals(openTemplates.get(i).getTemplateName(), content.getTemplateName())) { + DesignerContext.getDesignerFrame().activateJTemplate(openTemplates.get(i)); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl); + break; + } + } + } + + /** + * 模板已保存的跳转逻辑 + * @param tplFile 模板的FILE文件 + * @param trl 跳转链接 + */ + private void navigate2ExistedTemplate(FILE tplFile, TRL trl) { + DesignerContext.getDesignerFrame().openTemplate(tplFile); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl); + } });