Package ca.odell.glazedlists.swing
Class TextComponentMatcherEditor<E>
- java.lang.Object
-
- ca.odell.glazedlists.matchers.AbstractMatcherEditorListenerSupport<E>
-
- ca.odell.glazedlists.matchers.AbstractMatcherEditor<E>
-
- ca.odell.glazedlists.matchers.TextMatcherEditor<E>
-
- ca.odell.glazedlists.swing.TextComponentMatcherEditor<E>
-
- All Implemented Interfaces:
MatcherEditor<E>
public class TextComponentMatcherEditor<E> extends TextMatcherEditor<E>
A MatcherEditor that matches Objects that contain the filter text located within aDocument
. ThisTextMatcherEditor
is directly coupled with a Document and fires MatcherEditor changes in response to Document changes. This matcher is fully concrete and is expected to be used by Swing applications.The
TextComponentMatcherEditor
constructors require that either aDocument
or aJTextComponent
(from which aDocument
is extracted) be specified.The MatcherEditor registers itself as a
DocumentListener
on the given Document, orActionListener
on theJTextComponent
for non-live filtering. If aJTextComponent
is given on construction, it is also watched for changes of its Document and the Document used by this MatcherEditor is updated to reflect the latest Document behind the text component. If this MatcherEditor must be garbage collected before the underlying Document, or JTextComponent, the listeners can be unregistered by callingdispose()
.- Author:
- James Lemieux
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ca.odell.glazedlists.matchers.MatcherEditor
MatcherEditor.Event<E>, MatcherEditor.Listener<E>
-
-
Field Summary
-
Fields inherited from class ca.odell.glazedlists.matchers.TextMatcherEditor
CONTAINS, EXACT, IDENTICAL_STRATEGY, NORMALIZED_STRATEGY, REGULAR_EXPRESSION, STARTS_WITH
-
-
Constructor Summary
Constructors Constructor Description TextComponentMatcherEditor(javax.swing.text.Document document, TextFilterator<? super E> textFilterator)
Creates a TextMatcherEditor bound to the givendocument
with the giventextFilterator
.TextComponentMatcherEditor(javax.swing.text.JTextComponent textComponent, TextFilterator<? super E> textFilterator)
Creates a TextMatcherEditor bound to theDocument
backing the giventextComponent
with the giventextFilterator
.TextComponentMatcherEditor(javax.swing.text.JTextComponent textComponent, TextFilterator<? super E> textFilterator, boolean live)
Creates a TextMatcherEditor bound to theDocument
backing the giventextComponent
with the giventextFilterator
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
A cleanup method which stops this MatcherEditor from listening to changes on the underlyingDocument
, thus freeing the MatcherEditor or Document to be garbage collected.boolean
isLive()
Whether filtering occurs by the keystroke or not.void
setLive(boolean live)
Toggle between filtering by the keystroke and not.-
Methods inherited from class ca.odell.glazedlists.matchers.TextMatcherEditor
getCurrentTextMatcher, getFilterator, getMode, getStrategy, setFilterator, setFilterText, setMode, setStrategy, setTextMatcher
-
Methods inherited from class ca.odell.glazedlists.matchers.AbstractMatcherEditor
fireChanged, fireConstrained, fireMatchAll, fireMatchNone, fireRelaxed, getMatcher, isCurrentlyMatchingAll, isCurrentlyMatchingNone
-
Methods inherited from class ca.odell.glazedlists.matchers.AbstractMatcherEditorListenerSupport
addMatcherEditorListener, createChangedEvent, createConstrainedEvent, createMatchAllEvent, createMatchNoneEvent, createRelaxedEvent, fireChangedMatcher, removeMatcherEditorListener
-
-
-
-
Constructor Detail
-
TextComponentMatcherEditor
public TextComponentMatcherEditor(javax.swing.text.JTextComponent textComponent, TextFilterator<? super E> textFilterator)
Creates a TextMatcherEditor bound to theDocument
backing the giventextComponent
with the giventextFilterator
.- Parameters:
textComponent
- the text component backed by theDocument
that is the source of text filter valuestextFilterator
- an object capable of producing Strings from the objects being filtered. IftextFilterator
isnull
then all filtered objects are expected to implementTextFilterable
.
-
TextComponentMatcherEditor
public TextComponentMatcherEditor(javax.swing.text.JTextComponent textComponent, TextFilterator<? super E> textFilterator, boolean live)
Creates a TextMatcherEditor bound to theDocument
backing the giventextComponent
with the giventextFilterator
.- Parameters:
textComponent
- the text component backed by theDocument
that is the source of text filter valuestextFilterator
- an object capable of producing Strings from the objects being filtered. IftextFilterator
isnull
then all filtered objects are expected to implementTextFilterable
.live
-true
to filter by the keystroke orfalse
to filter only whenEnter
is pressed within theJTextComponent
. Note that non-live filtering is only supported iftextComponent
is aJTextField
.- Throws:
java.lang.IllegalArgumentException
- if thetextComponent
is not aJTextField
and non-live filtering is specified.
-
TextComponentMatcherEditor
public TextComponentMatcherEditor(javax.swing.text.Document document, TextFilterator<? super E> textFilterator)
Creates a TextMatcherEditor bound to the givendocument
with the giventextFilterator
.- Parameters:
document
- theDocument
that is the source of text filter valuestextFilterator
- an object capable of producing Strings from the objects being filtered. IftextFilterator
isnull
then all filtered objects are expected to implementTextFilterable
.
-
-
Method Detail
-
isLive
public boolean isLive()
Whether filtering occurs by the keystroke or not.
-
setLive
public void setLive(boolean live)
Toggle between filtering by the keystroke and not.- Parameters:
live
-true
to filter by the keystroke orfalse
to filter only whenEnter
is pressed within theJTextComponent
. Note that non-live filtering is only supported iftextComponent
is aJTextField
.
-
dispose
public void dispose()
A cleanup method which stops this MatcherEditor from listening to changes on the underlyingDocument
, thus freeing the MatcherEditor or Document to be garbage collected.
-
-