cvs diff -N cvs server: Diffing . cvs server: Diffing api Index: api/apichanges.xml =================================================================== RCS file: /cvs/openidex/api/apichanges.xml,v retrieving revision 1.2 diff -r1.2 apichanges.xml 80a81,100 > Added SearchHistory and SearchPattern classes > > > > > >

> Editor find and replace dialog and search over files > in explorer should have one and shareable history. Editor module should > be notified about last selected search expression to highlight(in yellow) > the matched patterns. >

>
> > > > > > > cvs server: Diffing enode cvs server: Diffing enode/src cvs server: Diffing enode/src/org cvs server: Diffing enode/src/org/netbeans cvs server: Diffing enode/src/org/netbeans/api cvs server: Diffing enode/src/org/netbeans/api/enode cvs server: Diffing enode/src/org/netbeans/modules cvs server: Diffing enode/src/org/netbeans/modules/enode cvs server: Diffing enode/src/org/netbeans/spi cvs server: Diffing enode/src/org/netbeans/spi/enode cvs server: Diffing enode/test cvs server: Diffing enode/test/unit cvs server: Diffing enode/test/unit/src cvs server: Diffing enode/test/unit/src/org cvs server: Diffing enode/test/unit/src/org/netbeans cvs server: Diffing enode/test/unit/src/org/netbeans/modules cvs server: Diffing enode/test/unit/src/org/netbeans/modules/enode cvs server: Diffing enode/test/unit/src/org/netbeans/modules/enode/test cvs server: Diffing nbproject cvs server: Diffing src cvs server: Diffing src/org cvs server: Diffing src/org/openidex cvs server: Diffing src/org/openidex/resources cvs server: Diffing src/org/openidex/search Index: src/org/openidex/search/SearchHistory.java =================================================================== RCS file: src/org/openidex/search/SearchHistory.java diff -N src/org/openidex/search/SearchHistory.java 0a1,125 > /* > * Sun Public License Notice > * > * The contents of this file are subject to the Sun Public License > * Version 1.0 (the "License"). You may not use this file except in > * compliance with the License. A copy of the License is available at > * http://www.sun.com/ > * > * The Original Code is NetBeans. The Initial Developer of the Original > * Code is Sun Microsystems, Inc. Portions Copyright 2005 Sun > * Microsystems, Inc. All Rights Reserved. > */ > > package org.openidex.search; > > import java.beans.PropertyChangeListener; > import java.beans.PropertyChangeSupport; > import java.util.ArrayList; > import java.util.Collections; > import java.util.List; > > /** > * Shareable search history. Known implementations are explorer search > * dialog and editor find&replace dialog. > * > * Typical use case: > * Editor registers a listener to listen on lastSelected SearchPattern. If user > * opens explorer's search dialog and perform search, a search expression is added > * into SearchHistory and lastSelected SearchPattern is setted. The event is fired, > * editor can retrieve lastSelected SearchPattern and in accordance with its parameters > * it can highlight(in yellow) all matched patterns. If editor dialog is open, > * it contains shareable SearchHistory. Another direction is search in editor, that > * adds a SearchPattern in SearchHistory, thus the new item is available also in > * explorer's search dialog. > * > * @since org.openidex.util/3 3.5, NB 4.1 > * @author Martin Roskanin > */ > public final class SearchHistory { > > /** Last selected SearchPattern. */ > private SearchPattern lastSelected; > > /** Support for listeners */ > private PropertyChangeSupport pcs; > > /** Maximum items allowed in searchPatternsList */ > private static final int MAX_SEARCH_PATTERNS_ITEMS = 50; > > /** Shareable SearchPattern history. It is a List of SearchPatterns */ > private List searchPatternsList = new ArrayList(MAX_SEARCH_PATTERNS_ITEMS); > > /** Singleton instance */ > private static SearchHistory INSTANCE = null; > > /** Property name for last selected search pattern */ > public final static String LAST_SELECTED_SEARCH_PATTERN = "last-selected-search-pattern"; //NOI18N > > /** Creates a new instance of SearchHistory */ > private SearchHistory() { > } > > /** @return singleton instance of SearchHistory */ > public synchronized static SearchHistory getDefault(){ > if (INSTANCE == null) { > INSTANCE = new SearchHistory(); > } > return INSTANCE; > } > > /** @return last selected SearchPattern */ > public SearchPattern getLastSelected(){ > return lastSelected; > } > > /** Sets last selected SearchPattern > * @param pattern last selected pattern > */ > public void setLastSelected(SearchPattern pattern){ > SearchPattern oldPattern = this.lastSelected; > this.lastSelected = pattern; > if (pcs != null){ > pcs.firePropertyChange(LAST_SELECTED_SEARCH_PATTERN, oldPattern, pattern); > } > } > > private synchronized PropertyChangeSupport getPropertyChangeSupport(){ > if (pcs == null){ > pcs = new PropertyChangeSupport(this); > } > return pcs; > } > > /** Adds a property change listener. > * @param pcl the listener to add > */ > public void addPropertyChangeListener(PropertyChangeListener pcl){ > getPropertyChangeSupport().addPropertyChangeListener(pcl); > } > > /** Removes a property change listener. > * @param pcl the listener to remove > */ > public void removePropertyChangeListener(PropertyChangeListener pcl){ > if (pcs != null){ > pcs.removePropertyChangeListener(pcl); > } > } > > /** @return unmodifiable List of SearchPatterns */ > public synchronized List/*SearchPattern*/ getSearchPatterns(){ > return Collections.unmodifiableList(searchPatternsList); > } > > /** Adds SearchPattern to SearchHistory > * @param pattern the SearchPattern to add > */ > public synchronized void add(SearchPattern pattern){ > if (searchPatternsList.size() == MAX_SEARCH_PATTERNS_ITEMS){ > searchPatternsList.remove(MAX_SEARCH_PATTERNS_ITEMS-1); > } > searchPatternsList.add(0, pattern); > } > > } Index: src/org/openidex/search/SearchPattern.java =================================================================== RCS file: src/org/openidex/search/SearchPattern.java diff -N src/org/openidex/search/SearchPattern.java 0a1,82 > /* > * Sun Public License Notice > * > * The contents of this file are subject to the Sun Public License > * Version 1.0 (the "License"). You may not use this file except in > * compliance with the License. A copy of the License is available at > * http://www.sun.com/ > * > * The Original Code is NetBeans. The Initial Developer of the Original > * Code is Sun Microsystems, Inc. Portions Copyright 2005 Sun > * Microsystems, Inc. All Rights Reserved. > */ > > package org.openidex.search; > > /** > * Pattern describes the search conditions > * > * @since org.openidex.util/3 3.5, NB 4.1 > * @author Martin Roskanin > */ > public final class SearchPattern { > > /** SearchExpression - a text to search */ > private String searchExpression; > > /** if true, only whole words were searched */ > private boolean wholeWords; > > /** if true, case sensitive search was preformed */ > private boolean matchCase; > > /** if true, regular expression search was performed */ > private boolean regExp; > > /** Creates a new instance of SearchPattern > * @param searchExpression a searched text > * @param wholeWords if true, only whole words were searched > * @param matchCase if true, case sensitive search was preformed > * @param regExp if true, regular expression search was performed > */ > private SearchPattern(String searchExpression, boolean wholeWords, > boolean matchCase, boolean regExp) { > this.searchExpression = searchExpression; > this.wholeWords = wholeWords; > this.matchCase = matchCase; > this.regExp = regExp; > } > > /** Creates a new SearchPattern in accordance with given parameters > * @param searchExpression a searched text > * @param wholeWords if true, only whole words were searched > * @param matchCase if true, case sensitive search was preformed > * @param regExp if true, regular expression search was performed > * @return a new SearchPattern in accordance with given parameters > */ > public static SearchPattern create(String searchExpression, boolean wholeWords, > boolean matchCase, boolean regExp){ > return new SearchPattern(searchExpression, wholeWords, matchCase, regExp); > } > > /** @return searchExpression */ > public String getSearchExpression(){ > return searchExpression; > } > > /** @return true if the wholeWords parameter was used during search performing */ > public boolean isWholeWords(){ > return wholeWords; > } > > /** @return true if the matchCase parameter was used during search performing */ > public boolean isMatchCase(){ > return matchCase; > } > > /** @return true if the regExp parameter was used during search performing */ > public boolean isRegExp(){ > return regExp; > } > > } cvs server: Diffing src/org/openidex/search/res cvs server: Diffing test cvs server: Diffing test/unit cvs server: Diffing test/unit/data cvs server: Diffing test/unit/data/goldenfiles cvs server: Diffing test/unit/data/goldenfiles/org cvs server: Diffing test/unit/data/goldenfiles/org/openidex cvs server: Diffing test/unit/data/goldenfiles/org/openidex/search cvs server: Diffing test/unit/data/goldenfiles/org/openidex/search/SearchIteratorTest cvs server: Diffing test/unit/data/projects cvs server: Diffing test/unit/data/projects/Project1 cvs server: Diffing test/unit/data/projects/Project1/nbproject cvs server: Diffing test/unit/data/projects/Project1/nbproject/private cvs server: Diffing test/unit/data/projects/Project1/src cvs server: Diffing test/unit/data/projects/Project1/src/foo cvs server: Diffing test/unit/data/projects/Project1/src/foo/bar cvs server: Diffing test/unit/data/projects/Project1/src/foo/bar/baz cvs server: Diffing test/unit/data/projects/Project1/test cvs server: Diffing test/unit/data/projects/Project1/test/abc cvs server: Diffing test/unit/data/projects/Project1/test/abc/xyz cvs server: Diffing test/unit/src cvs server: Diffing test/unit/src/org cvs server: Diffing test/unit/src/org/openidex cvs server: Diffing test/unit/src/org/openidex/search Index: test/unit/src/org/openidex/search/SearchHistoryTest.java =================================================================== RCS file: test/unit/src/org/openidex/search/SearchHistoryTest.java diff -N test/unit/src/org/openidex/search/SearchHistoryTest.java 0a1,69 > /* > * Sun Public License Notice > * > * The contents of this file are subject to the Sun Public License > * Version 1.0 (the "License"). You may not use this file except in > * compliance with the License. A copy of the License is available at > * http://www.sun.com/ > * > * The Original Code is NetBeans. The Initial Developer of the Original > * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun > * Microsystems, Inc. All Rights Reserved. > */ > > package org.openidex.search; > > import java.beans.PropertyChangeEvent; > import java.beans.PropertyChangeListener; > import junit.textui.TestRunner; > import org.netbeans.junit.NbTestCase; > import org.netbeans.junit.NbTestSuite; > > > /** > * > * @author Martin Roskanin > */ > public final class SearchHistoryTest extends NbTestCase { > > > /** > */ > public SearchHistoryTest(String name) { > super(name); > } > > /** > */ > public static void main(String args[]) { > TestRunner.run(new NbTestSuite(SearchHistoryTest.class)); > } > > > /** > */ > public void testSearchPatternSize() throws Exception { > assertSize("SearchPattern size", 80, SearchPattern.create("searchText",true,true,false)); > } > > public void testSearchHistoryListSize() throws Exception{ > for (int i = 0; i<60; i++){ > SearchHistory.getDefault().add(SearchPattern.create(String.valueOf(i),true,true,false)); > } > assertTrue(SearchHistory.getDefault().getSearchPatterns().size() == 50); > } > > public void testSearchHistoryListener() throws Exception{ > final boolean fired[] = new boolean[1]; > fired[0] = false; > PropertyChangeListener pcl = new PropertyChangeListener(){ > public void propertyChange(PropertyChangeEvent evt){ > fired[0] = true; > } > }; > SearchHistory.getDefault().addPropertyChangeListener(pcl); > SearchHistory.getDefault().setLastSelected(SearchPattern.create("searchtext",true,true,false)); > SearchHistory.getDefault().removePropertyChangeListener(pcl); > assertTrue(fired[0]); > } > } cvs server: Diffing www cvs server: Diffing www/proposals cvs server: Diffing www/proposals/api-changes cvs server: Diffing www/proposals/api-changes/SearchInfo cvs server: Diffing www/proposals/looks cvs server: Diffing www/proposals/looks/images *****CVS exited normally with code 1*****