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

Loading…
Cancel
Save