]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-before/ui/org/eclipse/jdt/ui/actions/FindImplementorsInProjectAction.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / ui / org / eclipse / jdt / ui / actions / FindImplementorsInProjectAction.java
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
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.ui.actions;
12
13 import org.eclipse.ui.IWorkbenchSite;
14 import org.eclipse.ui.PlatformUI;
15
16 import org.eclipse.jdt.core.IJavaElement;
17 import org.eclipse.jdt.core.JavaModelException;
18 import org.eclipse.jdt.core.search.IJavaSearchScope;
19
20 import org.eclipse.jdt.ui.search.ElementQuerySpecification;
21 import org.eclipse.jdt.ui.search.QuerySpecification;
22
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;
28
29 /**
30  * Finds implementors of the selected element in the enclosing project.
31  * The action is applicable to selections representing a Java interface.
32  *
33  * <p>
34  * This class may be instantiated; it is not intended to be subclassed.
35  * </p>
36  *
37  * @since 3.0
38  *
39  * @noextend This class is not intended to be subclassed by clients.
40  */
41 public class FindImplementorsInProjectAction extends FindImplementorsAction {
42
43         /**
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>.
47          *
48          * @param site the site providing context information for this action
49          */
50         public FindImplementorsInProjectAction(IWorkbenchSite site) {
51                 super(site);
52         }
53
54         /**
55          * Note: This constructor is for internal use only. Clients should not call this constructor.
56          * @param editor the Java editor
57          *
58          * @noreference This constructor is not intended to be referenced by clients.
59          */
60         public FindImplementorsInProjectAction(JavaEditor editor) {
61                 super(editor);
62         }
63
64         @Override
65         void init() {
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);
70         }
71
72         @Override
73         QuerySpecification createQuery(IJavaElement element) throws JavaModelException {
74                 JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
75                 JavaEditor editor= getEditor();
76
77                 IJavaSearchScope scope;
78                 String description;
79                 boolean isInsideJRE= factory.isInsideJRE(element);
80                 if (editor != null) {
81                         scope= factory.createJavaProjectSearchScope(editor.getEditorInput(), isInsideJRE);
82                         description= factory.getProjectScopeDescription(editor.getEditorInput(), isInsideJRE);
83                 } else {
84                         scope= factory.createJavaProjectSearchScope(element.getJavaProject(), isInsideJRE);
85                         description=  factory.getProjectScopeDescription(element.getJavaProject(), isInsideJRE);
86                 }
87                 return new ElementQuerySpecification(element, getLimitTo(), scope, description);
88         }
89 }