Class JaxxFilterableListModel<E>

java.lang.Object
javax.swing.AbstractListModel
jaxx.runtime.swing.model.JaxxDefaultListModel<E>
jaxx.runtime.swing.model.JaxxFilterableListModel<E>
All Implemented Interfaces:
java.io.Serializable, javax.swing.ListModel

public class JaxxFilterableListModel<E>
extends JaxxDefaultListModel<E>
List model for filterable lists.
Since:
2.5.11
Author:
Kevin Morin - morin@codelutin.com
See Also:
Serialized Form
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected org.nuiton.decorator.JXPathDecorator<E> decorator
    the decorator of data
    protected java.util.ArrayList<E> filteredItems  
    protected java.util.List<com.google.common.base.Predicate<E>> filters  
    protected java.lang.String filterText  

    Fields inherited from class jaxx.runtime.swing.model.JaxxDefaultListModel

    delegate, valueIsAdjusting

    Fields inherited from class javax.swing.AbstractListModel

    listenerList
  • Constructor Summary

    Constructors
    Constructor Description
    JaxxFilterableListModel()  
  • Method Summary

    Modifier and Type Method Description
    void add​(int index, E element)
    Inserts the specified element at the specified position in this list.
    void addAllElements​(java.util.Collection<E> elements)  
    void addElement​(E o)
    Adds the specified component to the end of this list.
    void addFilter​(com.google.common.base.Predicate<E> filter)  
    void clear()
    Removes all of the elements from this list.
    void clearFilters()  
    E elementAt​(int index)
    Returns the component at the specified index.
    void ensureCapacity​(int minCapacity)
    Increases the capacity of this list, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.
    org.nuiton.decorator.JXPathDecorator<E> getDecorator()  
    E getElementAt​(int index)
    Returns the component at the specified index.
    java.lang.String getFilterText()  
    int getSize()
    Returns the number of components in this list.
    void insertElementAt​(E element, int index)
    Inserts the specified element as a component in this list at the specified index.
    protected void refilter()  
    void refreshFilteredElements()  
    E remove​(int index)
    Removes the element at the specified position in this list.
    void removeAllElements()
    Removes all components from this list and sets its size to zero.
    void removeAllElements​(java.util.Collection<E> elements)  
    boolean removeElement​(E o)
    Removes the first (lowest-indexed) occurrence of the argument from this list.
    void removeElementAt​(int index)
    Deletes the component at the specified index.
    void removeFilter​(com.google.common.base.Predicate<E> filter)  
    void removeRange​(int fromIndex, int toIndex)
    Deletes the components at the specified range of indexes.
    E set​(int index, E element)
    Replaces the element at the specified position in this list with the specified element.
    void setAllElements​(java.util.Collection<E> objects)  
    void setDecorator​(org.nuiton.decorator.JXPathDecorator<E> decorator)  
    void setElementAt​(E element, int index)
    Sets the component at the specified index of this list to be the specified element.
    void setFilterText​(java.lang.String filterText)  
    void setSize​(int newSize)
    Sets the size of this list.
    int size()
    Returns the number of components in this list.
    void trimToSize()
    Trims the capacity of this list to be the list's current size.

    Methods inherited from class javax.swing.AbstractListModel

    addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • filteredItems

      protected java.util.ArrayList<E> filteredItems
    • filterText

      protected java.lang.String filterText
    • decorator

      protected org.nuiton.decorator.JXPathDecorator<E> decorator
      the decorator of data
    • filters

      protected java.util.List<com.google.common.base.Predicate<E>> filters
  • Constructor Details

    • JaxxFilterableListModel

      public JaxxFilterableListModel()
  • Method Details

    • getElementAt

      public E getElementAt​(int index)
      Description copied from class: JaxxDefaultListModel
      Returns the component at the specified index.
      Note: Although this method is not deprecated, the preferred method to use is get(int), which implements the List interface defined in the 1.2 Collections framework.
      Specified by:
      getElementAt in interface javax.swing.ListModel<E>
      Overrides:
      getElementAt in class JaxxDefaultListModel<E>
      Parameters:
      index - an index into this list
      Returns:
      the component at the specified index
      See Also:
      JaxxDefaultListModel.get(int)
    • elementAt

      public E elementAt​(int index)
      Description copied from class: JaxxDefaultListModel
      Returns the component at the specified index. Throws an ArrayIndexOutOfBoundsException if the index is negative or not less than the size of the list.
      Note: Although this method is not deprecated, the preferred method to use is get(int), which implements the List interface defined in the 1.2 Collections framework.
      Overrides:
      elementAt in class JaxxDefaultListModel<E>
      Parameters:
      index - an index into this list
      Returns:
      the component at the specified index
      See Also:
      JaxxDefaultListModel.get(int), Vector.elementAt(int)
    • addElement

      public void addElement​(E o)
      Description copied from class: JaxxDefaultListModel
      Adds the specified component to the end of this list.
      Overrides:
      addElement in class JaxxDefaultListModel<E>
      Parameters:
      o - the component to be added
      See Also:
      Vector.addElement(Object)
    • removeElement

      public boolean removeElement​(E o)
      Description copied from class: JaxxDefaultListModel
      Removes the first (lowest-indexed) occurrence of the argument from this list.
      Overrides:
      removeElement in class JaxxDefaultListModel<E>
      Parameters:
      o - the component to be removed
      Returns:
      true if the argument was a component of this list; false otherwise
      See Also:
      Vector.removeElement(Object)
    • getSize

      public int getSize()
      Description copied from class: JaxxDefaultListModel
      Returns the number of components in this list. This method is identical to size, which implements the List interface defined in the 1.2 Collections framework. This method exists in conjunction with setSize so that size is identifiable as a JavaBean property.
      Specified by:
      getSize in interface javax.swing.ListModel<E>
      Overrides:
      getSize in class JaxxDefaultListModel<E>
      Returns:
      the number of components in this list
      See Also:
      JaxxDefaultListModel.size()
    • size

      public int size()
      Description copied from class: JaxxDefaultListModel
      Returns the number of components in this list.
      Overrides:
      size in class JaxxDefaultListModel<E>
      Returns:
      the number of components in this list
      See Also:
      Vector.size()
    • trimToSize

      public void trimToSize()
      Description copied from class: JaxxDefaultListModel
      Trims the capacity of this list to be the list's current size.
      Overrides:
      trimToSize in class JaxxDefaultListModel<E>
      See Also:
      Vector.trimToSize()
    • ensureCapacity

      public void ensureCapacity​(int minCapacity)
      Description copied from class: JaxxDefaultListModel
      Increases the capacity of this list, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.
      Overrides:
      ensureCapacity in class JaxxDefaultListModel<E>
      Parameters:
      minCapacity - the desired minimum capacity
      See Also:
      Vector.ensureCapacity(int)
    • setSize

      public void setSize​(int newSize)
      Description copied from class: JaxxDefaultListModel
      Sets the size of this list.
      Overrides:
      setSize in class JaxxDefaultListModel<E>
      Parameters:
      newSize - the new size of this list
      See Also:
      Vector.setSize(int)
    • setElementAt

      public void setElementAt​(E element, int index)
      Description copied from class: JaxxDefaultListModel
      Sets the component at the specified index of this list to be the specified element. The previous component at that position is discarded. Throws an ArrayIndexOutOfBoundsException if the index is invalid.
      Note: Although this method is not deprecated, the preferred method to use is set(int,Object), which implements the List interface defined in the 1.2 Collections framework.
      Overrides:
      setElementAt in class JaxxDefaultListModel<E>
      Parameters:
      element - what the component is to be set to
      index - the specified index
      See Also:
      JaxxDefaultListModel.set(int, Object), Vector.setElementAt(Object, int)
    • removeElementAt

      public void removeElementAt​(int index)
      Description copied from class: JaxxDefaultListModel
      Deletes the component at the specified index. Throws an ArrayIndexOutOfBoundsException if the index is invalid.
      Note: Although this method is not deprecated, the preferred method to use is remove(int), which implements the List interface defined in the 1.2 Collections framework.
      Overrides:
      removeElementAt in class JaxxDefaultListModel<E>
      Parameters:
      index - the index of the object to remove
      See Also:
      JaxxDefaultListModel.remove(int), Vector.removeElementAt(int)
    • insertElementAt

      public void insertElementAt​(E element, int index)
      Description copied from class: JaxxDefaultListModel
      Inserts the specified element as a component in this list at the specified index. Throws an ArrayIndexOutOfBoundsException if the index is invalid.
      Note: Although this method is not deprecated, the preferred method to use is add(int,Object), which implements the List interface defined in the 1.2 Collections framework.
      Overrides:
      insertElementAt in class JaxxDefaultListModel<E>
      Parameters:
      element - the component to insert
      index - where to insert the new component
      See Also:
      JaxxDefaultListModel.add(int, Object), Vector.insertElementAt(Object, int)
    • removeAllElements

      public void removeAllElements()
      Description copied from class: JaxxDefaultListModel
      Removes all components from this list and sets its size to zero.
      Note: Although this method is not deprecated, the preferred method to use is clear, which implements the List interface defined in the 1.2 Collections framework.
      Overrides:
      removeAllElements in class JaxxDefaultListModel<E>
      See Also:
      JaxxDefaultListModel.clear(), Vector.removeAllElements()
    • set

      public E set​(int index, E element)
      Description copied from class: JaxxDefaultListModel
      Replaces the element at the specified position in this list with the specified element. Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).
      Overrides:
      set in class JaxxDefaultListModel<E>
      Parameters:
      index - index of element to replace
      element - element to be stored at the specified position
      Returns:
      the element previously at the specified position
    • add

      public void add​(int index, E element)
      Description copied from class: JaxxDefaultListModel
      Inserts the specified element at the specified position in this list. Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index > size()).
      Overrides:
      add in class JaxxDefaultListModel<E>
      Parameters:
      index - index at which the specified element is to be inserted
      element - element to be inserted
    • setAllElements

      public void setAllElements​(java.util.Collection<E> objects)
      Overrides:
      setAllElements in class JaxxDefaultListModel<E>
    • addAllElements

      public void addAllElements​(java.util.Collection<E> elements)
      Overrides:
      addAllElements in class JaxxDefaultListModel<E>
    • removeAllElements

      public void removeAllElements​(java.util.Collection<E> elements)
      Overrides:
      removeAllElements in class JaxxDefaultListModel<E>
    • remove

      public E remove​(int index)
      Description copied from class: JaxxDefaultListModel
      Removes the element at the specified position in this list. Returns the element that was removed from the list. Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).
      Overrides:
      remove in class JaxxDefaultListModel<E>
      Parameters:
      index - the index of the element to removed
      Returns:
      the element previously at the specified position
    • clear

      public void clear()
      Description copied from class: JaxxDefaultListModel
      Removes all of the elements from this list. The list will be empty after this call returns (unless it throws an exception).
      Overrides:
      clear in class JaxxDefaultListModel<E>
    • removeRange

      public void removeRange​(int fromIndex, int toIndex)
      Description copied from class: JaxxDefaultListModel
      Deletes the components at the specified range of indexes. The removal is inclusive, so specifying a range of (1,5) removes the component at index 1 and the component at index 5, as well as all components in between. Throws an ArrayIndexOutOfBoundsException if the index was invalid. Throws an IllegalArgumentException if fromIndex > toIndex.
      Overrides:
      removeRange in class JaxxDefaultListModel<E>
      Parameters:
      fromIndex - the index of the lower end of the range
      toIndex - the index of the upper end of the range
      See Also:
      JaxxDefaultListModel.remove(int)
    • getFilterText

      public java.lang.String getFilterText()
    • setFilterText

      public void setFilterText​(java.lang.String filterText)
    • getDecorator

      public org.nuiton.decorator.JXPathDecorator<E> getDecorator()
    • setDecorator

      public void setDecorator​(org.nuiton.decorator.JXPathDecorator<E> decorator)
    • addFilter

      public void addFilter​(com.google.common.base.Predicate<E> filter)
    • removeFilter

      public void removeFilter​(com.google.common.base.Predicate<E> filter)
    • clearFilters

      public void clearFilters()
    • refreshFilteredElements

      public void refreshFilteredElements()
    • refilter

      protected void refilter()