Package org.jdesktop.swingx.search
Class TableSearchable
- java.lang.Object
-
- org.jdesktop.swingx.search.AbstractSearchable
-
- org.jdesktop.swingx.search.TableSearchable
-
- All Implemented Interfaces:
Searchable
public class TableSearchable extends AbstractSearchable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jdesktop.swingx.search.AbstractSearchable
AbstractSearchable.SearchResult
-
-
Field Summary
Fields Modifier and Type Field Description protected JXTabletable-
Fields inherited from class org.jdesktop.swingx.search.AbstractSearchable
lastSearchResult, MATCH_HIGHLIGHTER, NO_MATCH
-
-
Constructor Summary
Constructors Constructor Description TableSearchable(JXTable table)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intadjustStartPosition(int startIndex, boolean backwards)Called if startIndex is different from last search, reset the column to -1 and make sure a backwards/forwards search starts at last/first row, respectively.protected AbstractHighlightercreateMatchHighlighter()protected AbstractSearchable.SearchResultfindExtendedMatch(java.util.regex.Pattern pattern, int row)called if sameRowIndex && !hasEqualRegEx.protected voidfindMatchAndUpdateState(java.util.regex.Pattern pattern, int startRow, boolean backwards)Loops through the searchable until a match is found or the end is reached.protected AbstractSearchable.SearchResultfindMatchAt(java.util.regex.Pattern pattern, int row, int column)Matches the cell content at row/col against the given Pattern.protected AbstractHighlightergetConfiguredMatchHighlighter()protected AbstractHighlightergetMatchHighlighter()protected intgetSize()returns the size of this searchable.protected booleanhasMatch(AbstractSearchable.SearchResult result)protected booleanisEqualStartIndex(int startIndex)Checks if the startIndex is a candidate for trying a re-match.protected booleanmarkByHighlighter()protected voidmoveMatchByHighlighter()use and move the match highlighter.protected voidmoveMatchBySelection()protected voidmoveMatchMarker()Moves the match marker according to current found state.protected intmoveStartPosition(int startRow, boolean backwards)Moves the internal start for matching as appropriate and returns the new startIndex to use.-
Methods inherited from class org.jdesktop.swingx.search.AbstractSearchable
createSearchResult, doSearch, isEmpty, isEqualPattern, isTrivialNoMatch, isValidIndex, search, search, search, search, search, search, updateState
-
-
-
-
Field Detail
-
table
protected JXTable table
-
-
Constructor Detail
-
TableSearchable
public TableSearchable(JXTable table)
- Parameters:
table-
-
-
Method Detail
-
findMatchAndUpdateState
protected void findMatchAndUpdateState(java.util.regex.Pattern pattern, int startRow, boolean backwards)Description copied from class:AbstractSearchableLoops through the searchable until a match is found or the end is reached. Updates internal search state.- Specified by:
findMatchAndUpdateStatein classAbstractSearchable- Parameters:
pattern-Patternthat we will try to locatestartRow- position in the document in the appropriate coordinates from which we will start search or -1 to start from the beginningbackwards-trueif we should perform search towards the beginning
-
findExtendedMatch
protected AbstractSearchable.SearchResult findExtendedMatch(java.util.regex.Pattern pattern, int row)
called if sameRowIndex && !hasEqualRegEx. Matches the cell at row/lastFoundColumn against the pattern. PRE: lastFoundColumn valid.- Specified by:
findExtendedMatchin classAbstractSearchable- Parameters:
pattern-row-- Returns:
- an appropriate
SearchResultif matching or null
-
findMatchAt
protected AbstractSearchable.SearchResult findMatchAt(java.util.regex.Pattern pattern, int row, int column)
Matches the cell content at row/col against the given Pattern. Returns an appropriate SearchResult if matching or null if no matching- Parameters:
pattern-row- a valid row index in view coordinatescolumn- a valid column index in view coordinates- Returns:
- an appropriate
SearchResultif matching or null
-
adjustStartPosition
protected int adjustStartPosition(int startIndex, boolean backwards)Called if startIndex is different from last search, reset the column to -1 and make sure a backwards/forwards search starts at last/first row, respectively.- Overrides:
adjustStartPositionin classAbstractSearchable- Parameters:
startIndex-backwards-- Returns:
- adjusted
startIndex
-
moveStartPosition
protected int moveStartPosition(int startRow, boolean backwards)Moves the internal start for matching as appropriate and returns the new startIndex to use. Called if search was messaged with the same startIndex as previously.- Overrides:
moveStartPositionin classAbstractSearchable- Parameters:
startRow-backwards-- Returns:
- new start index to use
-
isEqualStartIndex
protected boolean isEqualStartIndex(int startIndex)
Checks if the startIndex is a candidate for trying a re-match.- Overrides:
isEqualStartIndexin classAbstractSearchable- Parameters:
startIndex-- Returns:
- true if the startIndex should be re-matched, false if not.
-
getSize
protected int getSize()
Description copied from class:AbstractSearchablereturns the size of this searchable.- Specified by:
getSizein classAbstractSearchable- Returns:
- size of this searchable
-
moveMatchByHighlighter
protected void moveMatchByHighlighter()
use and move the match highlighter. PRE: markByHighlighter
-
getConfiguredMatchHighlighter
protected AbstractHighlighter getConfiguredMatchHighlighter()
- Returns:
- a highlighter configured for matching
-
hasMatch
protected boolean hasMatch(AbstractSearchable.SearchResult result)
- Parameters:
result-- Returns:
trueif theresultcontains a match;falseotherwise
-
moveMatchBySelection
protected void moveMatchBySelection()
-
moveMatchMarker
protected void moveMatchMarker()
Description copied from class:AbstractSearchableMoves the match marker according to current found state.- Specified by:
moveMatchMarkerin classAbstractSearchable
-
markByHighlighter
protected boolean markByHighlighter()
-
getMatchHighlighter
protected AbstractHighlighter getMatchHighlighter()
- Returns:
- a highlighter used for matching
-
createMatchHighlighter
protected AbstractHighlighter createMatchHighlighter()
- Returns:
- a highlighter used for matching
-
-