diff --git a/platform/lang-api/src/com/intellij/ide/projectView/ProjectViewNode.java b/platform/lang-api/src/com/intellij/ide/projectView/ProjectViewNode.java index 474ccc011d33..e7bfc33f8af5 100644 --- a/platform/lang-api/src/com/intellij/ide/projectView/ProjectViewNode.java +++ b/platform/lang-api/src/com/intellij/ide/projectView/ProjectViewNode.java @@ -165,11 +165,32 @@ public abstract class ProjectViewNode extends AbstractTreeNode { return 0; } + /** + * When nodes are sorted by type all objects with same weigh will be sorted using + * some common algorithm (e.g alpha comparator). This method allows to perform custom + * sorting for such objects. And default comparison will be applied only if nodes are equal + * from custom comparator's point of view. Also comparison will be applied only if both objects + * have not null comparable keys. + * @return Comparable object. + */ @Nullable public Comparable getTypeSortKey() { return null; } + /** + * When nodes aren't sorted by type all objects with same weigh will be sorted using + * some common algorithm (e.g alpha comparator). This method allows to perform custom + * sorting for such objects. And default comparison will be applied only if nodes are equal + * from custom comparator's point of view. Also comparison will be applied only if both objects + * have not null comparable keys. + * @return Comparable object. + */ + @Nullable + public Comparable getSortKey() { + return null; + } + @Nullable public String getQualifiedNameSortKey() { return null; diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/GroupByTypeComparator.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/GroupByTypeComparator.java index ac88f0939c08..8fa21d67fb2f 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/GroupByTypeComparator.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/GroupByTypeComparator.java @@ -58,10 +58,17 @@ public class GroupByTypeComparator implements Comparator { } if (isSortByType()) { - Comparable typeSortKey1 = node1.getTypeSortKey(); - Comparable typeSortKey2 = node2.getTypeSortKey(); + final Comparable typeSortKey1 = node1.getTypeSortKey(); + final Comparable typeSortKey2 = node2.getTypeSortKey(); if (typeSortKey1 != null && typeSortKey2 != null) { - int result = typeSortKey1.compareTo(typeSortKey2); + final int result = typeSortKey1.compareTo(typeSortKey2); + if (result != 0) return result; + } + } else { + final Comparable typeSortKey1 = node1.getSortKey(); + final Comparable typeSortKey2 = node2.getSortKey(); + if (typeSortKey1 != null && typeSortKey2 != null) { + final int result = typeSortKey1.compareTo(typeSortKey2); if (result != 0) return result; } }