01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.ui.actions;
11:
12: import org.eclipse.ui.IWorkbenchSite;
13: import org.eclipse.ui.PlatformUI;
14:
15: import org.eclipse.jdt.core.IJavaElement;
16: import org.eclipse.jdt.core.JavaModelException;
17: import org.eclipse.jdt.core.search.IJavaSearchScope;
18:
19: import org.eclipse.jdt.ui.search.ElementQuerySpecification;
20: import org.eclipse.jdt.ui.search.QuerySpecification;
21:
22: import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
23: import org.eclipse.jdt.internal.ui.JavaPluginImages;
24: import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
25: import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
26: import org.eclipse.jdt.internal.ui.search.SearchMessages;
27:
28: /**
29: * Finds implementors of the selected element in the enclosing project.
30: * The action is applicable to selections representing a Java interface.
31: *
32: * <p>
33: * This class may be instantiated; it is not intended to be subclassed.
34: * </p>
35: *
36: * @since 3.0
37: */
38: public class FindImplementorsInProjectAction extends
39: FindImplementorsAction {
40:
41: /**
42: * Creates a new <code>FindImplementorsInProjectAction</code>. The action
43: * requires that the selection provided by the site's selection provider is of type
44: * <code>IStructuredSelection</code>.
45: *
46: * @param site the site providing context information for this action
47: */
48: public FindImplementorsInProjectAction(IWorkbenchSite site) {
49: super (site);
50: }
51:
52: /**
53: * Note: This constructor is for internal use only. Clients should not call this constructor.
54: * @param editor the Java editor
55: */
56: public FindImplementorsInProjectAction(JavaEditor editor) {
57: super (editor);
58: }
59:
60: void init() {
61: setText(SearchMessages.Search_FindImplementorsInProjectAction_label);
62: setToolTipText(SearchMessages.Search_FindImplementorsInProjectAction_tooltip);
63: setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_DECL);
64: PlatformUI
65: .getWorkbench()
66: .getHelpSystem()
67: .setHelp(
68: this ,
69: IJavaHelpContextIds.FIND_IMPLEMENTORS_IN_PROJECT_ACTION);
70: }
71:
72: QuerySpecification createQuery(IJavaElement element)
73: throws JavaModelException {
74: JavaSearchScopeFactory factory = JavaSearchScopeFactory
75: .getInstance();
76: JavaEditor editor = getEditor();
77:
78: IJavaSearchScope scope;
79: String description;
80: boolean isInsideJRE = factory.isInsideJRE(element);
81: if (editor != null) {
82: scope = factory.createJavaProjectSearchScope(editor
83: .getEditorInput(), isInsideJRE);
84: description = factory.getProjectScopeDescription(editor
85: .getEditorInput(), isInsideJRE);
86: } else {
87: scope = factory.createJavaProjectSearchScope(element
88: .getJavaProject(), isInsideJRE);
89: description = factory.getProjectScopeDescription(element
90: .getJavaProject(), isInsideJRE);
91: }
92: return new ElementQuerySpecification(element, getLimitTo(),
93: scope, description);
94: }
95: }
|