Java 类org.apache.commons.collections.comparators.TransformingComparator 实例源码

项目:GitDirStat    文件:GitRepositoryTreeNode.java   
@SuppressWarnings("unchecked")
private void deepSort(DefaultMutableTreeNode parent,
        TreeObjectSortBy sortBy, SortOrder order) {
    Enumeration<DefaultMutableTreeNode> treeObjectNodes = parent.children();
    List<DefaultMutableTreeNode> treeNodes = EnumerationUtils
            .toList(treeObjectNodes);

    BeanToPropertyValueTransformer sortProperty = getSortByTransformer(sortBy);

    Comparator<DefaultMutableTreeNode> comparator = new TransformingComparator(
            sortProperty);

    if (SortOrder.DESC.equals(order)) {
        comparator = new ReverseComparator<DefaultMutableTreeNode>(
                comparator);
    }

    Collections.sort(treeNodes, comparator);

    parent.removeAllChildren();
    for (DefaultMutableTreeNode childNode : treeNodes) {
        parent.add(childNode);
        deepSort(childNode, sortBy, order);
    }
}
项目:GitDirStat    文件:GitRepositoryTreeNode.java   
@SuppressWarnings("unchecked")
private void deepSort(DefaultMutableTreeNode parent,
        TreeObjectSortBy sortBy, SortOrder order) {
    Enumeration<DefaultMutableTreeNode> treeObjectNodes = parent.children();
    List<DefaultMutableTreeNode> treeNodes = EnumerationUtils
            .toList(treeObjectNodes);

    BeanToPropertyValueTransformer sortProperty = getSortByTransformer(sortBy);

    Comparator<DefaultMutableTreeNode> comparator = new TransformingComparator(
            sortProperty);

    if (SortOrder.DESC.equals(order)) {
        comparator = new ReverseComparator<DefaultMutableTreeNode>(
                comparator);
    }

    Collections.sort(treeNodes, comparator);

    parent.removeAllChildren();
    for (DefaultMutableTreeNode childNode : treeNodes) {
        parent.add(childNode);
        deepSort(childNode, sortBy, order);
    }
}
项目:spring-rich-client    文件:SortedListModel.java   
protected void applyComparator() {
    Integer[] indexes = new Integer[this.indexes.length];
    System.arraycopy(this.indexes, 0, indexes, 0, indexes.length);
    Arrays.sort(indexes, new TransformingComparator(new IndexToElementTransformer(getFilteredModel()), comparator));
    this.indexes = indexes;
    fireContentsChanged(this, -1, -1);
}
项目:spring-richclient    文件:SortedListModel.java   
protected void applyComparator() {
    Integer[] indexes = new Integer[this.indexes.length];
    System.arraycopy(this.indexes, 0, indexes, 0, indexes.length);
    Arrays.sort(indexes, new TransformingComparator(new IndexToElementTransformer(getFilteredModel()), comparator));
    this.indexes = indexes;
    fireContentsChanged(this, -1, -1);
}