/** * Sets whether "mark all" should be selected or enabled. This method * fires property change events of type {@link #PROPERTY_MARK_ALL}. * * @param markAll Whether "mark all" should be enabled. * @see #getMarkAll() */ public void setMarkAll(boolean markAll) { if (markAll!=this.markAll) { this.markAll = markAll; firePropertyChange(PROPERTY_MARK_ALL, !markAll, markAll); } }
/** * Sets whether case should be honored while searching. This method * fires a property change event of type {@link #PROPERTY_MATCH_CASE}. * * @param matchCase Whether case should be honored. * @see #getMatchCase() */ public void setMatchCase(boolean matchCase) { if (matchCase!=this.matchCase) { this.matchCase = matchCase; firePropertyChange(PROPERTY_MATCH_CASE, !matchCase, matchCase); } }
/** * Sets whether a regular expression search should be done.This method * fires a property change event of type {@link #PROPERTY_USE_REGEX}. * * @param regex Whether a regular expression search should be done. * @see #isRegularExpression() */ public void setRegularExpression(boolean regex) { if (regex!=this.regex) { this.regex = regex; firePropertyChange(PROPERTY_USE_REGEX, !regex, regex); } }
/** * Sets whether the search should be forward through the text (vs. * backwards). This method fires a property change event of type * {@link #PROPERTY_SEARCH_FORWARD}. * * @param forward Whether we should search forwards. * @see #getSearchForward() */ public void setSearchForward(boolean forward) { if (forward!=this.forward) { this.forward = forward; firePropertyChange(PROPERTY_SEARCH_FORWARD, !forward, forward); } }
/** * Sets whether only "whole word" matches should be returned. A match * is considered to be "whole word" if the character on either side of the * matched text is a non-word character, or if there is no character on * one side of the word, such as when it's at the beginning or end of a * line.This method fires a property change event of type * {@link #PROPERTY_MATCH_WHOLE_WORD}. * * @param wholeWord Whether only "whole word" matches should be returned. * @see #getWholeWord() */ public void setWholeWord(boolean wholeWord) { if (wholeWord!=this.wholeWord) { this.wholeWord = wholeWord; firePropertyChange(PROPERTY_MATCH_WHOLE_WORD, !wholeWord,wholeWord); } }
/** * Sets the text to search for. This method fires a property change * event of type {@link #PROPERTY_SEARCH_FOR}. * * @param searchFor The text to search for. * @see #getSearchFor() * @see #setReplaceWith(String) */ public void setSearchFor(String searchFor) { if ((searchFor==null && this.searchFor!=null) || (searchFor!=null && !searchFor.equals(this.searchFor))) { String old = this.searchFor; this.searchFor = searchFor; firePropertyChange(PROPERTY_SEARCH_FOR, old, searchFor); } }
/** * Sets the text to replace with, if doing a replace operation. This * method fires a property change event of type * {@link #PROPERTY_REPLACE_WITH}. * * @param replaceWith The text to replace with. * @see #getReplaceWith() * @see #setSearchFor(String) */ public void setReplaceWith(String replaceWith) { if ((replaceWith==null && this.replaceWith!=null) || (replaceWith!=null && !replaceWith.equals(this.replaceWith))) { String old = this.replaceWith; this.replaceWith = replaceWith; firePropertyChange(PROPERTY_REPLACE_WITH, old, replaceWith); } }
/** * Sets whether only the selected text should be searched. This method * fires a property change event of type {@link #PROPERTY_SELECTION_ONLY}. * <p> * * This flag is currently not supported. Calling this method will throw * an {@link UnsupportedOperationException} until it is implemented. * * @param selectionOnly Whether only selected text should be searched. * @see #getSearchSelectionOnly() */ public void setSearchSelectionOnly(boolean selectionOnly) { if (selectionOnly!=this.selectionOnly) { this.selectionOnly = selectionOnly; firePropertyChange(PROPERTY_SELECTION_ONLY, !selectionOnly, selectionOnly); if (selectionOnly) { throw new UnsupportedOperationException( "Searching in selection is not currently supported"); } } }
/** * Sets whether "mark all" should be selected or enabled. This method * fires property change events of type {@link #PROPERTY_MARK_ALL}. * * @param markAll Whether "mark all" should be enabled. * @see #getMarkAll() */ public void setMarkAll(boolean markAll) { if (markAll!=this.markAll) { this.markAll = markAll; firePropertyChange(PROPERTY_MARK_ALL, !markAll, markAll); } }
/** * Sets whether case should be honored while searching. This method * fires a property change event of type {@link #PROPERTY_MATCH_CASE}. * * @param matchCase Whether case should be honored. * @see #getMatchCase() */ public void setMatchCase(boolean matchCase) { if (matchCase!=this.matchCase) { this.matchCase = matchCase; firePropertyChange(PROPERTY_MATCH_CASE, !matchCase, matchCase); } }
/** * Sets whether a regular expression search should be done.This method * fires a property change event of type {@link #PROPERTY_USE_REGEX}. * * @param regex Whether a regular expression search should be done. * @see #isRegularExpression() */ public void setRegularExpression(boolean regex) { if (regex!=this.regex) { this.regex = regex; firePropertyChange(PROPERTY_USE_REGEX, !regex, regex); } }
/** * Sets whether the search should be forward through the text (vs. * backwards). This method fires a property change event of type * {@link #PROPERTY_SEARCH_FORWARD}. * * @param forward Whether we should search forwards. * @see #getSearchForward() */ public void setSearchForward(boolean forward) { if (forward!=this.forward) { this.forward = forward; firePropertyChange(PROPERTY_SEARCH_FORWARD, !forward, forward); } }
@Test public void testFirePropertyChange_stringArgs() { TestPropertyChangeListener pcl = new TestPropertyChangeListener(); SearchContext sc = new SearchContext(); sc.addPropertyChangeListener(pcl); sc.firePropertyChange("fooProp", "old", "new"); Assert.assertTrue(pcl.called); }
@Test public void testAddPropertyChangeListener() { TestPropertyChangeListener pcl = new TestPropertyChangeListener(); SearchContext sc = new SearchContext(); sc.addPropertyChangeListener(pcl); sc.firePropertyChange("fooProp", false, true); Assert.assertTrue(pcl.called); }
@Test public void testFirePropertyChange_booleanArgs() { TestPropertyChangeListener pcl = new TestPropertyChangeListener(); SearchContext sc = new SearchContext(); sc.addPropertyChangeListener(pcl); sc.firePropertyChange("fooProp", false, true); Assert.assertTrue(pcl.called); }
/** * Sets whether only "whole word" matches should be returned. A match * is considered to be "whole word" if the character on either side of the * matched text is a non-word character, or if there is no character on * one side of the word, such as when it's at the beginning or end of a * line.This method fires a property change event of type * {@link #PROPERTY_MATCH_WHOLE_WORD}. * * @param wholeWord Whether only "whole word" matches should be returned. * @see #getWholeWord() */ public void setWholeWord(boolean wholeWord) { if (wholeWord!=this.wholeWord) { this.wholeWord = wholeWord; firePropertyChange(PROPERTY_MATCH_WHOLE_WORD, !wholeWord,wholeWord); } }
@Test public void testRemovePropertyChangeListener() { TestPropertyChangeListener pcl = new TestPropertyChangeListener(); SearchContext sc = new SearchContext(); sc.addPropertyChangeListener(pcl); sc.removePropertyChangeListener(pcl); sc.firePropertyChange("fooProp", false, true); Assert.assertFalse(pcl.called); }
/** * Sets the text to search for. This method fires a property change * event of type {@link #PROPERTY_SEARCH_FOR}. * * @param searchFor The text to search for. * @see #getSearchFor() * @see #setReplaceWith(String) */ public void setSearchFor(String searchFor) { if ((searchFor==null && this.searchFor!=null) || (searchFor!=null && !searchFor.equals(this.searchFor))) { String old = this.searchFor; this.searchFor = searchFor; firePropertyChange(PROPERTY_SEARCH_FOR, old, searchFor); } }
/** * Sets the text to replace with, if doing a replace operation. This * method fires a property change event of type * {@link #PROPERTY_REPLACE_WITH}. * * @param replaceWith The text to replace with. * @see #getReplaceWith() * @see #setSearchFor(String) */ public void setReplaceWith(String replaceWith) { if ((replaceWith==null && this.replaceWith!=null) || (replaceWith!=null && !replaceWith.equals(this.replaceWith))) { String old = this.replaceWith; this.replaceWith = replaceWith; firePropertyChange(PROPERTY_REPLACE_WITH, old, replaceWith); } }
/** * Sets whether only the selected text should be searched. This method * fires a property change event of type {@link #PROPERTY_SELECTION_ONLY}. * <p> * * This flag is currently not supported. Calling this method will throw * an {@link UnsupportedOperationException} until it is implemented. * * @param selectionOnly Whether only selected text should be searched. * @see #getSearchSelectionOnly() */ public void setSearchSelectionOnly(boolean selectionOnly) { if (selectionOnly!=this.selectionOnly) { this.selectionOnly = selectionOnly; firePropertyChange(PROPERTY_SELECTION_ONLY, !selectionOnly, selectionOnly); if (selectionOnly) { throw new UnsupportedOperationException( "Searching in selection is not currently supported"); } } }