Lines 16-26
Link Here
|
16 |
import java.beans.PropertyChangeEvent; |
16 |
import java.beans.PropertyChangeEvent; |
17 |
import java.beans.PropertyChangeListener; |
17 |
import java.beans.PropertyChangeListener; |
18 |
import java.util.ArrayList; |
18 |
import java.util.ArrayList; |
19 |
import java.util.Collection; |
|
|
20 |
import java.util.Collections; |
21 |
import java.util.Iterator; |
22 |
import java.util.List; |
19 |
import java.util.List; |
23 |
import java.util.Set; |
|
|
24 |
import org.netbeans.api.project.Project; |
20 |
import org.netbeans.api.project.Project; |
25 |
import org.netbeans.api.project.ProjectUtils; |
21 |
import org.netbeans.api.project.ProjectUtils; |
26 |
import org.netbeans.api.project.SourceGroup; |
22 |
import org.netbeans.api.project.SourceGroup; |
Lines 28-36
Link Here
|
28 |
import org.netbeans.api.project.ui.OpenProjects; |
24 |
import org.netbeans.api.project.ui.OpenProjects; |
29 |
import org.netbeans.modules.search.SearchPanel; |
25 |
import org.netbeans.modules.search.SearchPanel; |
30 |
import org.netbeans.modules.search.SearchPerformer; |
26 |
import org.netbeans.modules.search.SearchPerformer; |
31 |
import org.openide.ErrorManager; |
27 |
import org.openide.filesystems.FileObject; |
32 |
import org.openide.loaders.DataObject; |
|
|
33 |
import org.openide.loaders.DataObjectNotFoundException; |
34 |
import org.openide.nodes.AbstractNode; |
28 |
import org.openide.nodes.AbstractNode; |
35 |
import org.openide.nodes.Children; |
29 |
import org.openide.nodes.Children; |
36 |
|
30 |
|
Lines 39-45
Link Here
|
39 |
import org.openide.util.HelpCtx; |
33 |
import org.openide.util.HelpCtx; |
40 |
import org.openide.util.NbBundle; |
34 |
import org.openide.util.NbBundle; |
41 |
import org.openide.util.lookup.Lookups; |
35 |
import org.openide.util.lookup.Lookups; |
42 |
import org.openidex.search.SimpleSearchInfo; |
36 |
import org.openidex.search.SearchInfo; |
|
|
37 |
import org.openidex.search.SearchInfoFactory; |
43 |
|
38 |
|
44 |
|
39 |
|
45 |
/** |
40 |
/** |
Lines 98-131
Link Here
|
98 |
|
93 |
|
99 |
/** Where to search */ |
94 |
/** Where to search */ |
100 |
private Node[] getNodesToSearch() { |
95 |
private Node[] getNodesToSearch() { |
101 |
Collection dataObjectsToSearch = getDataObjectsToSearch(); |
|
|
102 |
|
103 |
if (dataObjectsToSearch.isEmpty()) { |
104 |
return new Node[0]; |
105 |
} |
106 |
|
107 |
SimpleSearchInfo searchInfo = new SimpleSearchInfo(); |
108 |
for (Iterator i = dataObjectsToSearch.iterator(); i.hasNext(); ) { |
109 |
DataObject root = (DataObject) i.next(); |
110 |
if (root instanceof DataObject.Container) { |
111 |
searchInfo.add( |
112 |
new SimpleSearchInfo((DataObject.Container) root)); |
113 |
} else { |
114 |
searchInfo.add(root); |
115 |
} |
116 |
} |
117 |
|
118 |
Node nodeToSearch = new AbstractNode( |
119 |
Children.LEAF, |
120 |
Lookups.singleton(searchInfo)); |
121 |
nodeToSearch.setValue( |
122 |
SearchPanel.PROP_DIALOG_TITLE, |
123 |
NbBundle.getMessage(ProjectsSearchAction.class, |
124 |
"LBL_Title_SearchProjects")); //NOI18N |
125 |
return new Node[] {nodeToSearch}; |
126 |
} |
127 |
|
128 |
private Collection getDataObjectsToSearch() { |
129 |
Project[] openProjects = OpenProjects.getDefault().getOpenProjects(); |
96 |
Project[] openProjects = OpenProjects.getDefault().getOpenProjects(); |
130 |
|
97 |
|
131 |
if (openProjects.length == 0) { |
98 |
if (openProjects.length == 0) { |
Lines 138-165
Link Here
|
138 |
* is being removed in another thread than this action was |
105 |
* is being removed in another thread than this action was |
139 |
* invoked from. |
106 |
* invoked from. |
140 |
*/ |
107 |
*/ |
141 |
return Collections.EMPTY_LIST; |
108 |
return new Node[0]; |
142 |
} |
109 |
} |
143 |
|
110 |
|
144 |
List rootDataObjects = new ArrayList(openProjects.length * 2); |
111 |
List rootFolders = new ArrayList(); |
145 |
|
|
|
146 |
for (int i = 0; i < openProjects.length; i++) { |
112 |
for (int i = 0; i < openProjects.length; i++) { |
147 |
Sources sources = ProjectUtils.getSources(openProjects[i]); |
113 |
Sources sources = ProjectUtils.getSources(openProjects[i]); |
148 |
SourceGroup[] sourceGroups |
114 |
SourceGroup[] sourceGroups |
149 |
= sources.getSourceGroups(Sources.TYPE_GENERIC); |
115 |
= sources.getSourceGroups(Sources.TYPE_GENERIC); |
150 |
for (int j = 0; j < sourceGroups.length; j++) { |
116 |
for (int j = 0; j < sourceGroups.length; j++) { |
151 |
try { |
117 |
rootFolders.add(sourceGroups[j].getRootFolder()); |
152 |
rootDataObjects.add( |
|
|
153 |
DataObject.find(sourceGroups[j].getRootFolder())); |
154 |
} catch (DataObjectNotFoundException ex) { |
155 |
ErrorManager.getDefault().notify( |
156 |
ErrorManager.EXCEPTION, ex); |
157 |
} |
158 |
} |
118 |
} |
159 |
} |
119 |
} |
|
|
120 |
|
121 |
if (rootFolders.isEmpty()) { |
122 |
return new Node[0]; |
123 |
} |
124 |
|
125 |
SearchInfo searchInfo = SearchInfoFactory.createSearchInfo( |
126 |
(FileObject[]) |
127 |
rootFolders.toArray(new FileObject[rootFolders.size()]), |
128 |
true, //recursive |
129 |
true, //check sharability |
130 |
true); //check visibility |
160 |
|
131 |
|
161 |
return !rootDataObjects.isEmpty() ? rootDataObjects |
132 |
Node nodeToSearch = new AbstractNode( |
162 |
: Collections.EMPTY_LIST; |
133 |
Children.LEAF, |
|
|
134 |
Lookups.singleton(searchInfo)); |
135 |
nodeToSearch.setValue( |
136 |
SearchPanel.PROP_DIALOG_TITLE, |
137 |
NbBundle.getMessage(ProjectsSearchAction.class, |
138 |
"LBL_Title_SearchProjects")); //NOI18N |
139 |
return new Node[] {nodeToSearch}; |
163 |
} |
140 |
} |
164 |
|
141 |
|
165 |
/** Perform this action. */ |
142 |
/** Perform this action. */ |