Tabnine Logo
ListenableCollection.addCollectionListener
Code IndexAdd Tabnine to your IDE (free)

How to use
addCollectionListener
method
in
com.ochafik.util.listenable.ListenableCollection

Best Java code snippets using com.ochafik.util.listenable.ListenableCollection.addCollectionListener (Showing top 5 results out of 315)

origin: com.nativelibs4java/ochafik-util

public void addCollectionListener(CollectionListener<T> l) {
  if (listeners == null) {
    listeners = new ArrayList<CollectionListener<T>>();
    listenableCollection.addCollectionListener(new CollectionListener<T>() {
      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);
          }
        }
      }
    });
  }
  
  listeners.add(l);
}
origin: com.nativelibs4java/ochafik-util

a.addCollectionListener(listener);
b.addCollectionListener(listener);
origin: jtrfp/terminal-recall

public CompoundListenableCollection(ListenableCollection<ListenableCollection<T>> adapted){
final Object wildcardObject = adapted;//Just don't look at it and it won't hurt as much.
delegate = new CompoundCollection<T>((Collection<Collection<? extends T>>)wildcardObject);
adapted.addCollectionListener(outerListener);
}//end constructor
origin: com.nativelibs4java/ochafik-util

public void addCollectionListener(CollectionListener<V> l) {
  if (collectionSupport == null) {
    collectionSupport = new ListenableSupport<V>();
    if (collection instanceof ListenableCollection<?>) {
      ((ListenableCollection<U>)collection).addCollectionListener(new CollectionListener<U>() {
        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());
        }
      });
    }
  }
      
  collectionSupport.addCollectionListener(l);
}

origin: jtrfp/terminal-recall

@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
}};
com.ochafik.util.listenableListenableCollectionaddCollectionListener

Popular methods of ListenableCollection

  • add
  • addAll
  • clear
  • contains
  • containsAll
  • isEmpty
  • iterator
  • remove
  • removeAll
  • removeCollectionListener
  • retainAll
  • size
  • retainAll,
  • size,
  • toArray

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setScale (BigDecimal)
  • setContentView (Activity)
  • getExternalFilesDir (Context)
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Collectors (java.util.stream)
  • JLabel (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now