]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-before/ui/org/eclipse/jdt/ui/actions/FindDeclarationsInProjectAction.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / ui / org / eclipse / jdt / ui / actions / FindDeclarationsInProjectAction.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 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.
33  *
34  * <p>
35  * This class may be instantiated; it is not intended to be subclassed.
36  * </p>
37  *
38  * @since 3.0
39  *
40  * @noextend This class is not intended to be subclassed by clients.
41  */
42 public class FindDeclarationsInProjectAction extends FindDeclarationsAction {
43
44         /**
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>.
48          *
49          * @param site the site providing context information for this action
50          */
51         public FindDeclarationsInProjectAction(IWorkbenchSite site) {
52                 super(site);
53         }
54
55         /**
56          * Note: This constructor is for internal use only. Clients should not call this constructor.
57          * @param editor the Java editor
58          *
59          * @noreference This constructor is not intended to be referenced by clients.
60          */
61         public FindDeclarationsInProjectAction(JavaEditor editor) {
62                 super(editor);
63         }
64
65         @Override
66         void init() {
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);
71         }
72
73         @Override
74         QuerySpecification createQuery(IJavaElement element) throws JavaModelException {
75                 JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
76                 JavaEditor editor= getEditor();
77
78                 IJavaSearchScope scope;
79                 String description;
80                 boolean isInsideJRE= true;
81                 if (editor != null) {
82                         scope= factory.createJavaProjectSearchScope(editor.getEditorInput(), isInsideJRE);
83                         description= factory.getProjectScopeDescription(editor.getEditorInput(), isInsideJRE);
84                 } else {
85                         scope= factory.createJavaProjectSearchScope(element.getJavaProject(), isInsideJRE);
86                         description=  factory.getProjectScopeDescription(element.getJavaProject(), isInsideJRE);
87                 }
88                 return new ElementQuerySpecification(element, getLimitTo(), scope, description);
89         }
90 }