# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: E:\NB_HG\main # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: o.openidex.util/manifest.mf --- o.openidex.util/manifest.mf Base (BASE) +++ o.openidex.util/manifest.mf Locally Modified (Based On LOCAL) @@ -1,5 +1,5 @@ Manifest-Version: 1.0 OpenIDE-Module: org.openidex.util/3 OpenIDE-Module-Localizing-Bundle: org/openidex/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 3.16 +OpenIDE-Module-Specification-Version: 3.20 AutoUpdate-Essential-Module: true Index: o.openidex.util/src/org/openidex/search/CompoundSearchInfo.java --- o.openidex.util/src/org/openidex/search/CompoundSearchInfo.java Base (BASE) +++ o.openidex.util/src/org/openidex/search/CompoundSearchInfo.java Locally Modified (Based On LOCAL) @@ -45,13 +45,14 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; /** * * @author Marian Petras */ -class CompoundSearchInfo implements SearchInfo { +class CompoundSearchInfo implements SearchInfo.Files { /** */ private final SearchInfo[] elements; @@ -88,8 +89,14 @@ /** */ public Iterator objectsToSearch() { + return Utils.toDataObjectIterator(filesToSearch()); + } + + /** + */ + public Iterator filesToSearch() { if (elements == null) { - return Collections.emptyList().iterator(); + return Collections.emptyList().iterator(); } List searchableElements = new ArrayList(elements.length); Index: o.openidex.util/src/org/openidex/search/CompoundSearchIterator.java --- o.openidex.util/src/org/openidex/search/CompoundSearchIterator.java Base (BASE) +++ o.openidex.util/src/org/openidex/search/CompoundSearchIterator.java Locally Modified (Based On LOCAL) @@ -43,22 +43,22 @@ import java.util.Iterator; import java.util.NoSuchElementException; -import org.openide.loaders.DataObject; +import org.openide.filesystems.FileObject; /** * * @author Marian Petras */ -class CompoundSearchIterator implements Iterator { +class CompoundSearchIterator implements Iterator { /** */ private final SearchInfo[] elements; /** */ private int elementIndex; /** */ - private Iterator elementIterator; + private Iterator elementIterator; /** */ - private DataObject nextObject; + private FileObject nextObject; /** */ private boolean upToDate; @@ -80,7 +80,7 @@ upToDate = true; //hasNext() returns always false } else { this.elements = elements; - elementIterator = elements[elementIndex = 0].objectsToSearch(); + elementIterator = Utils.getFileObjectsIterator(elements[elementIndex = 0]); upToDate = false; } } @@ -96,7 +96,7 @@ /** */ - public DataObject next() { + public FileObject next() { if (!hasNext()) { throw new NoSuchElementException(); } @@ -117,7 +117,7 @@ break; } - elementIterator = elements[elementIndex].objectsToSearch(); + elementIterator = Utils.getFileObjectsIterator(elements[elementIndex]); } if (elementIndex < elements.length) { Index: o.openidex.util/src/org/openidex/search/SearchInfo.java --- o.openidex.util/src/org/openidex/search/SearchInfo.java Base (BASE) +++ o.openidex.util/src/org/openidex/search/SearchInfo.java Locally Modified (Based On LOCAL) @@ -42,6 +42,7 @@ package org.openidex.search; import java.util.Iterator; +import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; /** @@ -98,4 +99,17 @@ */ public Iterator objectsToSearch(); + public interface Files extends SearchInfo{ + /** + * Specifies which FileObjects should be searched. + * The returned Iterator needn't implement method + * {@link java.util.Iterator#remove remove()} (i.e. it may throw + * UnsupportedOperationException instead of actual + * implementation). + * + * @return iterator which iterates over FileObjects + * to be searched + */ + public Iterator filesToSearch(); } +} Index: o.openidex.util/src/org/openidex/search/SimpleSearchInfo.java --- o.openidex.util/src/org/openidex/search/SimpleSearchInfo.java Base (BASE) +++ o.openidex.util/src/org/openidex/search/SimpleSearchInfo.java Locally Modified (Based On LOCAL) @@ -52,7 +52,7 @@ * * @author Marian Petras */ -class SimpleSearchInfo implements SearchInfo { +class SimpleSearchInfo implements SearchInfo.Files { /** * Empty search info object. @@ -61,14 +61,18 @@ * (returned by method * {@link SearchInfo#objectsToSearch objectsToSearch()}) has no elements. */ - static final SearchInfo EMPTY_SEARCH_INFO - = new SearchInfo() { + static final SearchInfo.Files EMPTY_SEARCH_INFO + = new SearchInfo.Files() { public boolean canSearch() { return true; } public Iterator objectsToSearch() { return Collections.emptyList().iterator(); } + + public Iterator filesToSearch() { + return Collections.emptyList().iterator(); + } }; /** */ @@ -112,6 +116,12 @@ /** */ public Iterator objectsToSearch() { + return Utils.toDataObjectIterator(filesToSearch()); + } + + /** + */ + public Iterator filesToSearch() { return new SimpleSearchIterator(rootFolder, recursive, filters != null ? Arrays.asList(filters) Index: o.openidex.util/src/org/openidex/search/SimpleSearchIterator.java --- o.openidex.util/src/org/openidex/search/SimpleSearchIterator.java Base (BASE) +++ o.openidex.util/src/org/openidex/search/SimpleSearchIterator.java Locally Modified (Based On LOCAL) @@ -48,16 +48,15 @@ import java.util.NoSuchElementException; import org.openide.filesystems.FileObject; import org.openide.loaders.DataFolder; -import org.openide.loaders.DataObject; /** * * @author Marian Petras */ -class SimpleSearchIterator implements Iterator { +class SimpleSearchIterator implements Iterator { /** current enumeration of children */ - private Enumeration childrenEnum; + private Enumeration childrenEnum; /** * filters to be applied on the current enumeration of children * ({@link #childrenEnum}) @@ -70,8 +69,8 @@ /** */ private final boolean recursive; /** stack of the ancestor folders' children enumerations */ - private final List> enums - = new ArrayList>(); //unsynced stack + private final List> enums + = new ArrayList>(); //unsynced stack /** * stack of filter lists to be applied on children of the ancestor folders * ({@link #enums}) @@ -84,14 +83,14 @@ * DataObject to be returned the next time method * {@link #next()} is called */ - private DataObject nextObject; + private FileObject nextObject; /** */ SimpleSearchIterator(DataFolder folder, boolean recursive, List filters) { - this.childrenEnum = folder.children(false); + this.childrenEnum = folder.getPrimaryFile().getChildren(false); this.recursive = recursive; this.filters = (filters != null) ? new ArrayList(filters) : null; @@ -108,7 +107,7 @@ /** */ - public DataObject next() { + public FileObject next() { if (!hasNext()) { throw new NoSuchElementException(); } @@ -124,8 +123,7 @@ assert childrenEnum != null; do { if (childrenEnum.hasMoreElements()) { - DataObject dataObject = childrenEnum.nextElement(); - FileObject file = dataObject.getPrimaryFile(); + FileObject file = childrenEnum.nextElement(); if (file.isFolder()) { if (!recursive) { continue; @@ -147,13 +145,13 @@ filterLists.add(null); } enums.add(childrenEnum); - childrenEnum = ((DataFolder) dataObject).children(false); + childrenEnum = file.getChildren(false); } else { if ((filters != null) && !checkFileFilters(file)) { continue; } - nextObject = dataObject; + nextObject = file; break; } } else { Index: o.openidex.util/src/org/openidex/search/SubnodesSearchInfo.java --- o.openidex.util/src/org/openidex/search/SubnodesSearchInfo.java Base (BASE) +++ o.openidex.util/src/org/openidex/search/SubnodesSearchInfo.java Locally Modified (Based On LOCAL) @@ -45,6 +45,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; import org.openide.nodes.Node; @@ -52,7 +53,7 @@ * * @author Marian Petras */ -final class SubnodesSearchInfo implements SearchInfo { +final class SubnodesSearchInfo implements SearchInfo.Files { /** */ private final Node node; @@ -80,28 +81,34 @@ /** */ public Iterator objectsToSearch() { + return Utils.toDataObjectIterator(filesToSearch()); + } + + /** + */ + public Iterator filesToSearch() { final Node[] nodes = node.getChildren().getNodes(true); if (nodes.length == 0) { - return SimpleSearchInfo.EMPTY_SEARCH_INFO.objectsToSearch(); + return Collections.emptyList().iterator(); } - List searchInfoElements = new ArrayList(nodes.length); + List searchInfoElements = new ArrayList(nodes.length); for (int i = 0; i < nodes.length; i++) { SearchInfo subInfo = Utils.getSearchInfo(nodes[i]); if (subInfo != null && subInfo.canSearch()) { - searchInfoElements.add(subInfo); + searchInfoElements.add((SearchInfo.Files)subInfo); } } final int size = searchInfoElements.size(); switch (size) { case 0: - return Collections.emptyList().iterator(); + return Collections.emptyList().iterator(); case 1: - return searchInfoElements.get(0).objectsToSearch(); + return searchInfoElements.get(0).filesToSearch(); default: return new CompoundSearchIterator( - searchInfoElements.toArray(new SearchInfo[size])); + searchInfoElements.toArray(new SearchInfo.Files[size])); } } Index: o.openidex.util/src/org/openidex/search/Utils.java --- o.openidex.util/src/org/openidex/search/Utils.java Base (BASE) +++ o.openidex.util/src/org/openidex/search/Utils.java Locally Modified (Based On LOCAL) @@ -41,14 +41,22 @@ package org.openidex.search; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import org.openide.filesystems.FileObject; import org.openide.loaders.DataFolder; +import org.openide.loaders.DataObject; +import org.openide.loaders.DataObjectNotFoundException; import org.openide.nodes.Node; +import org.openide.util.Exceptions; /** * * @author Marian Petras + * @author kaktus */ -final class Utils { +public final class Utils { /** */ @@ -72,4 +80,26 @@ } } + public static Iterator getFileObjectsIterator(SearchInfo si){ + if (si instanceof SearchInfo.Files){ + return ((SearchInfo.Files)si).filesToSearch(); + }else{ + Set set = new HashSet(); + for(Iterator iter = si.objectsToSearch(); iter.hasNext();){ + set.add(iter.next().getPrimaryFile()); } + return set.iterator(); + } + } + + static Iterator toDataObjectIterator(Iterator itFO){ + Set set = new HashSet(); + while(itFO.hasNext()){ + try { + set.add(DataObject.find(itFO.next())); + } catch (DataObjectNotFoundException ex){} + } + return set.iterator(); + } + +} Index: utilities/nbproject/project.xml --- utilities/nbproject/project.xml Base (BASE) +++ utilities/nbproject/project.xml Locally Modified (Based On LOCAL) @@ -183,7 +183,7 @@ 3 - 3.3 + 3.20 Index: utilities/src/org/netbeans/modules/search/BasicSearchCriteria.java --- utilities/src/org/netbeans/modules/search/BasicSearchCriteria.java Base (BASE) +++ utilities/src/org/netbeans/modules/search/BasicSearchCriteria.java Locally Modified (Based On LOCAL) @@ -561,13 +561,16 @@ * criteria, {@code false} otherwise */ boolean matches(DataObject dataObj) { + return matches(dataObj.getPrimaryFile()); + } + + boolean matches(FileObject fileObj) { lastCharset = null; - if (!dataObj.isValid()) { + if (!fileObj.isValid()) { return false; } - FileObject fileObj = dataObj.getPrimaryFile(); if (fileObj.isFolder() || !fileObj.isValid() || (isFullText() && !isTextFile(fileObj))) { return false; } @@ -580,7 +583,7 @@ /* Check the file's content: */ if (textPatternValid - && !checkFileContent(fileObj, dataObj)) { + && !checkFileContent(fileObj)) { return false; } @@ -639,10 +642,11 @@ * @return {@code true} if the file contains at least one substring * matching the pattern, {@code false} otherwise */ - private boolean checkFileContent(FileObject fileObj, DataObject dataObj) { + private boolean checkFileContent(FileObject fileObj) { boolean firstMatch = true; SearchPattern searchPattern = null; ArrayList txtDetails = null; + DataObject dObj = null; LineNumberReader reader = null; try { @@ -656,8 +660,9 @@ searchPattern = createSearchPattern(); txtDetails = new ArrayList(5); firstMatch = false; + dObj = DataObject.find(fileObj); } - TextDetail det = new TextDetail(dataObj, searchPattern); + TextDetail det = new TextDetail(dObj, searchPattern); det.setLine(reader.getLineNumber()); det.setLineText(line); int start = matcher.start(); @@ -669,7 +674,7 @@ } if (txtDetails != null) { txtDetails.trimToSize(); - getDetailsMap().put(dataObj, txtDetails); + getDetailsMap().put(dObj, txtDetails); return true; } else { return false; Index: utilities/src/org/netbeans/modules/search/SpecialSearchGroup.java --- utilities/src/org/netbeans/modules/search/SpecialSearchGroup.java Base (BASE) +++ utilities/src/org/netbeans/modules/search/SpecialSearchGroup.java Locally Modified (Based On LOCAL) @@ -44,15 +44,20 @@ import java.nio.charset.Charset; import java.util.Collection; import java.util.Iterator; +import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; -import org.openidex.search.DataObjectSearchGroup; +import org.openide.loaders.DataObjectNotFoundException; +import org.openide.util.Exceptions; +import org.openidex.search.FileObjectSearchGroup; +import org.openidex.search.SearchInfo; import org.openidex.search.SearchType; /** * * @author Marian Petras + * @author kaktus */ -final class SpecialSearchGroup extends DataObjectSearchGroup { +final class SpecialSearchGroup extends FileObjectSearchGroup { final BasicSearchCriteria basicCriteria; final boolean hasExtraSearchTypes; @@ -81,13 +86,23 @@ @Override public void doSearch() { - for (Iterator j = searchScope.getSearchInfo().objectsToSearch(); j.hasNext(); ) { + SearchInfo sInfo = searchScope.getSearchInfo(); + if (sInfo instanceof SearchInfo.Files){ + for (Iterator j = ((SearchInfo.Files)sInfo).filesToSearch(); j.hasNext(); ) { if (stopped) { return; } + processSearchObject(/*FileObject*/ j.next()); + } + }else{ + for (Iterator j = sInfo.objectsToSearch(); j.hasNext(); ) { + if (stopped) { + return; + } processSearchObject(/*DataObject*/ j.next()); } } + } /** * Provides search on one search object instance. The object is added to @@ -104,10 +119,21 @@ protected void processSearchObject(Object searchObject) { if (!hasExtraSearchTypes) { assert basicCriteria != null; + if (searchObject instanceof DataObject){ DataObject dataObj = (DataObject) searchObject; if (basicCriteria.matches(dataObj)) { notifyMatchingObjectFound(dataObj); } + } else if (searchObject instanceof FileObject){ + FileObject fileObj = (FileObject) searchObject; + if (basicCriteria.matches(fileObj)) { + try { + notifyMatchingObjectFound(DataObject.find(fileObj)); + } catch (DataObjectNotFoundException ex) { + Exceptions.printStackTrace(ex); + } + } + } return; }