Browse Source

改用TreeSet

feature/big-screen
Lanlan 4 years ago
parent
commit
16c43c8a77
  1. 30
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java

30
designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java

@ -13,6 +13,9 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
import javax.swing.BorderFactory;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
@ -21,7 +24,6 @@ import javax.swing.tree.TreePath;
import java.awt.Color;
import java.awt.Component;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
/*
@ -199,15 +201,33 @@ public class EnvFileTree extends RefreshableJTree {
// 用FileNodeFilter过滤一下
if (filter != null) {
java.util.List<FileNode> tList = new ArrayList<FileNode>();
Set<FileNode> tSet = new TreeSet<FileNode>(new Comparator<FileNode>() {
private boolean isNull(FileNode node) {
return node == null || node.getName() == null;
}
@Override
public int compare(FileNode o1, FileNode o2) {
if (isNull(o1) && !isNull(o2)) {
return 1;
}
if (!isNull(o1) && isNull(o2)) {
return -1;
}
if (isNull(o1) && isNull(o2)) {
return 0;
}
return o1.getName().compareTo(o2.getName());
}
});
for (int i = 0; i < resFns.length; i++) {
// war包部署下会生成两份classes目录,需要去重一下
if (filter.accept(resFns[i]) && !tList.contains(resFns[i])) {
tList.add(resFns[i]);
if (filter.accept(resFns[i])) {
tSet.add(resFns[i]);
}
}
resFns = tList.toArray(new FileNode[tList.size()]);
resFns = tSet.toArray(new FileNode[tSet.size()]);
}
Arrays.sort(resFns, new FileNodeComparator(FRContext.getFileNodes().getSupportedTypes()));

Loading…
Cancel
Save