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 implementors of the selected element in the enclosing project.
31 * The action is applicable to selections representing a Java interface.
34 * This class may be instantiated; it is not intended to be subclassed.
39 * @noextend This class is not intended to be subclassed by clients.
41 public class FindImplementorsInProjectAction extends FindImplementorsAction {
44 * Creates a new <code>FindImplementorsInProjectAction</code>. The action
45 * requires that the selection provided by the site's selection provider is of type
46 * <code>IStructuredSelection</code>.
48 * @param site the site providing context information for this action
50 public FindImplementorsInProjectAction(IWorkbenchSite site) {
55 * Note: This constructor is for internal use only. Clients should not call this constructor.
56 * @param editor the Java editor
58 * @noreference This constructor is not intended to be referenced by clients.
60 public FindImplementorsInProjectAction(JavaEditor editor) {
66 setText(SearchMessages.Search_FindImplementorsInProjectAction_label);
67 setToolTipText(SearchMessages.Search_FindImplementorsInProjectAction_tooltip);
68 setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_DECL);
69 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_IMPLEMENTORS_IN_PROJECT_ACTION);
73 QuerySpecification createQuery(IJavaElement element) throws JavaModelException {
74 JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
75 JavaEditor editor= getEditor();
77 IJavaSearchScope scope;
79 boolean isInsideJRE= factory.isInsideJRE(element);
81 scope= factory.createJavaProjectSearchScope(editor.getEditorInput(), isInsideJRE);
82 description= factory.getProjectScopeDescription(editor.getEditorInput(), isInsideJRE);
84 scope= factory.createJavaProjectSearchScope(element.getJavaProject(), isInsideJRE);
85 description= factory.getProjectScopeDescription(element.getJavaProject(), isInsideJRE);
87 return new ElementQuerySpecification(element, getLimitTo(), scope, description);