|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.odell.glazedlists.AbstractEventList<E>
ca.odell.glazedlists.TransformedList
ca.odell.glazedlists.migrationkit.swing.TextFilterList
FilterList and TextComponentMatcherEditor.
public class TextFilterList
An EventList that shows only elements that contain a filter text string.
The TextFilterList uses a JTextField to allow the user to edit
the filter text. As this filter text is edited, the contents of the
TextFilterList are changed to reflect the elements that match the text.
The TextFilterList either requires that a TextFilterator be
specified in its constructor, or that every object in the source list implements
the TextFilterable interface. These are used to specify the Strings
to search for each element.
The TextFilterList initially refilters the list after each change in
the JTextField. If this live filtering does not have adequate performance,
it can be turned off. In this case, the list will refiltered by pressing
ENTER in the JTextField and on every action to the ActionListener.
This ActionListener will be returned from the method getFilterActionListener()
and can be used to refilter in response to a button click.
Warning: This class
breaks the contract required by List. See EventList
for an example.
| EventList Overview | |
| Writable: | yes |
| Concurrency: | thread ready, not thread safe |
| Performance: | reads: O(log N), writes O(log N), filter changes O(N) |
| Memory: | O(N) |
| Unit Tests: | N/A |
| Issues: | N/A |
| Field Summary |
|---|
| Fields inherited from class ca.odell.glazedlists.TransformedList |
|---|
source |
| Fields inherited from class ca.odell.glazedlists.AbstractEventList |
|---|
publisher, readWriteLock, updates |
| Constructor Summary | |
|---|---|
TextFilterList(EventList source)
Deprecated. Creates a TextFilterList that filters the specified EventList
of elements that implement the TextFilterable interface. |
|
TextFilterList(EventList source,
String[] propertyNames)
Deprecated. Creates a TextFilterList that filters the specified EventList
of elements using the JavaBeans property names specified to get the
Strings to search. |
|
TextFilterList(EventList source,
String[] propertyNames,
JTextField filterEdit)
Deprecated. Creates a TextFilterList that filters the specified EventList
of elements using the JavaBeans property names specified to get the
Strings to search. |
|
TextFilterList(EventList source,
TextFilterator filterator)
Deprecated. Creates a TextFilterList that filters the specified EventList
of elements using the specified TextFilterator to get the
Strings to search. |
|
TextFilterList(EventList source,
TextFilterator filterator,
JTextField filterEdit)
Deprecated. Creates a TextFilterList that filters the specified EventList
of elements using the specified TextFilterator to get the
Strings to search. |
|
| Method Summary | |
|---|---|
void |
dispose()
Deprecated. Releases the resources consumed by this TransformedList so that it
may eventually be garbage collected. |
ActionListener |
getFilterActionListener()
Deprecated. Gets an ActionListener that refilters the list when it is fired. |
JTextField |
getFilterEdit()
Deprecated. Gets the JTextField used to edit the filter search String. |
protected boolean |
isWritable()
Deprecated. Gets whether the source EventList is writable via this API. |
void |
listChanged(ListEvent listChanges)
Deprecated. When the underlying list changes, this notification allows the object to repaint itself or update itself as necessary. It is mandatory that the calling thread has obtained the write lock on the source list. This is because the calling thread will have written to the source list to cause this event. This condition guarantees that no writes can occur while the listener is handling this event. It is an error to write to the source list while processing an event. |
void |
setFilterEdit(JTextField filterEdit)
Deprecated. Sets the JTextField used to edit the filter search String. |
void |
setLive(boolean live)
Deprecated. Directs this filter to respond to changes to the JTextField as they are
made. |
| Methods inherited from class ca.odell.glazedlists.TransformedList |
|---|
add, addAll, clear, get, getSourceIndex, remove, removeAll, retainAll, set, size |
| Methods inherited from class ca.odell.glazedlists.AbstractEventList |
|---|
add, addAll, addListEventListener, contains, containsAll, equals, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeListEventListener, subList, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TextFilterList(EventList source)
TextFilterList that filters the specified EventList
of elements that implement the TextFilterable interface.
public TextFilterList(EventList source,
TextFilterator filterator)
TextFilterList that filters the specified EventList
of elements using the specified TextFilterator to get the
Strings to search.
public TextFilterList(EventList source,
String[] propertyNames)
TextFilterList that filters the specified EventList
of elements using the JavaBeans property names specified to get the
Strings to search.
Note that the classes which will be obfuscated may not work with
reflection. In this case, implement a TextFilterator manually.
propertyNames - an array of property names in the JavaBeans format.
For example, if your list contains Objects with the methods getFirstName(),
setFirstName(String), getAge(), setAge(Integer), then this array should
contain the two strings "firstName" and "age". This format is specified
by the JavaBeans PropertyDescriptor.
public TextFilterList(EventList source,
String[] propertyNames,
JTextField filterEdit)
TextFilterList that filters the specified EventList
of elements using the JavaBeans property names specified to get the
Strings to search.
Note that the classes which will be obfuscated may not work with
reflection. In this case, implement a TextFilterator manually.
propertyNames - an array of property names in the JavaBeans format.
For example, if your list contains Objects with the methods getFirstName(),
setFirstName(String), getAge(), setAge(Integer), then this array should
contain the two strings "firstName" and "age". This format is specified
by the JavaBeans PropertyDescriptor.filterEdit - a text field for typing in the filter text.
public TextFilterList(EventList source,
TextFilterator filterator,
JTextField filterEdit)
TextFilterList that filters the specified EventList
of elements using the specified TextFilterator to get the
Strings to search.
filterEdit - a text field for typing in the filter text.| Method Detail |
|---|
public JTextField getFilterEdit()
JTextField used to edit the filter search String.
public void setFilterEdit(JTextField filterEdit)
JTextField used to edit the filter search String.
public void setLive(boolean live)
JTextField as they are
made. This uses a DocumentListener and every time the
JTextField is modified, the list is refiltered.
To avoid the processing overhead of filtering for each keystroke, use
a not-live filter edit and trigger the ActionListener using a
button or by pressing ENTER in the JTextField.
public ActionListener getFilterActionListener()
ActionListener that refilters the list when it is fired. This
listener can be used to filter when the user presses a button.
public void listChanged(ListEvent listChanges)
It is mandatory that the calling thread has obtained the write lock on the source list. This is because the calling thread will have written to the source list to cause this event. This condition guarantees that no writes can occur while the listener is handling this event. It is an error to write to the source list while processing an event.
listChanged in interface ListEventListenerlistChanged in class TransformedListprotected boolean isWritable()
EventList is writable via this API.
Extending classes must override this method in order to make themselves writable.
isWritable in class TransformedListpublic void dispose()
TransformedList so that it
may eventually be garbage collected.
A TransformedList will be garbage collected without a call to
TransformedList.dispose(), but not before its source EventList is garbage
collected. By calling TransformedList.dispose(), you allow the TransformedList
to be garbage collected before its source EventList. This is
necessary for situations where a TransformedList is short-lived but
its source EventList is long-lived.
Warning: It is an error
to call any method on a TransformedList after it has been disposed.
dispose in class TransformedList
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||