From 8ff603736dd99190aaa05cdbc436f285db502f10 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 23 Dec 2020 19:20:42 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-44644=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=BC=80=E5=8F=91=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/file/HistoryTemplateListCache.java | 9 +-------- .../fr/design/file/MutilTempalteTabPane.java | 2 +- ...ceOperation.java => TemplateResource.java} | 2 +- ...ager.java => TemplateResourceManager.java} | 19 ++++++++++++------- .../com/fr/design/file/TemplateTreePane.java | 6 +++--- ...ion.java => AbstractTemplateResource.java} | 5 +++-- .../file/impl/DefaultTemplateResource.java | 10 ++++++++++ .../fr/design/fun/LocalResourceProvider.java | 4 ++-- .../com/fr/design/mainframe/JTemplate.java | 4 ++-- .../main/java/com/fr/file/FileNodeFILE.java | 6 +++--- 10 files changed, 38 insertions(+), 29 deletions(-) rename designer-base/src/main/java/com/fr/design/file/{TemplateFileResourceOperation.java => TemplateResource.java} (96%) rename designer-base/src/main/java/com/fr/design/file/{TemplateFileResourceManager.java => TemplateResourceManager.java} (79%) rename designer-base/src/main/java/com/fr/design/file/impl/{DefaultTemplateFileResourceOperation.java => AbstractTemplateResource.java} (90%) create mode 100644 designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index 154caa32be..ba4a88c4c8 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -45,9 +45,6 @@ public class HistoryTemplateListCache implements CallbackEvent { private List> historyList; private JTemplate editingTemplate; - // 插件stop时的已经打开的模板xml byte缓存 插件重新run时 重新加载 - private final Map cacheMap = new LinkedHashMap<>(); - public static HistoryTemplateListCache getInstance() { return Holder.INSTANCE; } @@ -78,11 +75,7 @@ public class HistoryTemplateListCache implements CallbackEvent { selected.fireJTemplateClosed(); selected.stopEditing(); try { - int index = contains(selected); - historyList.remove(index); - if (stashFILEMap != null) { - stashFILEMap.remove(index); - } + historyList.remove(contains(selected)); selected.getEditingFILE().closeTemplate(); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName())); MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index 3ad4c401a1..269918448a 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -705,7 +705,7 @@ public class MutilTempalteTabPane extends JComponent { // 只有是环境内的文件,才执行释放锁 if (file != null && file.isEnvFile()) { // release lock - TemplateFileResourceManager.getOperation().closeTemplate(file.getPath()); + TemplateResourceManager.getResource().closeTemplate(file.getPath()); } } diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java b/designer-base/src/main/java/com/fr/design/file/TemplateResource.java similarity index 96% rename from designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java rename to designer-base/src/main/java/com/fr/design/file/TemplateResource.java index f3e813c92d..f394822d6b 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceOperation.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateResource.java @@ -13,7 +13,7 @@ import java.io.OutputStream; * Created by hades on 2020/12/23 */ @Open -public interface TemplateFileResourceOperation { +public interface TemplateResource { /** * 读取模板 diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceManager.java b/designer-base/src/main/java/com/fr/design/file/TemplateResourceManager.java similarity index 79% rename from designer-base/src/main/java/com/fr/design/file/TemplateFileResourceManager.java rename to designer-base/src/main/java/com/fr/design/file/TemplateResourceManager.java index 7755847324..384b1a3e1e 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateFileResourceManager.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateResourceManager.java @@ -1,7 +1,7 @@ package com.fr.design.file; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.file.impl.DefaultTemplateFileResourceOperation; +import com.fr.design.file.impl.DefaultTemplateResource; import com.fr.design.fun.LocalResourceProvider; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.ui.util.UIUtil; @@ -21,17 +21,19 @@ import com.fr.workspace.engine.base.FineObjectPool; * @version 10.0 * Created by hades on 2020/12/23 */ -public class TemplateFileResourceManager { +public class TemplateResourceManager { - private static TemplateFileResourceOperation OPERATION = new DefaultTemplateFileResourceOperation(); + private static final TemplateResource DEFAULT_OPERATION = new DefaultTemplateResource(); - private TemplateFileResourceManager() { + private static TemplateResource OPERATION = DEFAULT_OPERATION; + + static { PluginFilter filter = pluginContext -> pluginContext.contain(PluginModule.ExtraDesign, LocalResourceProvider.XML_TAG); PluginListenerRegistration.getInstance().listen(PluginEventType.AfterStop, new PluginEventListener() { @Override public void on(PluginEvent event) { - registerOperation(new DefaultTemplateFileResourceOperation()); + registerOperation(new DefaultTemplateResource()); FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, new LocalFileNodes()); UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh()); } @@ -50,11 +52,14 @@ public class TemplateFileResourceManager { }, filter); } - private static void registerOperation(TemplateFileResourceOperation operation) { + private static void registerOperation(TemplateResource operation) { OPERATION = operation; } - public static TemplateFileResourceOperation getOperation() { + public static TemplateResource getResource() { + if (OPERATION == null) { + return DEFAULT_OPERATION; + } return OPERATION; } 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 f54fd8eeb4..0fc3ca7281 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 @@ -193,7 +193,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { @Override public boolean mkdir(String path) { - return TemplateFileResourceManager.getOperation().mkdir(path); + return TemplateResourceManager.getResource().mkdir(path); } /** @@ -336,7 +336,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { if (node instanceof FileNode) { FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node); if (nodeFILE.exists()) { - if (TemplateFileResourceManager.getOperation().delete(nodeFILE)) { + if (TemplateResourceManager.getResource().delete(nodeFILE)) { HistoryTemplateListCache.getInstance().deleteFile(nodeFILE); } else { success = false; @@ -438,7 +438,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { try { // 接收的是WEB-INF下的路径 - return TemplateFileResourceManager.getOperation().rename(from, to); + return TemplateResourceManager.getResource().rename(from, to); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java similarity index 90% rename from designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java rename to designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java index 88a3f85645..acf785dd46 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateFileResourceOperation.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java @@ -1,6 +1,7 @@ package com.fr.design.file.impl; -import com.fr.design.file.TemplateFileResourceOperation; + +import com.fr.design.file.TemplateResource; import com.fr.file.FILE; import com.fr.workspace.WorkContext; import com.fr.workspace.server.lock.TplOperator; @@ -13,7 +14,7 @@ import java.io.OutputStream; * @version 10.0 * Created by hades on 2020/12/23 */ -public class DefaultTemplateFileResourceOperation implements TemplateFileResourceOperation { +public class AbstractTemplateResource implements TemplateResource { @Override public InputStream readTemplate(String path) throws Exception { diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java new file mode 100644 index 0000000000..125f1a9f31 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java @@ -0,0 +1,10 @@ +package com.fr.design.file.impl; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/12/23 + */ +public class DefaultTemplateResource extends AbstractTemplateResource { + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java b/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java index 51b36d9161..56a98a2359 100644 --- a/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java @@ -1,6 +1,6 @@ package com.fr.design.fun; -import com.fr.design.file.TemplateFileResourceOperation; +import com.fr.design.file.TemplateResource; import com.fr.file.filetree.FileNodes; import com.fr.stable.fun.mark.Immutable; @@ -22,7 +22,7 @@ public interface LocalResourceProvider extends Immutable { * * @return 目录/模板的各种操作 */ - TemplateFileResourceOperation createResourceOperation(); + TemplateResource createResourceOperation(); /** * eg: LocalFileNodes 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 dbf61e8b59..5cfd7a13d4 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 @@ -23,7 +23,7 @@ import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.InformationWarnPane; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.TemplateFileResourceManager; +import com.fr.design.file.TemplateResourceManager; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; @@ -813,7 +813,7 @@ public abstract class JTemplate> return false; } try { - this.getTarget().export(TemplateFileResourceManager.getOperation().saveTemplate(editingFILE)); + this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE)); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE); diff --git a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index 3e8178b2d7..d096faf8a7 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -2,7 +2,7 @@ package com.fr.file; import com.fr.base.BaseUtils; import com.fr.base.FRContext; -import com.fr.design.file.TemplateFileResourceManager; +import com.fr.design.file.TemplateResourceManager; import com.fr.io.FineEncryptUtils; import com.fr.base.io.XMLEncryptUtils; import com.fr.design.file.NodeAuthProcessor; @@ -323,7 +323,7 @@ public class FileNodeFILE implements FILE { } try { - return TemplateFileResourceManager.getOperation().exist(node.getEnvPath()); + return TemplateResourceManager.getResource().exist(node.getEnvPath()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; @@ -378,7 +378,7 @@ public class FileNodeFILE implements FILE { if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { return null; } - InputStream in = TemplateFileResourceManager.getOperation().readTemplate( + InputStream in = TemplateResourceManager.getResource().readTemplate( StableUtils.pathJoin( ProjectConstants.REPORTLETS_NAME, envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)