final boolean isEmpty = isEmpty(); updates.addDelete(0, size() - 1); rebuildCollapsedElements(); updates.addInsert(0, size() - 1); updates.commitEvent();
setVisible(separatorStart, Barcode.WHITE, fireEvents); setVisible(i, Barcode.BLACK, fireEvents); setVisible(separatorStart, Barcode.BLACK, fireEvents); setVisible(i, withinLimit ? Barcode.BLACK : Barcode.WHITE, fireEvents);
/** * 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); } }
public void saveExpandedState() { try { separatorList.getReadWriteLock().readLock().lock(); for (int i = 0; i < separatorList.size(); i++) { Object object = separatorList.get(i); if (object instanceof SeparatorList.Separator) { SeparatorList.Separator<?> separator = (SeparatorList.Separator) object; final int limit = separator.getLimit(); if (limit == 0) { //Collapsed for (Object item : separator.getGroup()) { expandedSate.put(item, limit != 0); } } else { for (int x = i + 1; x < separatorList.size(); x++) { Object xObject = separatorList.get(x); if (xObject instanceof SeparatorList.Separator) { break; } expandedSate.put(xObject, limit != 0); } } } } } finally { separatorList.getReadWriteLock().readLock().unlock(); } }
@Benchmark @Warmup(iterations = 5) @Measurement(iterations = 10) @Fork(1) public EventList<Element> testSeparatorListCrudNew() { EventList<Element> baseCopy = GlazedLists.eventList(base); EventList<Element> sepBase = new SeparatorList<>(baseCopy, elementComparator(), 0, Integer.MAX_VALUE); doTest(baseCopy, sepBase); return sepBase; }
/** * 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); }
private SeparatorList.Separator<?> getSeparator(final Stockpile stockpile) { try { separatorList.getReadWriteLock().readLock().lock(); for (int i = 0; i < separatorList.size(); i++) { Object object = separatorList.get(i); if (object instanceof SeparatorList.Separator) { SeparatorList.Separator<?> separator = (SeparatorList.Separator) object; Object first = separator.first(); if (first instanceof StockpileItem) { StockpileItem firstItem = (StockpileItem) first; if (firstItem.getStockpile().equals(stockpile)) { return separator; } } } } } finally { separatorList.getReadWriteLock().readLock().unlock(); } return null; }
@Benchmark @Warmup(iterations = 5) @Measurement(iterations = 10) @Fork(1) public EventList<Element> testSeparatorListCrudTransactionNew() { EventList<Element> baseCopy = GlazedLists.eventList(base); TransactionList<Element> transactionList = new TransactionList<>(baseCopy); EventList<Element> sepBase = new SeparatorList<>(transactionList, elementComparator(), 0, Integer.MAX_VALUE); doTestTransaction(transactionList, sepBase); return sepBase; }
/** * 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); }
final boolean isEmpty = isEmpty(); updates.addDelete(0, size() - 1); rebuildCollapsedElements(); updates.addInsert(0, size() - 1); updates.commitEvent();
public void loadExpandedState() { try { separatorList.getReadWriteLock().readLock().lock(); for (int i = 0; i < separatorList.size(); i++) { Object object = separatorList.get(i); if (object instanceof SeparatorList.Separator) { SeparatorList.Separator<?> separator = (SeparatorList.Separator) object; for (int x = i + 1; x < separatorList.size(); x++) { Object xObject = separatorList.get(x); if (xObject instanceof SeparatorList.Separator) { break; if (oldLimit != newLimit) { try { separatorList.getReadWriteLock().readLock().unlock(); separatorList.getReadWriteLock().writeLock().lock(); separator.setLimit(newLimit); } finally { separatorList.getReadWriteLock().writeLock().unlock(); separatorList.getReadWriteLock().readLock().lock(); separatorList.getReadWriteLock().readLock().unlock();
/** * 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); } }
separatorList = new SeparatorList<Material>(eventList, new MaterialSeparatorComparator(), 1, Integer.MAX_VALUE); eventList.getReadWriteLock().readLock().unlock();
/** * 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); }
setVisible(separatorStart, Barcode.WHITE, fireEvents); setVisible(i, Barcode.BLACK, fireEvents); setVisible(separatorStart, Barcode.BLACK, fireEvents); setVisible(i, withinLimit ? Barcode.BLACK : Barcode.WHITE, fireEvents);
final boolean isEmpty = isEmpty(); updates.addDelete(0, size() - 1); rebuildCollapsedElements(); updates.addInsert(0, size() - 1); updates.commitEvent(); } else {
private void expandHeader() { Material material = (Material) currentSeparator.first(); boolean expand = isHeaderCollapsed(); try { separatorList.getReadWriteLock().readLock().lock(); for (int i = 0; i < separatorList.size(); i++) { Object object = separatorList.get(i); if (object instanceof SeparatorList.Separator<?>) { SeparatorList.Separator<?> separator = (SeparatorList.Separator<?>) object; Material currentMaterial = (Material) separator.first(); if (currentMaterial.getHeader().equals(material.getHeader())) { try { separatorList.getReadWriteLock().readLock().unlock(); separatorList.getReadWriteLock().writeLock().lock(); separator.setLimit(expand ? Integer.MAX_VALUE : 0); } finally { separatorList.getReadWriteLock().writeLock().unlock(); separatorList.getReadWriteLock().readLock().lock(); } } } } } finally { separatorList.getReadWriteLock().readLock().unlock(); } }
/** * 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); } }
eventList.getReadWriteLock().readLock().unlock(); separatorList = new SeparatorList<Loadout>(filterList, new LoadoutSeparatorComparator(), 1, Integer.MAX_VALUE);
setVisible(separatorStart, Barcode.WHITE, fireEvents); setVisible(i, Barcode.BLACK, fireEvents); setVisible(separatorStart, Barcode.BLACK, fireEvents); setVisible(i, withinLimit ? Barcode.BLACK : Barcode.WHITE, fireEvents);