This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 134558
Collapse All | Expand All

(-)a/java.project/nbproject/project.xml (-1 / +1 lines)
Lines 246-252 Link Here
246
                    <compile-dependency/>
246
                    <compile-dependency/>
247
                    <run-dependency>
247
                    <run-dependency>
248
                        <release-version>3</release-version>
248
                        <release-version>3</release-version>
249
                        <specification-version>3.3</specification-version>
249
                        <specification-version>3.20</specification-version>
250
                    </run-dependency>
250
                    </run-dependency>
251
                </dependency>
251
                </dependency>
252
            </module-dependencies>
252
            </module-dependencies>
(-)a/java.project/src/org/netbeans/spi/java/project/support/ui/PackageRootNode.java (-2 / +6 lines)
Lines 91-96 Link Here
91
import org.openide.util.lookup.ProxyLookup;
91
import org.openide.util.lookup.ProxyLookup;
92
import org.openidex.search.SearchInfo;
92
import org.openidex.search.SearchInfo;
93
import org.openidex.search.SearchInfoFactory;
93
import org.openidex.search.SearchInfoFactory;
94
import org.openidex.search.Utils;
94
95
95
/** Node displaying a packages in given SourceGroup
96
/** Node displaying a packages in given SourceGroup
96
 * @author Petr Hrebejk
97
 * @author Petr Hrebejk
Lines 449-455 Link Here
449
        return new AlwaysSearchableSearchInfo(i);
450
        return new AlwaysSearchableSearchInfo(i);
450
    }    
451
    }    
451
    
452
    
452
    private static final class AlwaysSearchableSearchInfo implements SearchInfo {
453
    private static final class AlwaysSearchableSearchInfo implements SearchInfo.Files {
453
        
454
        
454
        private final SearchInfo delegate;
455
        private final SearchInfo delegate;
455
        
456
        
Lines 464-470 Link Here
464
        public Iterator<DataObject> objectsToSearch() {
465
        public Iterator<DataObject> objectsToSearch() {
465
            return delegate.objectsToSearch();
466
            return delegate.objectsToSearch();
466
        }
467
        }
467
        
468
469
        public Iterator<FileObject> filesToSearch() {
470
            return Utils.getFileObjectsIterator(delegate);
471
        }
468
    }
472
    }
469
    
473
    
470
}
474
}
(-)a/o.openidex.util/apichanges.xml (-1 / +40 lines)
Lines 105-111 Link Here
105
105
106
  <changes>
106
  <changes>
107
107
108
 
108
       <change id="SearchUtils">
109
        <api name="search"/>
110
        <summary>Added utility class <code>Utils</code></summary>
111
        <version major="3" minor="20"/>
112
        <date day="13" month="1" year="2009"/>
113
        <author login="kaktus"/>
114
        <compatibility addition="yes"/>
115
        <description>
116
            <p>
117
                Class <code>Utils</code> made public with one public static method
118
                <code>getFileObjectsIterator(SearchInfo si)</code>. This utility
119
                method returns <code>Iterator</code> of <code>FileObject</code>s
120
                for the provided <code>SearchInfo</code>. This change simplifies
121
                the work with <code>SearchInfo</code> implementations.
122
            </p>
123
        </description>
124
        <class package="org.openidex.search" name="Utils"/>
125
    </change>
126
127
      <change id="SearchInfo.Files">
128
        <api name="search"/>
129
        <summary>Added interface <code>SearchInfo.Files</code></summary>
130
        <version major="3" minor="20"/>
131
        <date day="13" month="1" year="2009"/>
132
        <author login="kaktus"/>
133
        <compatibility addition="yes"/>
134
        <description>
135
            <p>
136
                Added <code>SearchInfo.Files</code> interface which extends
137
                <code>SearchInfo</code> interface. It adds method
138
                <code>filesToSearch()</code> to provide <code>FileObject</code>s
139
                which should be searched. This change allows to operate <code>FileObject</code>s
140
                in the search mechanism instead of <code>DataObject</code>s and
141
                as a result improves search performance.
142
            </p>
143
        </description>
144
        <class package="org.openidex.search" name="SearchInfo.Files"/>
145
        <issue number="134558"/>
146
    </change>
147
109
     <change id="SearchInfoFactory.createCompoundSearchInfo">
148
     <change id="SearchInfoFactory.createCompoundSearchInfo">
110
        <api name="search"/>
149
        <api name="search"/>
111
        <summary>Added method <code>createCompoundSearchInfo(...)</code>
150
        <summary>Added method <code>createCompoundSearchInfo(...)</code>
(-)a/o.openidex.util/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openidex.util/3
2
OpenIDE-Module: org.openidex.util/3
3
OpenIDE-Module-Localizing-Bundle: org/openidex/resources/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openidex/resources/Bundle.properties
4
OpenIDE-Module-Specification-Version: 3.16
4
OpenIDE-Module-Specification-Version: 3.20
5
AutoUpdate-Essential-Module: true
5
AutoUpdate-Essential-Module: true
(-)a/o.openidex.util/src/org/openidex/search/CompoundSearchInfo.java (-2 / +9 lines)
Lines 45-57 Link Here
45
import java.util.Collections;
45
import java.util.Collections;
46
import java.util.Iterator;
46
import java.util.Iterator;
47
import java.util.List;
47
import java.util.List;
48
import org.openide.filesystems.FileObject;
48
import org.openide.loaders.DataObject;
49
import org.openide.loaders.DataObject;
49
50
50
/**
51
/**
51
 *
52
 *
52
 * @author  Marian Petras
53
 * @author  Marian Petras
53
 */
54
 */
54
class CompoundSearchInfo implements SearchInfo {
55
class CompoundSearchInfo implements SearchInfo.Files {
55
56
56
    /** */
57
    /** */
57
    private final SearchInfo[] elements;
58
    private final SearchInfo[] elements;
Lines 88-95 Link Here
88
    /**
89
    /**
89
     */
90
     */
90
    public Iterator<DataObject> objectsToSearch() {
91
    public Iterator<DataObject> objectsToSearch() {
92
        return Utils.toDataObjectIterator(filesToSearch());
93
    }
94
95
    /**
96
     */
97
    public Iterator<FileObject> filesToSearch() {
91
        if (elements == null) {
98
        if (elements == null) {
92
            return Collections.<DataObject>emptyList().iterator();
99
            return Collections.<FileObject>emptyList().iterator();
93
        }
100
        }
94
        
101
        
95
        List<SearchInfo> searchableElements = new ArrayList<SearchInfo>(elements.length);
102
        List<SearchInfo> searchableElements = new ArrayList<SearchInfo>(elements.length);
(-)a/o.openidex.util/src/org/openidex/search/CompoundSearchIterator.java (-7 / +7 lines)
Lines 43-64 Link Here
43
43
44
import java.util.Iterator;
44
import java.util.Iterator;
45
import java.util.NoSuchElementException;
45
import java.util.NoSuchElementException;
46
import org.openide.loaders.DataObject;
46
import org.openide.filesystems.FileObject;
47
47
48
/**
48
/**
49
 *
49
 *
50
 * @author  Marian Petras
50
 * @author  Marian Petras
51
 */
51
 */
52
class CompoundSearchIterator implements Iterator<DataObject> {
52
class CompoundSearchIterator implements Iterator<FileObject> {
53
53
54
    /** */
54
    /** */
55
    private final SearchInfo[] elements;
55
    private final SearchInfo[] elements;
56
    /** */
56
    /** */
57
    private int elementIndex;
57
    private int elementIndex;
58
    /** */
58
    /** */
59
    private Iterator<DataObject> elementIterator;
59
    private Iterator<FileObject> elementIterator;
60
    /** */
60
    /** */
61
    private DataObject nextObject;
61
    private FileObject nextObject;
62
    /** */
62
    /** */
63
    private boolean upToDate;
63
    private boolean upToDate;
64
64
Lines 80-86 Link Here
80
            upToDate = true;                //hasNext() returns always false
80
            upToDate = true;                //hasNext() returns always false
81
        } else {
81
        } else {
82
            this.elements = elements;
82
            this.elements = elements;
83
            elementIterator = elements[elementIndex = 0].objectsToSearch();
83
            elementIterator = Utils.getFileObjectsIterator(elements[elementIndex = 0]);
84
            upToDate = false;
84
            upToDate = false;
85
        }
85
        }
86
    }
86
    }
Lines 96-102 Link Here
96
96
97
    /**
97
    /**
98
     */
98
     */
99
    public DataObject next() {
99
    public FileObject next() {
100
        if (!hasNext()) {
100
        if (!hasNext()) {
101
            throw new NoSuchElementException();
101
            throw new NoSuchElementException();
102
        }
102
        }
Lines 117-123 Link Here
117
                break;
117
                break;
118
            }
118
            }
119
            
119
            
120
            elementIterator = elements[elementIndex].objectsToSearch();
120
            elementIterator = Utils.getFileObjectsIterator(elements[elementIndex]);
121
        }
121
        }
122
        
122
        
123
        if (elementIndex < elements.length) {
123
        if (elementIndex < elements.length) {
(-)a/o.openidex.util/src/org/openidex/search/SearchInfo.java (-1 / +22 lines)
Lines 42-47 Link Here
42
package org.openidex.search;
42
package org.openidex.search;
43
43
44
import java.util.Iterator;
44
import java.util.Iterator;
45
import org.openide.filesystems.FileObject;
45
import org.openide.loaders.DataObject;
46
import org.openide.loaders.DataObject;
46
47
47
/**
48
/**
Lines 97-101 Link Here
97
     *          to be searched
98
     *          to be searched
98
     */
99
     */
99
    public Iterator<DataObject> objectsToSearch();
100
    public Iterator<DataObject> objectsToSearch();
100
    
101
102
    /**
103
     * Additionally defines which <code>FileObject</code>s should be searched.
104
     *
105
     * @since org.openidex.util/3 3.20
106
     * @author kaktus
107
     */
108
    public interface Files extends SearchInfo{
109
110
    /**
111
     * Specifies which <code>FileObject</code>s should be searched.
112
     * The returned <code>Iterator</code> needn't implement method
113
     * {@link java.util.Iterator#remove remove()} (i.e. it may throw
114
     * <code>UnsupportedOperationException</code> instead of actual
115
     * implementation).
116
     *
117
     * @return  iterator which iterates over <code>FileObject</code>s
118
     *          to be searched
119
     */
120
    public Iterator<FileObject> filesToSearch();
121
    }
101
}
122
}
(-)a/o.openidex.util/src/org/openidex/search/SimpleSearchInfo.java (-3 / +13 lines)
Lines 52-58 Link Here
52
 *
52
 *
53
 * @author  Marian Petras
53
 * @author  Marian Petras
54
 */
54
 */
55
class SimpleSearchInfo implements SearchInfo {
55
class SimpleSearchInfo implements SearchInfo.Files {
56
56
57
    /**
57
    /**
58
     * Empty search info object.
58
     * Empty search info object.
Lines 61-73 Link Here
61
     * (returned by method
61
     * (returned by method
62
     * {@link SearchInfo#objectsToSearch objectsToSearch()}) has no elements.
62
     * {@link SearchInfo#objectsToSearch objectsToSearch()}) has no elements.
63
     */
63
     */
64
    static final SearchInfo EMPTY_SEARCH_INFO
64
    static final SearchInfo.Files EMPTY_SEARCH_INFO
65
        = new SearchInfo() {
65
        = new SearchInfo.Files() {
66
            public boolean canSearch() {
66
            public boolean canSearch() {
67
                return true;
67
                return true;
68
            }
68
            }
69
            public Iterator<DataObject> objectsToSearch() {
69
            public Iterator<DataObject> objectsToSearch() {
70
                return Collections.<DataObject>emptyList().iterator();
70
                return Collections.<DataObject>emptyList().iterator();
71
            }
72
73
            public Iterator<FileObject> filesToSearch() {
74
                return Collections.<FileObject>emptyList().iterator();
71
            }
75
            }
72
        };
76
        };
73
        
77
        
Lines 112-117 Link Here
112
    /**
116
    /**
113
     */
117
     */
114
    public Iterator<DataObject> objectsToSearch() {
118
    public Iterator<DataObject> objectsToSearch() {
119
        return Utils.toDataObjectIterator(filesToSearch());
120
    }
121
122
    /**
123
     */
124
    public Iterator<FileObject> filesToSearch() {
115
        return new SimpleSearchIterator(rootFolder,
125
        return new SimpleSearchIterator(rootFolder,
116
                                        recursive,
126
                                        recursive,
117
                                        filters != null ? Arrays.asList(filters)
127
                                        filters != null ? Arrays.asList(filters)
(-)a/o.openidex.util/src/org/openidex/search/SimpleSearchIterator.java (-12 / +10 lines)
Lines 48-63 Link Here
48
import java.util.NoSuchElementException;
48
import java.util.NoSuchElementException;
49
import org.openide.filesystems.FileObject;
49
import org.openide.filesystems.FileObject;
50
import org.openide.loaders.DataFolder;
50
import org.openide.loaders.DataFolder;
51
import org.openide.loaders.DataObject;
52
51
53
/**
52
/**
54
 *
53
 *
55
 * @author  Marian Petras
54
 * @author  Marian Petras
56
 */
55
 */
57
class SimpleSearchIterator implements Iterator<DataObject> {
56
class SimpleSearchIterator implements Iterator<FileObject> {
58
57
59
    /** current enumeration of children */
58
    /** current enumeration of children */
60
    private Enumeration<DataObject> childrenEnum;
59
    private Enumeration<? extends FileObject> childrenEnum;
61
    /**
60
    /**
62
     * filters to be applied on the current enumeration of children
61
     * filters to be applied on the current enumeration of children
63
     * ({@link #childrenEnum})
62
     * ({@link #childrenEnum})
Lines 70-77 Link Here
70
    /** */
69
    /** */
71
    private final boolean recursive;
70
    private final boolean recursive;
72
    /** stack of the ancestor folders' children enumerations */
71
    /** stack of the ancestor folders' children enumerations */
73
    private final List<Enumeration<DataObject>> enums
72
    private final List<Enumeration<? extends FileObject>> enums
74
            = new ArrayList<Enumeration<DataObject>>();            //unsynced stack
73
            = new ArrayList<Enumeration<? extends FileObject>>();            //unsynced stack
75
    /**
74
    /**
76
     * stack of filter lists to be applied on children of the ancestor folders
75
     * stack of filter lists to be applied on children of the ancestor folders
77
     * ({@link #enums})
76
     * ({@link #enums})
Lines 84-97 Link Here
84
     * <code>DataObject</code> to be returned the next time method
83
     * <code>DataObject</code> to be returned the next time method
85
     * {@link #next()} is called
84
     * {@link #next()} is called
86
     */
85
     */
87
    private DataObject nextObject;
86
    private FileObject nextObject;
88
87
89
    /**
88
    /**
90
     */
89
     */
91
    SimpleSearchIterator(DataFolder folder,
90
    SimpleSearchIterator(DataFolder folder,
92
                         boolean recursive,
91
                         boolean recursive,
93
                         List<FileObjectFilter> filters) {
92
                         List<FileObjectFilter> filters) {
94
        this.childrenEnum = folder.children(false);
93
        this.childrenEnum = folder.getPrimaryFile().getChildren(false);
95
        this.recursive = recursive;
94
        this.recursive = recursive;
96
        this.filters = (filters != null) ? new ArrayList<FileObjectFilter>(filters)
95
        this.filters = (filters != null) ? new ArrayList<FileObjectFilter>(filters)
97
                                         : null;
96
                                         : null;
Lines 108-114 Link Here
108
107
109
    /** 
108
    /** 
110
     */
109
     */
111
    public DataObject next() {
110
    public FileObject next() {
112
        if (!hasNext()) {
111
        if (!hasNext()) {
113
            throw new NoSuchElementException();
112
            throw new NoSuchElementException();
114
        }
113
        }
Lines 124-131 Link Here
124
        assert childrenEnum != null;
123
        assert childrenEnum != null;
125
        do {
124
        do {
126
            if (childrenEnum.hasMoreElements()) {
125
            if (childrenEnum.hasMoreElements()) {
127
                DataObject dataObject = childrenEnum.nextElement();
126
                FileObject file = childrenEnum.nextElement();
128
                FileObject file = dataObject.getPrimaryFile();
129
                if (file.isFolder()) {
127
                if (file.isFolder()) {
130
                    if (!recursive) {
128
                    if (!recursive) {
131
                        continue;
129
                        continue;
Lines 147-159 Link Here
147
                        filterLists.add(null);
145
                        filterLists.add(null);
148
                    }
146
                    }
149
                    enums.add(childrenEnum);
147
                    enums.add(childrenEnum);
150
                    childrenEnum = ((DataFolder) dataObject).children(false);
148
                    childrenEnum = file.getChildren(false);
151
                } else {
149
                } else {
152
                    if ((filters != null) && !checkFileFilters(file)) {
150
                    if ((filters != null) && !checkFileFilters(file)) {
153
                        continue;
151
                        continue;
154
                    }
152
                    }
155
                    
153
                    
156
                    nextObject = dataObject;
154
                    nextObject = file;
157
                    break;
155
                    break;
158
                }
156
                }
159
            } else {
157
            } else {
(-)a/o.openidex.util/src/org/openidex/search/SubnodesSearchInfo.java (-4 / +11 lines)
Lines 45-50 Link Here
45
import java.util.Collections;
45
import java.util.Collections;
46
import java.util.Iterator;
46
import java.util.Iterator;
47
import java.util.List;
47
import java.util.List;
48
import org.openide.filesystems.FileObject;
48
import org.openide.loaders.DataObject;
49
import org.openide.loaders.DataObject;
49
import org.openide.nodes.Node;
50
import org.openide.nodes.Node;
50
51
Lines 52-58 Link Here
52
 *
53
 *
53
 * @author  Marian Petras
54
 * @author  Marian Petras
54
 */
55
 */
55
final class SubnodesSearchInfo implements SearchInfo {
56
final class SubnodesSearchInfo implements SearchInfo.Files {
56
57
57
    /** */
58
    /** */
58
    private final Node node;
59
    private final Node node;
Lines 80-88 Link Here
80
    /**
81
    /**
81
     */
82
     */
82
    public Iterator<DataObject> objectsToSearch() {
83
    public Iterator<DataObject> objectsToSearch() {
84
        return Utils.toDataObjectIterator(filesToSearch());
85
    }
86
87
    /**
88
     */
89
    public Iterator<FileObject> filesToSearch() {
83
        final Node[] nodes = node.getChildren().getNodes(true);
90
        final Node[] nodes = node.getChildren().getNodes(true);
84
        if (nodes.length == 0) {
91
        if (nodes.length == 0) {
85
            return SimpleSearchInfo.EMPTY_SEARCH_INFO.objectsToSearch();
92
            return SimpleSearchInfo.EMPTY_SEARCH_INFO.filesToSearch();
86
        }
93
        }
87
        
94
        
88
        List<SearchInfo> searchInfoElements = new ArrayList<SearchInfo>(nodes.length);
95
        List<SearchInfo> searchInfoElements = new ArrayList<SearchInfo>(nodes.length);
Lines 96-104 Link Here
96
        final int size = searchInfoElements.size();
103
        final int size = searchInfoElements.size();
97
        switch (size) {
104
        switch (size) {
98
            case 0:
105
            case 0:
99
                return Collections.<DataObject>emptyList().iterator();
106
                return Collections.<FileObject>emptyList().iterator();
100
            case 1:
107
            case 1:
101
                return searchInfoElements.get(0).objectsToSearch();
108
                return Utils.getFileObjectsIterator(searchInfoElements.get(0));
102
            default:
109
            default:
103
                return new CompoundSearchIterator(
110
                return new CompoundSearchIterator(
104
                        searchInfoElements.toArray(new SearchInfo[size]));
111
                        searchInfoElements.toArray(new SearchInfo[size]));
(-)a/o.openidex.util/src/org/openidex/search/Utils.java (-6 / +46 lines)
Lines 41-54 Link Here
41
41
42
package org.openidex.search;
42
package org.openidex.search;
43
43
44
import java.util.HashSet;
45
import java.util.Iterator;
46
import java.util.Set;
47
import org.openide.filesystems.FileObject;
44
import org.openide.loaders.DataFolder;
48
import org.openide.loaders.DataFolder;
49
import org.openide.loaders.DataObject;
50
import org.openide.loaders.DataObjectNotFoundException;
45
import org.openide.nodes.Node;
51
import org.openide.nodes.Node;
46
52
47
/**
53
 /**
48
 *
54
+ * Search API utility class.
49
 * @author  Marian Petras
55
  *
50
 */
56
+ * @since org.openidex.util/3 3.20
51
final class Utils {
57
  * @author  Marian Petras
58
+ * @author  cactus
59
  */
60
public final class Utils {
52
61
53
    /**
62
    /**
54
     */
63
     */
Lines 71-75 Link Here
71
                            SearchInfoFactory.VISIBILITY_FILTER });
80
                            SearchInfoFactory.VISIBILITY_FILTER });
72
        }
81
        }
73
    }
82
    }
74
    
83
84
    /**
85
     * Returns <code>Iterator</code> of <code>FileObject</code>'s for the provided <code>SearchInfo</code>.
86
     * If provided <code>SearchInfo</code> object is implementation of <code>SearchInfo.Files</code> interface
87
     * then the result of method <code>SearchInfo.Files.filesToSearch</code> is returned. Otherwise the objects
88
     * are getting from the <code>SearchInfo.objectsToSearch</code> method.
89
     *
90
     * @param si <code>SearchInfo</code> object to return the iterator for
91
     * @return iterator which iterates over <code>FileObject</code>s
92
     * @since org.openidex.util/3 3.20
93
     */
94
    public static Iterator<FileObject> getFileObjectsIterator(SearchInfo si){
95
        if (si instanceof SearchInfo.Files){
96
            return ((SearchInfo.Files)si).filesToSearch();
97
        }else{
98
            Set<FileObject> set = new HashSet<FileObject>();
99
            for(Iterator<DataObject> iter = si.objectsToSearch(); iter.hasNext();){
100
                set.add(iter.next().getPrimaryFile());
101
            }
102
            return set.iterator();
103
        }
104
    }
105
106
    static Iterator<DataObject> toDataObjectIterator(Iterator<FileObject> itFO){
107
        Set<DataObject> set = new HashSet<DataObject>();
108
        while(itFO.hasNext()){
109
            try {
110
                set.add(DataObject.find(itFO.next()));
111
            } catch (DataObjectNotFoundException ex){}
112
        }
113
        return set.iterator();
114
    }
75
}
115
}
(-)a/projectui/nbproject/project.xml (-1 / +1 lines)
Lines 211-217 Link Here
211
                    <compile-dependency/>
211
                    <compile-dependency/>
212
                    <run-dependency>
212
                    <run-dependency>
213
                        <release-version>3</release-version>
213
                        <release-version>3</release-version>
214
                        <specification-version>3.3</specification-version>
214
                        <specification-version>3.20</specification-version>
215
                    </run-dependency>
215
                    </run-dependency>
216
                </dependency>
216
                </dependency>
217
            </module-dependencies>
217
            </module-dependencies>
(-)a/projectui/src/org/netbeans/modules/project/ui/ProjectsRootNode.java (-2 / +6 lines)
Lines 97-102 Link Here
97
import org.openidex.search.FileObjectFilter;
97
import org.openidex.search.FileObjectFilter;
98
import org.openidex.search.SearchInfo;
98
import org.openidex.search.SearchInfo;
99
import org.openidex.search.SearchInfoFactory;
99
import org.openidex.search.SearchInfoFactory;
100
import org.openidex.search.Utils;
100
101
101
/** Root node for list of open projects
102
/** Root node for list of open projects
102
 */
103
 */
Lines 734-740 Link Here
734
        return new AlwaysSearchableSearchInfo(p);
735
        return new AlwaysSearchableSearchInfo(p);
735
    }
736
    }
736
    
737
    
737
    private static final class AlwaysSearchableSearchInfo implements SearchInfo {
738
    private static final class AlwaysSearchableSearchInfo implements SearchInfo.Files {
738
        
739
        
739
        private final SearchInfo delegate;
740
        private final SearchInfo delegate;
740
        
741
        
Lines 762-768 Link Here
762
        public Iterator<DataObject> objectsToSearch() {
763
        public Iterator<DataObject> objectsToSearch() {
763
            return delegate.objectsToSearch();
764
            return delegate.objectsToSearch();
764
        }
765
        }
766
767
        public Iterator<FileObject> filesToSearch() {
768
            return Utils.getFileObjectsIterator(delegate);
769
        }
765
        
770
        
766
    }
771
    }
767
    
768
}
772
}
(-)a/utilities.project/src/org/netbeans/modules/search/project/SearchScopeMainProject.java (-1 lines)
Lines 42-48 Link Here
42
package org.netbeans.modules.search.project;
42
package org.netbeans.modules.search.project;
43
43
44
import org.netbeans.api.project.Project;
44
import org.netbeans.api.project.Project;
45
import org.netbeans.api.project.ui.OpenProjects;
46
import org.netbeans.api.project.ui.OpenProjects;
45
import org.netbeans.api.project.ui.OpenProjects;
47
import org.openide.util.NbBundle;
46
import org.openide.util.NbBundle;
48
import org.openidex.search.SearchInfo;
47
import org.openidex.search.SearchInfo;
(-)a/utilities/nbproject/project.xml (-1 / +1 lines)
Lines 183-189 Link Here
183
                    <compile-dependency/>
183
                    <compile-dependency/>
184
                    <run-dependency>
184
                    <run-dependency>
185
                        <release-version>3</release-version>
185
                        <release-version>3</release-version>
186
                        <specification-version>3.3</specification-version>
186
                        <specification-version>3.20</specification-version>
187
                    </run-dependency>
187
                    </run-dependency>
188
                </dependency>
188
                </dependency>
189
            </module-dependencies>
189
            </module-dependencies>
(-)a/utilities/src/org/netbeans/modules/search/BasicSearchCriteria.java (-7 / +11 lines)
Lines 561-573 Link Here
561
     *          criteria, {@code false} otherwise
561
     *          criteria, {@code false} otherwise
562
     */
562
     */
563
    boolean matches(DataObject dataObj) {
563
    boolean matches(DataObject dataObj) {
564
        return matches(dataObj.getPrimaryFile());
565
    }
566
567
    boolean matches(FileObject fileObj) {
564
        lastCharset = null;
568
        lastCharset = null;
565
569
566
        if (!dataObj.isValid()) {
570
        if (!fileObj.isValid()) {
567
            return false;
571
            return false;
568
        }
572
        }
569
        
573
        
570
        FileObject fileObj = dataObj.getPrimaryFile();
571
        if (fileObj.isFolder() || !fileObj.isValid() || (isFullText() && !isTextFile(fileObj))) {
574
        if (fileObj.isFolder() || !fileObj.isValid() || (isFullText() && !isTextFile(fileObj))) {
572
            return false;
575
            return false;
573
        }
576
        }
Lines 580-586 Link Here
580
        
583
        
581
        /* Check the file's content: */
584
        /* Check the file's content: */
582
        if (textPatternValid
585
        if (textPatternValid
583
                && !checkFileContent(fileObj, dataObj)) {
586
                && !checkFileContent(fileObj)) {
584
            return false;
587
            return false;
585
        }
588
        }
586
        
589
        
Lines 635-648 Link Here
635
     * Checks whether the file's content matches the text pattern.
638
     * Checks whether the file's content matches the text pattern.
636
     * 
639
     * 
637
     * @param  fileObj  file whose content is to be checked
640
     * @param  fileObj  file whose content is to be checked
638
     * @param  dataObj  {@code DataObject} corresponding to the file
639
     * @return  {@code true} if the file contains at least one substring
641
     * @return  {@code true} if the file contains at least one substring
640
     *          matching the pattern, {@code false} otherwise
642
     *          matching the pattern, {@code false} otherwise
641
     */
643
     */
642
    private boolean checkFileContent(FileObject fileObj, DataObject dataObj) {
644
    private boolean checkFileContent(FileObject fileObj) {
643
        boolean firstMatch = true;
645
        boolean firstMatch = true;
644
        SearchPattern searchPattern = null;
646
        SearchPattern searchPattern = null;
645
        ArrayList<TextDetail> txtDetails = null;
647
        ArrayList<TextDetail> txtDetails = null;
648
        DataObject dObj = null;
646
649
647
        LineNumberReader reader = null;
650
        LineNumberReader reader = null;
648
        try {
651
        try {
Lines 656-663 Link Here
656
                        searchPattern = createSearchPattern();
659
                        searchPattern = createSearchPattern();
657
                        txtDetails = new ArrayList<TextDetail>(5);
660
                        txtDetails = new ArrayList<TextDetail>(5);
658
                        firstMatch = false;
661
                        firstMatch = false;
662
                        dObj = DataObject.find(fileObj);
659
                    }
663
                    }
660
                    TextDetail det = new TextDetail(dataObj, searchPattern);
664
                    TextDetail det = new TextDetail(dObj, searchPattern);
661
                    det.setLine(reader.getLineNumber());
665
                    det.setLine(reader.getLineNumber());
662
                    det.setLineText(line);
666
                    det.setLineText(line);
663
                    int start = matcher.start();
667
                    int start = matcher.start();
Lines 669-675 Link Here
669
            }
673
            }
670
            if (txtDetails != null) {
674
            if (txtDetails != null) {
671
                txtDetails.trimToSize();
675
                txtDetails.trimToSize();
672
                getDetailsMap().put(dataObj, txtDetails);
676
                getDetailsMap().put(dObj, txtDetails);
673
                return true;
677
                return true;
674
            } else {
678
            } else {
675
                return false;
679
                return false;
(-)a/utilities/src/org/netbeans/modules/search/SpecialSearchGroup.java (-9 / +35 lines)
Lines 45-52 Link Here
45
import java.util.Collection;
45
import java.util.Collection;
46
import java.util.Iterator;
46
import java.util.Iterator;
47
import java.util.LinkedList;
47
import java.util.LinkedList;
48
import org.openide.filesystems.FileObject;
48
import org.openide.loaders.DataObject;
49
import org.openide.loaders.DataObject;
49
import org.openidex.search.DataObjectSearchGroup;
50
import org.openidex.search.DataObjectSearchGroup;
51
import org.openide.loaders.DataObjectNotFoundException;
52
import org.openide.util.Exceptions;
53
import org.openidex.search.FileObjectSearchGroup;
54
import org.openidex.search.SearchInfo;
50
import org.openidex.search.SearchType;
55
import org.openidex.search.SearchType;
51
56
52
/**
57
/**
Lines 54-60 Link Here
54
 * @author  Marian Petras
59
 * @author  Marian Petras
55
 * @author  kaktus
60
 * @author  kaktus
56
 */
61
 */
57
final class SpecialSearchGroup extends DataObjectSearchGroup {
62
final class SpecialSearchGroup extends FileObjectSearchGroup {
58
63
59
    final BasicSearchCriteria basicCriteria;
64
    final BasicSearchCriteria basicCriteria;
60
    final boolean hasExtraSearchTypes;
65
    final boolean hasExtraSearchTypes;
Lines 86-96 Link Here
86
    @Override
91
    @Override
87
    protected void prepareSearch(){
92
    protected void prepareSearch(){
88
        searchItems = new LinkedList();
93
        searchItems = new LinkedList();
89
        for (Iterator<DataObject> j = searchScope.getSearchInfo().objectsToSearch(); j.hasNext(); ) {
94
        SearchInfo sInfo = searchScope.getSearchInfo();
90
            if (stopped) {
95
        if (sInfo instanceof SearchInfo.Files){
91
                return;
96
            for (Iterator j = ((SearchInfo.Files)sInfo).filesToSearch(); j.hasNext(); ) {
97
                if (stopped) {
98
                    return;
99
                }
100
                searchItems.add(j.next());
92
            }
101
            }
93
            searchItems.add(j.next());
102
        } else {
103
            for (Iterator<DataObject> j = sInfo.objectsToSearch(); j.hasNext(); ) {
104
                if (stopped) {
105
                    return;
106
                }
107
                searchItems.add(j.next());
108
            }
94
        }
109
        }
95
    }
110
    }
96
111
Lines 102-108 Link Here
102
            if (stopped) {
117
            if (stopped) {
103
                return;
118
                return;
104
            }
119
            }
105
            processSearchObject(/*DataObject*/ searchItems.poll());
120
            processSearchObject(searchItems.poll());
106
            notifyProgress(index++);
121
            notifyProgress(index++);
107
        }
122
        }
108
    }
123
    }
Lines 122-130 Link Here
122
    protected void processSearchObject(Object searchObject) {
137
    protected void processSearchObject(Object searchObject) {
123
        if (!hasExtraSearchTypes) {
138
        if (!hasExtraSearchTypes) {
124
            assert basicCriteria != null;
139
            assert basicCriteria != null;
125
            DataObject dataObj = (DataObject) searchObject;
140
            if (searchObject instanceof DataObject){
126
            if (basicCriteria.matches(dataObj)) {
141
                DataObject dataObj = (DataObject) searchObject;
127
                notifyMatchingObjectFound(dataObj);
142
                if (basicCriteria.matches(dataObj)) {
143
                    notifyMatchingObjectFound(dataObj);
144
                }
145
            } else if (searchObject instanceof FileObject){
146
                FileObject fileObj = (FileObject) searchObject;
147
                if (basicCriteria.matches(fileObj)) {
148
                    try {
149
                        notifyMatchingObjectFound(DataObject.find(fileObj));
150
                    } catch (DataObjectNotFoundException ex) {
151
                        Exceptions.printStackTrace(ex);
152
                    }
153
                }
128
            }
154
            }
129
            return;
155
            return;
130
        }
156
        }

Return to bug 134558