]> git.uio.no Git - ifi-stolz-refaktor.git/blame - case-study/jdt-after/ui/org/eclipse/jdt/ui/actions/FindWriteReferencesInProjectAction.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / ui / actions / FindWriteReferencesInProjectAction.java
CommitLineData
1b2798f6
EK
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 *******************************************************************************/
11package org.eclipse.jdt.ui.actions;
12
13import org.eclipse.ui.IWorkbenchSite;
14import org.eclipse.ui.PlatformUI;
15
16import org.eclipse.jdt.core.IJavaElement;
17import org.eclipse.jdt.core.JavaModelException;
18import org.eclipse.jdt.core.search.IJavaSearchScope;
19
20import org.eclipse.jdt.ui.search.ElementQuerySpecification;
21import org.eclipse.jdt.ui.search.QuerySpecification;
22
23import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
24import org.eclipse.jdt.internal.ui.JavaPluginImages;
25import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
26import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
27import org.eclipse.jdt.internal.ui.search.SearchMessages;
28
29/**
30 * Finds field write accesses of the selected element in the enclosing project.
31 * The action is applicable to selections representing a Java field.
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 */
41public class FindWriteReferencesInProjectAction extends FindWriteReferencesAction {
42
43 /**
44 * Creates a new <code>FindWriteReferencesInProjectAction</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 FindWriteReferencesInProjectAction(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 FindWriteReferencesInProjectAction(JavaEditor editor) {
61 super(editor);
62 }
63
64 @Override
65 void init() {
66 setText(SearchMessages.Search_FindWriteReferencesInProjectAction_label);
67 setToolTipText(SearchMessages.Search_FindWriteReferencesInProjectAction_tooltip);
68 setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_REF);
69 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_WRITE_REFERENCES_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
90}