1 /*******************************************************************************
2 * Copyright (c) 2000, 2011 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.ui.actions;
13 import org.eclipse.ui.IWorkbenchSite;
14 import org.eclipse.ui.PlatformUI;
16 import org.eclipse.jdt.core.IJavaElement;
17 import org.eclipse.jdt.core.JavaModelException;
18 import org.eclipse.jdt.core.search.IJavaSearchScope;
20 import org.eclipse.jdt.ui.search.ElementQuerySpecification;
21 import org.eclipse.jdt.ui.search.QuerySpecification;
23 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
24 import org.eclipse.jdt.internal.ui.JavaPluginImages;
25 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
26 import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
27 import org.eclipse.jdt.internal.ui.search.SearchMessages;
30 * Finds declarations of the selected element in the enclosing project
31 * of the selected element.
32 * The action is applicable to selections representing a Java element.
35 * This class may be instantiated; it is not intended to be subclassed.
40 * @noextend This class is not intended to be subclassed by clients.
42 public class FindDeclarationsInProjectAction extends FindDeclarationsAction {
45 * Creates a new <code>FindDeclarationsInProjectAction</code>. The action
46 * requires that the selection provided by the site's selection provider is of type
47 * <code>IStructuredSelection</code>.
49 * @param site the site providing context information for this action
51 public FindDeclarationsInProjectAction(IWorkbenchSite site) {
56 * Note: This constructor is for internal use only. Clients should not call this constructor.
57 * @param editor the Java editor
59 * @noreference This constructor is not intended to be referenced by clients.
61 public FindDeclarationsInProjectAction(JavaEditor editor) {
67 setText(SearchMessages.Search_FindDeclarationsInProjectAction_label);
68 setToolTipText(SearchMessages.Search_FindDeclarationsInProjectAction_tooltip);
69 setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_DECL);
70 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_DECLARATIONS_IN_PROJECT_ACTION);
74 QuerySpecification createQuery(IJavaElement element) throws JavaModelException {
75 JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
76 JavaEditor editor= getEditor();
78 IJavaSearchScope scope;
80 boolean isInsideJRE= true;
82 scope= factory.createJavaProjectSearchScope(editor.getEditorInput(), isInsideJRE);
83 description= factory.getProjectScopeDescription(editor.getEditorInput(), isInsideJRE);
85 scope= factory.createJavaProjectSearchScope(element.getJavaProject(), isInsideJRE);
86 description= factory.getProjectScopeDescription(element.getJavaProject(), isInsideJRE);
88 return new ElementQuerySpecification(element, getLimitTo(), scope, description);