From ea59aee64ebcaac751b0e2cd9dc9cc230d00a4da Mon Sep 17 00:00:00 2001 From: "alex.sung" Date: Mon, 29 Jul 2019 17:28:22 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87=E7=9B=91=E5=90=AC=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9F=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/itree/filetree/FileNodeConstants.java | 41 +++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java index b997b21d0..a6757ee2b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java @@ -3,6 +3,12 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.FRContext; import com.fr.design.ExtraDesignClassManager; import com.fr.design.mainframe.App; +import com.fr.general.GeneralContext; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import java.util.ArrayList; import java.util.Arrays; @@ -14,15 +20,36 @@ import java.util.Set; */ public class FileNodeConstants { - private FileNodeConstants(){} + private static List supportFileType = new ArrayList(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); - public static String[] getSupportFileTypes(){ - List supportFileType = new ArrayList<>(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); - //通过插件扩展的 - Set apps = ExtraDesignClassManager.getInstance().getArray(App.MARK_STRING); - for(App app: apps){ - supportFileType.addAll(Arrays.asList(app.defaultExtensions())); + static { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent pluginEvent) { + supportFileType = new ArrayList(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); + //通过插件扩展的 + Set apps = ExtraDesignClassManager.getInstance().getArray(App.MARK_STRING); + for (App app : apps) { + addAppExtensions(app.defaultExtensions()); + } + } + }, new PluginFilter() { + @Override + public boolean accept(PluginContext pluginContext) { + return pluginContext.contain(PluginModule.ExtraDesign); + } + }); + } + + private static void addAppExtensions(String[] extensions) { + for (int i = 0, size = extensions.length; i < size; i++) { + if (!supportFileType.contains(extensions[i])) { + supportFileType.add(extensions[i]); + } } + } + + public static String[] getSupportFileTypes() { return supportFileType.toArray(new String[0]); } }