/** {@inheritDoc} */ @Override public E get(int index) { Object type = insertedSeparators.get(index); if(type == SEPARATOR) return (E)separators.get(getSeparatorIndex(index)).get(); else if(type == SOURCE_ELEMENT) return source.get(getSourceIndex(index)); else throw new IllegalStateException(); }
if(sourceComparator != grouper.getComparator()) { grouper.setComparator(sourceComparator); rebuildSeparators(); return;
int limit = node.get().getLimit(); if(limit == 0) continue; if(limit >= separatorSource.size()) continue; if(limit >= node.get().size()) continue; canReorder = false;
int limit = node.get().getLimit(); if(limit == 0) continue; if(limit >= separatorSource.size()) continue; if(limit >= node.get().size()) continue; canReorder = false;
int limit = node.get().getLimit(); if(limit == 0) continue; if(limit >= separatorSource.size()) continue; if(limit >= node.get().size()) continue; canReorder = false;
if(sourceComparator != grouper.getComparator()) { grouper.setComparator(sourceComparator); rebuildSeparators(); return;
if(sourceComparator != grouper.getComparator()) { grouper.setComparator(sourceComparator); rebuildSeparators(); return;
/** * Construct a SeparatorList overtop of the <code>source</code> list by * using the given <code>comparator</code> to compute groups of similar * source items. For each group a single separator will be present in this * SeparatorList provided the group contains at least the * <code>minimumSizeForSeparator</code> number of items (otherwise they are * left without a separator). In addition this SeparatorList will never * show more than the <code>defaultLimit</code> number of group elements * from any given group. * * @param source the list containing the raw items to be grouped * @param comparator the Comparator which defines the grouping logic * @param minimumSizeForSeparator the number of elements which must exist * in a group in order for a separator to be created * @param defaultLimit the maximum number of element to display for a group; * extra elements are truncated */ public SeparatorList(EventList<E> source, Comparator<? super E> comparator, int minimumSizeForSeparator, int defaultLimit) { super(new SeparatorInjectorList<E>(new SortedList<E>(source, comparator), defaultLimit)); this.separatorSource = (SeparatorInjectorList<E>)super.source; this.minimumSizeForSeparator = minimumSizeForSeparator; // prepare the collapsed elements rebuildCollapsedElements(); // handle changes to the separators list this.separatorSource.addListEventListener(this); }
/** * Construct a SeparatorList overtop of the <code>source</code> list by * using the given <code>comparator</code> to compute groups of similar * source items. For each group a single separator will be present in this * SeparatorList provided the group contains at least the * <code>minimumSizeForSeparator</code> number of items (otherwise they are * left without a separator). In addition this SeparatorList will never * show more than the <code>defaultLimit</code> number of group elements * from any given group. * * @param source the list containing the raw items to be grouped * @param comparator the Comparator which defines the grouping logic * @param minimumSizeForSeparator the number of elements which must exist * in a group in order for a separator to be created * @param defaultLimit the maximum number of element to display for a group; * extra elements are truncated */ public SeparatorList(EventList<E> source, Comparator<? super E> comparator, int minimumSizeForSeparator, int defaultLimit) { super(new SeparatorInjectorList<E>(new SortedList<E>(source, comparator), defaultLimit)); this.separatorSource = (SeparatorInjectorList<E>)super.source; this.minimumSizeForSeparator = minimumSizeForSeparator; // prepare the collapsed elements rebuildCollapsedElements(); // handle changes to the separators list this.separatorSource.addListEventListener(this); }
/** * Construct a SeparatorList overtop of the <code>source</code> list by * using the given <code>comparator</code> to compute groups of similar * source items. For each group a single separator will be present in this * SeparatorList provided the group contains at least the * <code>minimumSizeForSeparator</code> number of items (otherwise they are * left without a separator). In addition this SeparatorList will never * show more than the <code>defaultLimit</code> number of group elements * from any given group. * * @param source the list containing the raw items to be grouped * @param comparator the Comparator which defines the grouping logic * @param minimumSizeForSeparator the number of elements which must exist * in a group in order for a separator to be created * @param defaultLimit the maximum number of element to display for a group; * extra elements are truncated */ public SeparatorList(EventList<E> source, Comparator<? super E> comparator, int minimumSizeForSeparator, int defaultLimit) { super(new SeparatorInjectorList<E>(new SortedList<E>(source, comparator), defaultLimit)); this.separatorSource = (SeparatorInjectorList<E>)super.source; this.minimumSizeForSeparator = minimumSizeForSeparator; // prepare the collapsed elements rebuildCollapsedElements(); // handle changes to the separators list this.separatorSource.addListEventListener(this); }
/** * Create a new {@link SeparatorInjectorList} that groups together like * items using the Comparator from the <code>source</code>. Elements * that the {@link Comparator} determines are equal will share a common * separator. * * @param source the sorted list of items with a Comparator that defines * the group boundaries * @param defaultLimit the maximum number of items to include in a * group; all remaining items will be truncated */ public SeparatorInjectorList(SortedList<E> source, int defaultLimit) { super(source); this.defaultLimit = defaultLimit; // prepare the groups GrouperClient grouperClient = new GrouperClient(); this.grouper = new Grouper<E>(source, grouperClient); // initialize separators state rebuildSeparators(); // handle changes via the grouper source.addListEventListener(this); }
/** * Create a new {@link SeparatorInjectorList} that groups together like * items using the Comparator from the <code>source</code>. Elements * that the {@link Comparator} determines are equal will share a common * separator. * * @param source the sorted list of items with a Comparator that defines * the group boundaries * @param defaultLimit the maximum number of items to include in a * group; all remaining items will be truncated */ public SeparatorInjectorList(SortedList<E> source, int defaultLimit) { super(source); this.defaultLimit = defaultLimit; // prepare the groups GrouperClient grouperClient = new GrouperClient(); this.grouper = new Grouper<E>(source, grouperClient); // initialize separators state rebuildSeparators(); // handle changes via the grouper source.addListEventListener(this); }
/** * Create a new {@link SeparatorInjectorList} that groups together like * items using the Comparator from the <code>source</code>. Elements * that the {@link Comparator} determines are equal will share a common * separator. * * @param source the sorted list of items with a Comparator that defines * the group boundaries * @param defaultLimit the maximum number of items to include in a * group; all remaining items will be truncated */ public SeparatorInjectorList(SortedList<E> source, int defaultLimit) { super(source); this.defaultLimit = defaultLimit; // prepare the groups GrouperClient grouperClient = new GrouperClient(); this.grouper = new Grouper<E>(source, grouperClient); // initialize separators state rebuildSeparators(); // handle changes via the grouper source.addListEventListener(this); }
/** {@inheritDoc} */ @Override public void dispose() { // dispose internal SeparatorInjectorList and SortedList separatorSource.dispose(); separatorSource.source.dispose(); super.dispose(); }
/** {@inheritDoc} */ @Override public void dispose() { // dispose internal SeparatorInjectorList and SortedList separatorSource.dispose(); separatorSource.source.dispose(); super.dispose(); }
/** * Rebuild the entire collapsed elements barcode. */ private void rebuildCollapsedElements() { collapsedElements = new Barcode(); collapsedElements.addBlack(0, separatorSource.size()); int groupCount = separatorSource.insertedSeparators.colourSize(SEPARATOR); for(int i = 0; i < groupCount; i++) { updateGroup(i, groupCount, false); } }
/** {@inheritDoc} */ @Override public E get(int index) { Object type = insertedSeparators.get(index); if(type == SEPARATOR) return (E)separators.get(getSeparatorIndex(index)).get(); else if(type == SOURCE_ELEMENT) return source.get(getSourceIndex(index)); else throw new IllegalStateException(); }
/** {@inheritDoc} */ @Override public E get(int index) { Object type = insertedSeparators.get(index); if(type == SEPARATOR) return (E)separators.get(getSeparatorIndex(index)).get(); else if(type == SOURCE_ELEMENT) return source.get(getSourceIndex(index)); else throw new IllegalStateException(); }
/** * Rebuild the entire collapsed elements barcode. */ private void rebuildCollapsedElements() { collapsedElements = new Barcode(); collapsedElements.addBlack(0, separatorSource.size()); int groupCount = separatorSource.insertedSeparators.colourSize(SEPARATOR); for(int i = 0; i < groupCount; i++) { updateGroup(i, groupCount, false); } }
/** * Rebuild the entire collapsed elements barcode. */ private void rebuildCollapsedElements() { collapsedElements = new Barcode(); collapsedElements.addBlack(0, separatorSource.size()); int groupCount = separatorSource.insertedSeparators.colourSize(SEPARATOR); for(int i = 0; i < groupCount; i++) { updateGroup(i, groupCount, false); } }