@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); } }
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); }