Browse Source

改用HashMap

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

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

@ -13,9 +13,8 @@ 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 java.util.HashMap;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
@ -201,33 +200,14 @@ public class EnvFileTree extends RefreshableJTree {
// 用FileNodeFilter过滤一下
if (filter != null) {
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++) {
Map<String, FileNode> fileNodes = new HashMap<>();
for (FileNode fileNode : resFns) {
// war包部署下会生成两份classes目录,需要去重一下
if (filter.accept(resFns[i])) {
tSet.add(resFns[i]);
if (filter.accept(fileNode)) {
fileNodes.put(fileNode.getName(), fileNode);
}
}
resFns = tSet.toArray(new FileNode[tSet.size()]);
resFns = fileNodes.values().toArray(new FileNode[fileNodes.size()]);
}
Arrays.sort(resFns, new FileNodeComparator(FRContext.getFileNodes().getSupportedTypes()));

Loading…
Cancel
Save