int (NodeDescriptor nodeDescriptor1, NodeDescriptor nodeDescriptor2) { int weight1 = getWeight(nodeDescriptor1); int weight2 = getWeight(nodeDescriptor2); if (weight1 != weight2) { return weight1 - weight2; } if (!(nodeDescriptor1.getParentDescriptor() instanceof ProjectViewProjectNode)){ if (nodeDescriptor1 instanceof PsiDirectoryNode || nodeDescriptor1 instanceof PsiFileNode){ return nodeDescriptor1.toString().compareToIgnoreCase(nodeDescriptor2.toString()); } if (nodeDescriptor1 instanceof ClassTreeNode && nodeDescriptor2 instanceof ClassTreeNode){ if (((ClassTreeNode)nodeDescriptor1).isTopLevel()){ return nodeDescriptor1.toString().compareToIgnoreCase(nodeDescriptor2.toString()); } } } return Integer.compare(nodeDescriptor1.getIndex(), nodeDescriptor2.getIndex()); }