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

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

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

origin: com.nativelibs4java/ochafik-util

public boolean add(T o) {
  return listenableCollection.add(o);
}
origin: com.nativelibs4java/ochafik-util

public boolean addAll(Collection<? extends T> c) {
  return listenableCollection.addAll(c);
}

origin: com.nativelibs4java/ochafik-util

public void clear() {
  listenableCollection.clear();		
}
origin: jtrfp/terminal-recall

  @Override
  public void propertyChange(PropertyChangeEvent evt) {
  outputList.clear();
  outputList.addAll(((AudioDevice)evt.getNewValue()).getOutputs());
  }});
this.addPropertyChangeListener(ACTIVE_OUTPUT, new PropertyChangeListener(){
origin: jtrfp/terminal-recall

  @Override
  public void propertyChange(PropertyChangeEvent evt) {
  formatList.clear();
  for(AudioFormat f:((AudioOutput)evt.getNewValue()).getFormats())
    if(isAcceptableFormat(f))
    formatList.add(f);
  }});
}//end constructor
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: 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
}};
origin: com.nativelibs4java/ochafik-util

@Override
public Iterator<T> iterator() {
  return new FilteredIterator<T>(listenableCollection.iterator()) {
    @Override
    public void remove() {
      throw new UnsupportedOperationException("Unmodifiable listenable collection !");
    }
  };
}
origin: com.nativelibs4java/ochafik-util

public boolean remove(Object o) {
  return listenableCollection.remove(o);
}
origin: com.nativelibs4java/ochafik-util

public boolean isEmpty() {
  return listenableCollection.isEmpty();
}
static class FilteredIterator<T> implements Iterator<T> {
origin: com.nativelibs4java/ochafik-util

public boolean contains(Object o) {
  return listenableCollection.contains(o);
}
origin: com.nativelibs4java/ochafik-util

public boolean containsAll(Collection<?> c) {
  return listenableCollection.containsAll(c);
}
origin: com.nativelibs4java/ochafik-util

public boolean removeAll(Collection<?> c) {
  return listenableCollection.removeAll(c);
}
origin: jtrfp/terminal-recall

  @Override
  public void propertyChange(PropertyChangeEvent evt) {
  deviceList.clear();
  deviceList.addAll(((AudioDriver)evt.getNewValue()).getDevices());
  }});
this.addPropertyChangeListener(ACTIVE_DEVICE, new PropertyChangeListener(){
origin: com.nativelibs4java/ochafik-util

a.addCollectionListener(listener);
b.addCollectionListener(listener);
origin: com.nativelibs4java/ochafik-util

public Iterator<T> iterator() {
  return new FilteredIterator<T>(listenableCollection.iterator());
}
origin: com.nativelibs4java/ochafik-util

  break;
case REMOVED:
  recipient.remove(t);
  break;
case UPDATED:
  } else {
    recipient.remove(t);
    add(t, source, recipient);
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

@SuppressWarnings("unchecked")
void add(T t, ListenableCollection<T> source, ListenableCollection<T> recipient) {
  if ((recipient instanceof List) && (source instanceof SortedSet)) {
    ListenableList<T> recipientList = (ListenableList<T>)recipient;
    Comparator<T> comparator = (Comparator<T>) ((SortedSet)source).comparator();
    int i;
    if (comparator != null) {
      i = Collections.binarySearch(recipientList, t, comparator);
    } else {
      // Assume T is comparable
      i = Collections.binarySearch((List)recipientList, t);
    }
    if (i >= 0) {
      recipientList.set(i, t);
    } else {
      recipientList.add(-i - 1, t);
    }
  } else {
    recipient.add(t);
  }
}
@SuppressWarnings("unchecked")
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);
}

com.ochafik.util.listenableListenableCollection

Javadoc

Interface for collections that support modification listeners.

Most used methods

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

Popular in Java

  • Updating database using SQL prepared statement
  • getContentResolver (Context)
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • JList (javax.swing)
  • Best plugins for Eclipse
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