Browse Source

通过监听插件生命周期实现

feature/big-screen
alex.sung 5 years ago
parent
commit
ea59aee64e
  1. 37
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java

37
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<String> supportFileType = new ArrayList<String>(Arrays.asList(FRContext.getFileNodes().getSupportedTypes()));
public static String[] getSupportFileTypes(){
List<String> supportFileType = new ArrayList<>(Arrays.asList(FRContext.getFileNodes().getSupportedTypes()));
static {
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent pluginEvent) {
supportFileType = new ArrayList<String>(Arrays.asList(FRContext.getFileNodes().getSupportedTypes()));
//通过插件扩展的
Set<App> apps = ExtraDesignClassManager.getInstance().getArray(App.MARK_STRING);
for(App app: apps){
supportFileType.addAll(Arrays.asList(app.defaultExtensions()));
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]);
}
}

Loading…
Cancel
Save