public void collectionChanged(CollectionEvent<T> e) { if (listeners != null && !listeners.isEmpty()) { Collection<T> filteredElements = e.getElements(); CollectionEvent<T> filteredEvent = new CollectionEvent<T>(FilteredListenableCollection.this, filteredElements, e.getType(), e.getFirstIndex(), e.getLastIndex()); for (CollectionListener<T> listener : listeners) { listener.collectionChanged(filteredEvent); } } } });
public void collectionChanged(CollectionEvent<T> e) { switch (e.getType()) { case ADDED: fireIntervalAdded(this, e.getFirstIndex(), e.getLastIndex()); break; case REMOVED: fireIntervalRemoved(this, e.getFirstIndex(), e.getLastIndex()); break; case UPDATED: fireContentsChanged(this, e.getFirstIndex(), e.getLastIndex()); break; } } });
@Override public void collectionChanged(CollectionEvent<T> e) { switch(e.getType()){ case ADDED: ls.fireAdded(CompoundListenableCollection.this, e.getElements()); break; case REMOVED: ls.fireRemoved(CompoundListenableCollection.this, e.getElements()); break; case UPDATED: ls.fireUpdated(CompoundListenableCollection.this, e.getElements()); break; default: break; }//end EventTypes }}; private final CollectionListener<ListenableCollection<T>> outerListener = new CollectionListener<ListenableCollection<T>>(){
ListenableCollection<T> source = e.getSource(), recipient = source == a ? b : a; for (T t : e.getElements()) { switch (e.getType()) { case ADDED: add(t, source, recipient);
public void fireEvent(ListenableCollection<T> source, Collection<T> elements, CollectionEvent.EventType type, int firstIndex, int lastIndex) { if (listeners == null || listeners.isEmpty() || elements.isEmpty()) return; CollectionEvent<T> event = new CollectionEvent<T>(source,elements,type, firstIndex, lastIndex); for (CollectionListener<T> listener : listeners) { listener.collectionChanged(event); } }
@Override public void collectionChanged(CollectionEvent<ListenableCollection<T>> e) { switch(e.getType()){ case ADDED: for(ListenableCollection<T> coll:e.getElements()){ delegate.addComponent(coll); coll.addCollectionListener(innerListener); ls.fireAdded(CompoundListenableCollection.this, coll); }//end for(collections added) break; case REMOVED: for(ListenableCollection<T> coll:e.getElements()){ delegate.removeComponent(coll); coll.removeCollectionListener(innerListener); ls.fireRemoved(CompoundListenableCollection.this, coll); }//end for(collections removed) break; case UPDATED: // ???? break; default: break; }//end EventTypes }};
public void collectionChanged(CollectionEvent<U> e) { // Do not propagate the event if we triggered it if (currentlyCausingChange) return; // Only propagate if someone is listening (CollectionSupport already tries not to fire anything when there is no listener, but here we are trying to avoid to create the wrapped elements collection) if (collectionSupport == null || !collectionSupport.hasListeners()) return; // Adapt the collection of changed / added / removed elements in the event collectionSupport.fireEvent( AdaptedCollection.this, new AdaptedCollection<U, V>(e.getElements(), AdaptedCollection.this.forwardAdapter, AdaptedCollection.this.backwardAdapter), e.getType(), e.getFirstIndex(), e.getLastIndex()); } });