]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/ui/org/eclipse/jdt/ui/actions/FindReadReferencesInProjectAction.java
Some talks, mostly identical.
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / ui / actions / FindReadReferencesInProjectAction.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.jface.viewers.ISelection;
14 import org.eclipse.jface.viewers.ISelectionProvider;
15
16 import org.eclipse.ui.IWorkbenchSite;
17 import org.eclipse.ui.PlatformUI;
18
19 import org.eclipse.jdt.core.IJavaElement;
20 import org.eclipse.jdt.core.JavaModelException;
21 import org.eclipse.jdt.core.search.IJavaSearchScope;
22
23 import org.eclipse.jdt.ui.search.ElementQuerySpecification;
24 import org.eclipse.jdt.ui.search.QuerySpecification;
25
26 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
27 import org.eclipse.jdt.internal.ui.JavaPluginImages;
28 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
29 import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
30 import org.eclipse.jdt.internal.ui.search.SearchMessages;
31
32 /**
33  * Finds field read accesses of the selected element in the enclosing project.
34  * The action is applicable to selections representing a Java field.
35  *
36  * <p>
37  * This class may be instantiated; it is not intended to be subclassed.
38  * </p>
39  *
40  * @since 3.0
41  *
42  * @noextend This class is not intended to be subclassed by clients.
43  */
44 public class FindReadReferencesInProjectAction extends FindReadReferencesAction {
45
46         /**
47          * Creates a new <code>FindReadReferencesInProjectAction</code>. The action
48          * requires that the selection provided by the site's selection provider is of type
49          * <code>IStructuredSelection</code>.
50          *
51          * @param site the site providing context information for this action
52          */
53         public FindReadReferencesInProjectAction(IWorkbenchSite site) {
54                 super(site);
55         }
56
57         /**
58          * Note: This constructor is for internal use only. Clients should not call this constructor.
59          * @param editor the Java editor
60          *
61          * @noreference This constructor is not intended to be referenced by clients.
62          */
63         public FindReadReferencesInProjectAction(JavaEditor editor) {
64                 super(editor);
65         }
66
67         @Override
68         void init() {
69                 setText(SearchMessages.Search_FindReadReferencesInProjectAction_label);
70                 setToolTipText(SearchMessages.Search_FindReadReferencesInProjectAction_tooltip);
71                 setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_REF);
72                 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_READ_REFERENCES_IN_PROJECT_ACTION);
73         }
74
75         @Override
76         QuerySpecification createQuery(IJavaElement element) throws JavaModelException {
77                 JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
78                 JavaEditor editor= getEditor();
79
80                 IJavaSearchScope scope;
81                 String description;
82                 boolean isInsideJRE= factory.isInsideJRE(element);
83                 if (editor != null) {
84                         scope= factory.createJavaProjectSearchScope(editor.getEditorInput(), isInsideJRE);
85                         description= factory.getProjectScopeDescription(editor.getEditorInput(), isInsideJRE);
86                 } else {
87                         scope= factory.createJavaProjectSearchScope(element.getJavaProject(), isInsideJRE);
88                         description=  factory.getProjectScopeDescription(element.getJavaProject(), isInsideJRE);
89                 }
90                 return new ElementQuerySpecification(element, getLimitTo(), scope, description);
91         }
92
93         public void generated_8196863578754530366(ReadReferencesSearchGroup readreferencessearchgroup, IWorkbenchSite site, ISelectionProvider specialSelectionProvider) {
94                 setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_READ_ACCESS_IN_PROJECT);
95         
96                 readreferencessearchgroup.fFindReadReferencesInHierarchyAction= new FindReadReferencesInHierarchyAction(site);
97                 readreferencessearchgroup.fFindReadReferencesInHierarchyAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_HIERARCHY);
98         
99                 readreferencessearchgroup.fFindReadReferencesInWorkingSetAction= new FindReadReferencesInWorkingSetAction(site);
100                 readreferencessearchgroup.fFindReadReferencesInWorkingSetAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_WORKING_SET);
101         
102                 // register the actions as selection listeners
103                 ISelectionProvider provider= specialSelectionProvider == null ? readreferencessearchgroup.fSite.getSelectionProvider() : specialSelectionProvider;
104                 ISelection selection= provider.getSelection();
105                 readreferencessearchgroup.registerAction(readreferencessearchgroup.fFindReadReferencesAction, provider, selection, specialSelectionProvider);
106                 readreferencessearchgroup.registerAction(this, provider, selection, specialSelectionProvider);
107                 readreferencessearchgroup.registerAction(readreferencessearchgroup.fFindReadReferencesInHierarchyAction, provider, selection, specialSelectionProvider);
108                 readreferencessearchgroup.registerAction(readreferencessearchgroup.fFindReadReferencesInWorkingSetAction, provider, selection, specialSelectionProvider);
109         }
110
111 }