/** * Ensure that the given Highlighter is the last in the list of * the highlighters registered on the target. * * @param highlighter the Highlighter to be inserted as last. */ protected void ensureInsertedSearchHighlighters(Highlighter highlighter) { if (!isInPipeline(highlighter)) { addHighlighter(highlighter); } }
/** * * {@inheritDoc} * <p> * * Overridden to adjust the column index to -1. */ @Override protected int adjustStartPosition(int startIndex, boolean backwards) { lastSearchResult.foundColumn = -1; return super.adjustStartPosition(startIndex, backwards); }
/** * Returns the Hihglighter to use as match marker, lazyly created if null. * * @return a highlighter used for matching, guaranteed to be not null. */ protected AbstractHighlighter getMatchHighlighter() { if (matchHighlighter == null) { matchHighlighter = createMatchHighlighter(); } return matchHighlighter; }
if (isTrivialNoMatch(pattern, startIndex)) { updateState(null); return lastSearchResult.foundRow; if (isEqualStartIndex(startIndex)) { // implies: the last found coordinates are valid if (!isEqualPattern(pattern)) { SearchResult searchResult = findExtendedMatch(pattern, startIndex); if (searchResult != null) { updateState(searchResult); return lastSearchResult.foundRow; startRow = moveStartPosition(startIndex, backwards); startRow = adjustStartPosition(startIndex, backwards); findMatchAndUpdateState(pattern, startRow, backwards); return lastSearchResult.foundRow;
/** * Configures and returns the match highlighter for the current match. * * @return a highlighter configured for matching */ protected AbstractHighlighter getConfiguredMatchHighlighter() { AbstractHighlighter searchHL = getMatchHighlighter(); searchHL.setHighlightPredicate(createMatchPredicate()); return searchHL; }
/** * Creates and returns a HighlightPredicate appropriate for the current * search result. * * @return a HighlightPredicate appropriate for the current search result. */ protected HighlightPredicate createMatchPredicate() { return hasMatch() ? new SearchPredicate(lastSearchResult.pattern, lastSearchResult.foundRow, convertColumnIndexToModel(lastSearchResult.foundColumn)) : HighlightPredicate.NEVER; }
/** * Returns a flag indicating if the given highlighter is last in the * list of highlighters registered on the target. If so returns true. * If not, it has the side-effect of removing the highlighter and returns false. * * @param searchHighlighter the highlighter to check for being last * @return a boolean indicating whether the highlighter is last. */ private boolean isInPipeline(Highlighter searchHighlighter) { Highlighter[] inPipeline = getHighlighters(); if ((inPipeline.length > 0) && (searchHighlighter.equals(inPipeline[inPipeline.length -1]))) { return true; } removeHighlighter(searchHighlighter); return false; }
/** * Performs a search starting at the given startIndex * using the pattern; {@link java.util.regex.Pattern}. * The search direction depends on the boolean parameter: * forward/backward if false/true, respectively.<p> * * Updates visible and internal search state. * * @param pattern <code>Pattern</code> that we will try to locate * @param startIndex position in the document in the appropriate coordinates * from which we will start search or -1 to start from the beginning * @param backwards <code>true</code> if we should perform search towards the beginning * @return the position of the match in appropriate coordinates or -1 if * no match found. */ @Override public int search(Pattern pattern, int startIndex, boolean backwards) { int matchingRow = doSearch(pattern, startIndex, backwards); moveMatchMarker(); return matchingRow; }
if (isTrivialNoMatch(pattern, startIndex)) { updateState(null); return lastSearchResult.foundRow; if (isEqualStartIndex(startIndex)) { // implies: the last found coordinates are valid if (!isEqualPattern(pattern)) { SearchResult searchResult = findExtendedMatch(pattern, startIndex); if (searchResult != null) { updateState(searchResult); return lastSearchResult.foundRow; startRow = moveStartPosition(startIndex, backwards); startRow = adjustStartPosition(startIndex, backwards); findMatchAndUpdateState(pattern, startRow, backwards); return lastSearchResult.foundRow;
/** * Configures and returns the match highlighter for the current match. * * @return a highlighter configured for matching */ protected AbstractHighlighter getConfiguredMatchHighlighter() { AbstractHighlighter searchHL = getMatchHighlighter(); searchHL.setHighlightPredicate(createMatchPredicate()); return searchHL; }
/** * Creates and returns a HighlightPredicate appropriate for the current * search result. * * @return a HighlightPredicate appropriate for the current search result. */ protected HighlightPredicate createMatchPredicate() { return hasMatch() ? new SearchPredicate(lastSearchResult.pattern, lastSearchResult.foundRow, convertColumnIndexToModel(lastSearchResult.foundColumn)) : HighlightPredicate.NEVER; }
/** * Returns a flag indicating if the given highlighter is last in the * list of highlighters registered on the target. If so returns true. * If not, it has the side-effect of removing the highlighter and returns false. * * @param searchHighlighter the highlighter to check for being last * @return a boolean indicating whether the highlighter is last. */ private boolean isInPipeline(Highlighter searchHighlighter) { Highlighter[] inPipeline = getHighlighters(); if ((inPipeline.length > 0) && (searchHighlighter.equals(inPipeline[inPipeline.length -1]))) { return true; } removeHighlighter(searchHighlighter); return false; }
/** * Performs a search starting at the given startIndex * using the pattern; {@link java.util.regex.Pattern}. * The search direction depends on the boolean parameter: * forward/backward if false/true, respectively.<p> * * Updates visible and internal search state. * * @param pattern <code>Pattern</code> that we will try to locate * @param startIndex position in the document in the appropriate coordinates * from which we will start search or -1 to start from the beginning * @param backwards <code>true</code> if we should perform search towards the beginning * @return the position of the match in appropriate coordinates or -1 if * no match found. */ @Override public int search(Pattern pattern, int startIndex, boolean backwards) { int matchingRow = doSearch(pattern, startIndex, backwards); moveMatchMarker(); return matchingRow; }
if (isTrivialNoMatch(pattern, startIndex)) { updateState(null); return lastSearchResult.foundRow; if (isEqualStartIndex(startIndex)) { // implies: the last found coordinates are valid if (!isEqualPattern(pattern)) { SearchResult searchResult = findExtendedMatch(pattern, startIndex); if (searchResult != null) { updateState(searchResult); return lastSearchResult.foundRow; startRow = moveStartPosition(startIndex, backwards); startRow = adjustStartPosition(startIndex, backwards); findMatchAndUpdateState(pattern, startRow, backwards); return lastSearchResult.foundRow;
/** * Configures and returns the match highlighter for the current match. * * @return a highlighter configured for matching */ protected AbstractHighlighter getConfiguredMatchHighlighter() { AbstractHighlighter searchHL = getMatchHighlighter(); searchHL.setHighlightPredicate(createMatchPredicate()); return searchHL; }
/** * Creates and returns a HighlightPredicate appropriate for the current * search result. * * @return a HighlightPredicate appropriate for the current search result. */ protected HighlightPredicate createMatchPredicate() { return hasMatch() ? new SearchPredicate(lastSearchResult.pattern, lastSearchResult.foundRow, convertColumnIndexToModel(lastSearchResult.foundColumn)) : HighlightPredicate.NEVER; }
/** * Ensure that the given Highlighter is the last in the list of * the highlighters registered on the target. * * @param highlighter the Highlighter to be inserted as last. */ protected void ensureInsertedSearchHighlighters(Highlighter highlighter) { if (!isInPipeline(highlighter)) { addHighlighter(highlighter); } }
/** * Returns a flag indicating if the given highlighter is last in the * list of highlighters registered on the target. If so returns true. * If not, it has the side-effect of removing the highlighter and returns false. * * @param searchHighlighter the highlighter to check for being last * @return a boolean indicating whether the highlighter is last. */ private boolean isInPipeline(Highlighter searchHighlighter) { Highlighter[] inPipeline = getHighlighters(); if ((inPipeline.length > 0) && (searchHighlighter.equals(inPipeline[inPipeline.length -1]))) { return true; } removeHighlighter(searchHighlighter); return false; }
/** * Performs a search starting at the given startIndex * using the pattern; {@link java.util.regex.Pattern}. * The search direction depends on the boolean parameter: * forward/backward if false/true, respectively.<p> * * Updates visible and internal search state. * * @param pattern <code>Pattern</code> that we will try to locate * @param startIndex position in the document in the appropriate coordinates * from which we will start search or -1 to start from the beginning * @param backwards <code>true</code> if we should perform search towards the beginning * @return the position of the match in appropriate coordinates or -1 if * no match found. */ public int search(Pattern pattern, int startIndex, boolean backwards) { int matchingRow = doSearch(pattern, startIndex, backwards); moveMatchMarker(); return matchingRow; }
/** * Returns the Hihglighter to use as match marker, lazyly created if null. * * @return a highlighter used for matching, guaranteed to be not null. */ protected AbstractHighlighter getMatchHighlighter() { if (matchHighlighter == null) { matchHighlighter = createMatchHighlighter(); } return matchHighlighter; }