Browse Source

REPORT-18867 [新引擎]设计器左侧目录树cptx文件名排序

* commit 'ac63ec1c6e8fe573b0eaae38d6e7bc710083b673':
  不ignored异常
  加读写锁
  初始化时从插件里捞一把
  通过监听插件生命周期实现
  插件天生可拔插,这里不能用static,应每次调用时获取
feature/big-screen
Alex.Sung 5 years ago
parent
commit
a31dafd616
  1. 64
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java
  2. 2
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java

64
designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java

@ -3,25 +3,75 @@ 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;
import java.util.List;
import java.util.Set;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Created by alex sung on 2019/7/23.
*/
public class FileNodeConstants {
public static String[] SUPPORT_FILE_TYPES;
private static List<String> supportFileType;
private static ReadWriteLock rwl = new ReentrantReadWriteLock();
private FileNodeConstants() {
}
static {
List<String> supportFileType = new ArrayList<>(Arrays.asList(FRContext.getFileNodes().getSupportedTypes()));
//通过插件扩展的
Set<App> apps = ExtraDesignClassManager.getInstance().getArray(App.MARK_STRING);
for(App app: apps){
supportFileType.addAll(Arrays.asList(app.defaultExtensions()));
initSupportedTypes();
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent pluginEvent) {
initSupportedTypes();
}
}, 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]);
}
}
}
private static void initSupportedTypes() {
try {
rwl.writeLock().lock();
supportFileType = new ArrayList<>(Arrays.asList(FRContext.getFileNodes().getSupportedTypes()));
//通过插件扩展的
Set<App> apps = ExtraDesignClassManager.getInstance().getArray(App.MARK_STRING);
for (App app : apps) {
addAppExtensions(app.defaultExtensions());
}
} finally {
rwl.writeLock().unlock();
}
}
public static String[] getSupportFileTypes() {
try {
rwl.readLock().lock();
return supportFileType.toArray(new String[0]);
} finally {
rwl.readLock().unlock();
}
SUPPORT_FILE_TYPES = supportFileType.toArray(new String[0]);
}
}

2
designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java

@ -228,7 +228,7 @@ public class TemplateFileTree extends EnvFileTree {
if (fileNodes == null) {
fileNodes = new FileNode[0];
}
Arrays.sort(fileNodes, new FileNodeComparator(FileNodeConstants.SUPPORT_FILE_TYPES));
Arrays.sort(fileNodes, new FileNodeComparator(FileNodeConstants.getSupportFileTypes()));
return fileNodes;
}

Loading…
Cancel
Save