Search in sources :

Example 1 with NodeTreeComparator

use of com.oxygenxml.git.view.NodeTreeComparator in project oxygen-git-client-addon by oxygenxml.

the class TreeUtil method sort.

/**
 * Sorts the given node
 *
 * @param node The node to be sorted.
 */
private static void sort(GitTreeNode node) {
    int childCount = node.getChildCount();
    List<GitTreeNode> children = new ArrayList<>(childCount);
    for (int i = 0; i < childCount; i++) {
        children.add((GitTreeNode) node.getChildAt(i));
    }
    Collections.sort(children, new NodeTreeComparator());
    node.removeAllChildren();
    children.forEach(node::add);
}
Also used : GitTreeNode(com.oxygenxml.git.view.GitTreeNode) ArrayList(java.util.ArrayList) NodeTreeComparator(com.oxygenxml.git.view.NodeTreeComparator)

Aggregations

GitTreeNode (com.oxygenxml.git.view.GitTreeNode)1 NodeTreeComparator (com.oxygenxml.git.view.NodeTreeComparator)1 ArrayList (java.util.ArrayList)1