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. ThisTextMatcherEditoris 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
TextComponentMatcherEditorconstructors require that either aDocumentor aJTextComponent(from which aDocumentis extracted) be specified.The MatcherEditor registers itself as a
DocumentListeneron the given Document, orActionListeneron theJTextComponentfor non-live filtering. If aJTextComponentis 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 givendocumentwith the giventextFilterator.TextComponentMatcherEditor(javax.swing.text.JTextComponent textComponent, TextFilterator<? super E> textFilterator)Creates a TextMatcherEditor bound to theDocumentbacking the giventextComponentwith the giventextFilterator.TextComponentMatcherEditor(javax.swing.text.JTextComponent textComponent, TextFilterator<? super E> textFilterator, boolean live)Creates a TextMatcherEditor bound to theDocumentbacking the giventextComponentwith the giventextFilterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()A cleanup method which stops this MatcherEditor from listening to changes on the underlyingDocument, thus freeing the MatcherEditor or Document to be garbage collected.booleanisLive()Whether filtering occurs by the keystroke or not.voidsetLive(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 theDocumentbacking the giventextComponentwith the giventextFilterator.- Parameters:
textComponent- the text component backed by theDocumentthat is the source of text filter valuestextFilterator- an object capable of producing Strings from the objects being filtered. IftextFilteratorisnullthen 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 theDocumentbacking the giventextComponentwith the giventextFilterator.- Parameters:
textComponent- the text component backed by theDocumentthat is the source of text filter valuestextFilterator- an object capable of producing Strings from the objects being filtered. IftextFilteratorisnullthen all filtered objects are expected to implementTextFilterable.live-trueto filter by the keystroke orfalseto filter only whenEnteris pressed within theJTextComponent. Note that non-live filtering is only supported iftextComponentis aJTextField.- Throws:
java.lang.IllegalArgumentException- if thetextComponentis not aJTextFieldand non-live filtering is specified.
-
TextComponentMatcherEditor
public TextComponentMatcherEditor(javax.swing.text.Document document, TextFilterator<? super E> textFilterator)Creates a TextMatcherEditor bound to the givendocumentwith the giventextFilterator.- Parameters:
document- theDocumentthat is the source of text filter valuestextFilterator- an object capable of producing Strings from the objects being filtered. IftextFilteratorisnullthen 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-trueto filter by the keystroke orfalseto filter only whenEnteris pressed within theJTextComponent. Note that non-live filtering is only supported iftextComponentis 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.
-
-