public Searchable getSearchable() { if (searchable == null) { searchable = new TableSearchable(this); } return searchable; }
/** * Configures the match highlighter to the current match. Ensures that the * matched cell is visible, if there is a match. * * PRE: markByHighlighter * */ protected void moveMatchByHighlighter() { AbstractHighlighter searchHL = getConfiguredMatchHighlighter(); // no match if (!hasMatch()) { return; } else { ensureInsertedSearchHighlighters(searchHL); table.scrollCellToVisible(lastSearchResult.foundRow, lastSearchResult.foundColumn); } }
/** * {@inheritDoc} * <p> * * Implemented to search for an extension in the cell given by row and * foundColumn. */ @Override protected SearchResult findExtendedMatch(Pattern pattern, int row) { return findMatchAt(pattern, row, lastSearchResult.foundColumn); }
matchRow = findMatchBackwardsInRow(pattern, r); updateState(matchRow); for (int r = startRow; r <= getSize() && matchRow == null; r++) { matchRow = findMatchForwardInRow(pattern, r); updateState(matchRow);
/** * Searches forward through columns of the given row. Starts at * lastFoundColumn or first column if lastFoundColumn < 0. returns an * appropriate SearchResult if a matching cell is found in this row or null * if no match is found. A row index out off range results in a no-match. * * @param pattern <code>Pattern</code> that we will try to locate * @param row the row to search * @return an appropriate <code>SearchResult</code> if a matching cell is * found in this row or null if no match is found */ private SearchResult findMatchForwardInRow(Pattern pattern, int row) { int startColumn = (lastSearchResult.foundColumn < 0) ? 0 : lastSearchResult.foundColumn; if (isValidIndex(row)) { for (int column = startColumn; column < table.getColumnCount(); column++) { SearchResult result = findMatchAt(pattern, row, column); if (result != null) return result; } } return null; }
/** * {@inheritDoc} * <p> * * Overridden to convert the column index in the table's view coordinate * system to model coordinate. * <p> * * PENDING JW: this is only necessary because the SearchPredicate wants its * highlight column in model coordinates. But code comments in the * SearchPredicate seem to indicate that we probably want to revise that * (legacy?). */ @Override protected int convertColumnIndexToModel(int viewColumn) { return getTarget().convertColumnIndexToModel(viewColumn); }
/** * Matches the cell content at row/col against the given Pattern. Returns an * appropriate SearchResult if matching or null if no matching * * @param pattern <code>Pattern</code> that we will try to locate * @param row a valid row index in view coordinates * @param column a valid column index in view coordinates * @return an appropriate <code>SearchResult</code> if matching or null */ protected SearchResult findMatchAt(Pattern pattern, int row, int column) { String text = table.getStringAt(row, column); if ((text != null) && (text.length() > 0)) { Matcher matcher = pattern.matcher(text); if (matcher.find()) { return createSearchResult(matcher, row, column); } } return null; }
/** * Moves the row selection to the matching cell and ensures its visibility, * if any. Does nothing if there is no match. * */ protected void moveMatchBySelection() { if (!hasMatch()) { return; } int row = lastSearchResult.foundRow; int column = lastSearchResult.foundColumn; table.changeSelection(row, column, false, false); if (!table.getAutoscrolls()) { // scrolling not handled by moving selection Rectangle cellRect = table.getCellRect(row, column, true); if (cellRect != null) { table.scrollRectToVisible(cellRect); } } }
matchRow = findMatchBackwardsInRow(pattern, r); updateState(matchRow); for (int r = startRow; r <= getSize() && matchRow == null; r++) { matchRow = findMatchForwardInRow(pattern, r); updateState(matchRow);
/** * Searches forward through columns of the given row. Starts at * lastFoundColumn or first column if lastFoundColumn < 0. returns an * appropriate SearchResult if a matching cell is found in this row or null * if no match is found. A row index out off range results in a no-match. * * @param pattern <code>Pattern</code> that we will try to locate * @param row the row to search * @return an appropriate <code>SearchResult</code> if a matching cell is * found in this row or null if no match is found */ private SearchResult findMatchForwardInRow(Pattern pattern, int row) { int startColumn = (lastSearchResult.foundColumn < 0) ? 0 : lastSearchResult.foundColumn; if (isValidIndex(row)) { for (int column = startColumn; column < table.getColumnCount(); column++) { SearchResult result = findMatchAt(pattern, row, column); if (result != null) return result; } } return null; }
/** * {@inheritDoc} * <p> * * Overridden to convert the column index in the table's view coordinate * system to model coordinate. * <p> * * PENDING JW: this is only necessary because the SearchPredicate wants its * highlight column in model coordinates. But code comments in the * SearchPredicate seem to indicate that we probably want to revise that * (legacy?). */ @Override protected int convertColumnIndexToModel(int viewColumn) { return getTarget().convertColumnIndexToModel(viewColumn); }
/** * Matches the cell content at row/col against the given Pattern. Returns an * appropriate SearchResult if matching or null if no matching * * @param pattern <code>Pattern</code> that we will try to locate * @param row a valid row index in view coordinates * @param column a valid column index in view coordinates * @return an appropriate <code>SearchResult</code> if matching or null */ protected SearchResult findMatchAt(Pattern pattern, int row, int column) { String text = table.getStringAt(row, column); if ((text != null) && (text.length() > 0)) { Matcher matcher = pattern.matcher(text); if (matcher.find()) { return createSearchResult(matcher, row, column); } } return null; }
/** * Moves the row selection to the matching cell and ensures its visibility, * if any. Does nothing if there is no match. * */ protected void moveMatchBySelection() { if (!hasMatch()) { return; } int row = lastSearchResult.foundRow; int column = lastSearchResult.foundColumn; table.changeSelection(row, column, false, false); if (!table.getAutoscrolls()) { // scrolling not handled by moving selection Rectangle cellRect = table.getCellRect(row, column, true); if (cellRect != null) { table.scrollRectToVisible(cellRect); } } }
matchRow = findMatchBackwardsInRow(pattern, r); updateState(matchRow); for (int r = startRow; r <= getSize() && matchRow == null; r++) { matchRow = findMatchForwardInRow(pattern, r); updateState(matchRow);
/** * Configures the match highlighter to the current match. Ensures that the * matched cell is visible, if there is a match. * * PRE: markByHighlighter * */ protected void moveMatchByHighlighter() { AbstractHighlighter searchHL = getConfiguredMatchHighlighter(); // no match if (!hasMatch()) { return; } else { ensureInsertedSearchHighlighters(searchHL); table.scrollCellToVisible(lastSearchResult.foundRow, lastSearchResult.foundColumn); } }
/** * Searches forward through columns of the given row. Starts at * lastFoundColumn or first column if lastFoundColumn < 0. returns an * appropriate SearchResult if a matching cell is found in this row or null * if no match is found. A row index out off range results in a no-match. * * @param pattern <code>Pattern</code> that we will try to locate * @param row the row to search * @return an appropriate <code>SearchResult</code> if a matching cell is * found in this row or null if no match is found */ private SearchResult findMatchBackwardsInRow(Pattern pattern, int row) { int startColumn = (lastSearchResult.foundColumn < 0) ? table .getColumnCount() - 1 : lastSearchResult.foundColumn; if (isValidIndex(row)) { for (int column = startColumn; column >= 0; column--) { SearchResult result = findMatchAt(pattern, row, column); if (result != null) return result; } } return null; }
/** * Returns a Searchable for this component, guaranteed to be not null. This * implementation lazily creates a TableSearchable if necessary. * * * @return a not-null Searchable for this component. * * @see #setSearchable(Searchable) * @see org.jdesktop.swingx.search.TableSearchable */ public Searchable getSearchable() { if (searchable == null) { searchable = new TableSearchable(this); } return searchable; }
/** * {@inheritDoc} * <p> * * Implemented to search for an extension in the cell given by row and * foundColumn. */ @Override protected SearchResult findExtendedMatch(Pattern pattern, int row) { return findMatchAt(pattern, row, lastSearchResult.foundColumn); }
/** * {@inheritDoc} * <p> * * Overridden to convert the column index in the table's view coordinate * system to model coordinate. * <p> * * PENDING JW: this is only necessary because the SearchPredicate wants its * highlight column in model coordinates. But code comments in the * SearchPredicate seem to indicate that we probably want to revise that * (legacy?). */ @Override protected int convertColumnIndexToModel(int viewColumn) { return getTarget().convertColumnIndexToModel(viewColumn); }
/** * Matches the cell content at row/col against the given Pattern. Returns an * appropriate SearchResult if matching or null if no matching * * @param pattern <code>Pattern</code> that we will try to locate * @param row a valid row index in view coordinates * @param column a valid column index in view coordinates * @return an appropriate <code>SearchResult</code> if matching or null */ protected SearchResult findMatchAt(Pattern pattern, int row, int column) { String text = table.getStringAt(row, column); if ((text != null) && (text.length() > 0)) { Matcher matcher = pattern.matcher(text); if (matcher.find()) { return createSearchResult(matcher, row, column); } } return null; }