Browse Source

Merge branch 'release/10.0' of http://cloud.finedevelop.com:2015/scm/~harrison/design into release/10.0

feature/big-screen
Harrison 5 years ago
parent
commit
3c3d95aeff
  1. 60
      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

60
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()));
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){
supportFileType.addAll(Arrays.asList(app.defaultExtensions()));
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