KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > search > ReferenceScopeFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.search;
12
13 import org.eclipse.core.resources.ResourcesPlugin;
14 import org.eclipse.jdt.core.IJavaModel;
15 import org.eclipse.jdt.core.IJavaProject;
16 import org.eclipse.jdt.core.JavaCore;
17 import org.eclipse.jdt.core.JavaModelException;
18 import org.eclipse.jdt.core.search.IJavaSearchScope;
19 import org.eclipse.jdt.core.search.SearchEngine;
20
21
22 public class ReferenceScopeFactory {
23
24     private ReferenceScopeFactory() {
25         // no instances, please
26
}
27
28     public static IJavaSearchScope createWorkspaceScope(boolean includeJRE) {
29         try {
30             return SearchEngine.createJavaSearchScope(getAllProjects(), JavaSearchScopeFactory.getSearchFlags(includeJRE));
31         } catch (JavaModelException e) {
32             return SearchEngine.createWorkspaceScope();
33         }
34     }
35
36     private static IJavaProject[] getAllProjects() throws JavaModelException {
37         IJavaModel model= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
38         return model.getJavaProjects();
39     }
40 }
41
Popular Tags