@Test public void testSortedSource() { Comparator<String> alphabetical = GlazedLists.comparableComparator(); Comparator<String> length = GlazedLists.reverseComparator(new StringLengthComparator()); BasicEventList<String> unsortedSource = new BasicEventList<>(); SortedList<String> source = new SortedList<>(unsortedSource, null); unsortedSource.addAll(Arrays.asList("apple", "banana", "cat", "dear", "frog", "boat", "car", "jesse", "glazed", "shirt", "hat", "art", "dog", "puppy", "foot")); SeparatorList<String> separatorList = new SeparatorList<>(source, length, 0, Integer.MAX_VALUE); ListConsistencyListener<String> listConsistencyListener = ListConsistencyListener.install(separatorList); listConsistencyListener.setPreviousElementTracked(false); assertEqualsIgnoreSeparators(source, separatorList, length); source.setComparator(alphabetical); assertEqualsIgnoreSeparators(source, separatorList, length); unsortedSource.addAll(Arrays.asList("apple", "banana", "cat", "art", "dog", "puppy", "foot", "carrot", "beer")); assertEqualsIgnoreSeparators(source, separatorList, length); source.setComparator(alphabetical); assertEqualsIgnoreSeparators(source, separatorList, length); }
public void setComparator(Comparator<E> comparator) { final boolean isEmpty = isEmpty(); if (!isEmpty) { updates.beginEvent(); updates.addDelete(0, size() - 1); } SortedList<E> sortedList = (SortedList<E>)separatorSource.source; sortedList.setComparator(comparator); if (!isEmpty) { rebuildCollapsedElements(); updates.addInsert(0, size() - 1); updates.commitEvent(); } else { separatorSource.grouper.setComparator(comparator); } }
SeparatorList extends TransformedList<E, E> { public void setComparator(Comparator<E> comparator) { final boolean isEmpty = isEmpty(); if (!isEmpty) { updates.beginEvent(); updates.addDelete(0, size() - 1); } SortedList<E> sortedList = (SortedList<E>)separatorSource.source; sortedList.setComparator(comparator); if (!isEmpty) { rebuildCollapsedElements(); updates.addInsert(0, size() - 1); updates.commitEvent(); } else { separatorSource.grouper.setComparator(comparator); } } }
SeparatorList extends TransformedList<E, E> { public void setComparator(Comparator<E> comparator) { final boolean isEmpty = isEmpty(); if (!isEmpty) { updates.beginEvent(); updates.addDelete(0, size() - 1); } SortedList<E> sortedList = (SortedList<E>)separatorSource.source; sortedList.setComparator(comparator); if (!isEmpty) { rebuildCollapsedElements(); updates.addInsert(0, size() - 1); updates.commitEvent(); } else { separatorSource.grouper.setComparator(comparator); } } SeparatorList(EventList<E> source, Comparator<? super E> comparator, int minimumSizeForSeparator, int defaultLimit); }
SeparatorList extends TransformedList<E, E> { public void setComparator(Comparator<E> comparator) { final boolean isEmpty = isEmpty(); if (!isEmpty) { updates.beginEvent(); updates.addDelete(0, size() - 1); } SortedList<E> sortedList = (SortedList<E>)separatorSource.source; sortedList.setComparator(comparator); if (!isEmpty) { rebuildCollapsedElements(); updates.addInsert(0, size() - 1); updates.commitEvent(); } else { separatorSource.grouper.setComparator(comparator); } } SeparatorList(EventList<E> source, Comparator<? super E> comparator, int minimumSizeForSeparator, int defaultLimit); @Override int size(); void setComparator(Comparator<E> comparator); @Override void listChanged(ListEvent<E> listChanges); @Override void dispose(); }
SeparatorList extends TransformedList<E, E> { public void setComparator(Comparator<E> comparator) { final boolean isEmpty = isEmpty(); if (!isEmpty) { updates.beginEvent(); updates.addDelete(0, size() - 1); } SortedList<E> sortedList = (SortedList<E>)separatorSource.source; sortedList.setComparator(comparator); if (!isEmpty) { rebuildCollapsedElements(); updates.addInsert(0, size() - 1); updates.commitEvent(); } else { separatorSource.grouper.setComparator(comparator); } } SeparatorList(EventList<E> source, Comparator<? super E> comparator, int minimumSizeForSeparator, int defaultLimit); @Override int size(); void setComparator(Comparator<E> comparator); @Override void listChanged(ListEvent<E> listChanges); @Override void dispose();  }