From 03a8dd09dd24eb727912110c9d1b357a56641673 Mon Sep 17 00:00:00 2001 From: Harrison Date: Wed, 15 Jan 2020 12:56:19 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-25778=20json=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=EF=BC=8C=E8=AE=BE=E8=AE=A1=E5=99=A8=E9=87=8D=E5=90=AF=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E6=B6=88=E5=A4=B1=20=E6=8D=A2=E4=B8=80=E7=A7=8D?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=96=B9=E5=BC=8F=EF=BC=8C=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=90=84=E7=A7=8D?= =?UTF-8?q?=E8=AF=A1=E5=BC=82=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/TableDataTreePane.java | 13 +++++------ .../com/fr/design/mainframe/JTemplate.java | 13 +++++++++++ .../fr/design/mainframe/JTemplateFactory.java | 23 +++++++++++++++++++ 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java index 7c8b1f46b2..531e128484 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java @@ -16,9 +16,9 @@ import com.fr.design.data.tabledata.wrapper.AbstractTableDataWrapper; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.fun.TableDataDefineProvider; -import com.fr.design.dialog.FineJOptionPane; import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; @@ -168,23 +168,22 @@ public class TableDataTreePane extends BasicTableDataTreePane { //如果数据集插件禁用或启用。需要清空当前模板中的缓存 reloadCurrTemplate(); } - + private void reloadCurrTemplate() { JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (accept(jt)) { - HistoryTemplateListCache.getInstance().closeSelectedReport(jt); - DesignerContext.getDesignerFrame().openTemplate(jt.getEditingFILE()); + jt.refreshResource(); } } - + private boolean accept(JTemplate jt) { - + return jt != null && jt.getEditingFILE() != null && jt.getEditingFILE().exists(); } }, new PluginFilter() { @Override public boolean accept(PluginContext pluginContext) { - + return pluginContext.contain(TableDataDefineProvider.XML_TAG); } }); 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 c6da049bd9..97df45c4ae 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 @@ -243,6 +243,19 @@ public abstract class JTemplate> public void judgeSheetAuthority(String roles) { } + + /** + * 刷新内部资源 + */ + public void refreshResource() { + + try { + this.template = JTemplateFactory.asIOFile(this.editingFILE); + setTarget(this.template); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } /** * 刷新容器 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java index c6a6f4a0de..8019cc178a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe; +import com.fr.base.io.BaseBook; import com.fr.file.FILE; import com.fr.stable.CoreConstants; import com.fr.third.javax.annotation.Nonnull; @@ -42,6 +43,28 @@ public final class JTemplateFactory { } return null; } + + public static T asIOFile(@Nonnull FILE file) { + + String fileName = file.getName(); + int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT); + if (indexOfLastDot < 0) { + return null; + } + String fileExtension = fileName.substring(indexOfLastDot + 1); + for (App app : ALL_APP) { + String[] defaultAppExtensions = app.defaultExtensions(); + for (String defaultAppExtension : defaultAppExtensions) { + if (defaultAppExtension.equalsIgnoreCase(fileExtension)) { + BaseBook bb = app.asIOFile(file); + if (bb != null) { + return (T) bb; + } + } + } + } + return null; + } /**