]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-before/ui/org/eclipse/jdt/ui/actions/FindReadReferencesInWorkingSetAction.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / ui / org / eclipse / jdt / ui / actions / FindReadReferencesInWorkingSetAction.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.IWorkingSet;
15 import org.eclipse.ui.PlatformUI;
16
17 import org.eclipse.jdt.core.IField;
18 import org.eclipse.jdt.core.ILocalVariable;
19 import org.eclipse.jdt.core.search.IJavaSearchConstants;
20
21 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
22 import org.eclipse.jdt.internal.ui.JavaPluginImages;
23 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
24 import org.eclipse.jdt.internal.ui.search.SearchMessages;
25
26 /**
27  * Finds field read accesses of the selected element in working sets.
28  * The action is applicable to selections representing a Java field.
29  *
30  * <p>
31  * This class may be instantiated; it is not intended to be subclassed.
32  * </p>
33  *
34  * @since 2.0
35  *
36  * @noextend This class is not intended to be subclassed by clients.
37  */
38 public class FindReadReferencesInWorkingSetAction extends FindReferencesInWorkingSetAction {
39
40         /**
41          * Creates a new <code>FindReadReferencesInWorkingSetAction</code>. The action
42          * requires that the selection provided by the site's selection provider is of type
43          * <code>org.eclipse.jface.viewers.IStructuredSelection</code>. The user will be
44          * prompted to select the working sets.
45          *
46          * @param site the site providing context information for this action
47          */
48         public FindReadReferencesInWorkingSetAction(IWorkbenchSite site) {
49                 super(site);
50         }
51
52         /**
53          * Creates a new <code>FindReadReferencesInWorkingSetAction</code>. The action
54          * requires that the selection provided by the site's selection provider is of type
55          * <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
56          *
57          * @param site                  the site providing context information for this action
58          * @param workingSets   the working sets to be used in the search
59          */
60         public FindReadReferencesInWorkingSetAction(IWorkbenchSite site, IWorkingSet[] workingSets) {
61                 super(site, workingSets);
62         }
63
64         /**
65          * Note: This constructor is for internal use only. Clients should not call this constructor.
66          * @param editor the Java editor
67          *
68          * @noreference This constructor is not intended to be referenced by clients.
69          */
70         public FindReadReferencesInWorkingSetAction(JavaEditor editor) {
71                 super(editor);
72         }
73
74         /**
75          * Note: This constructor is for internal use only. Clients should not call this constructor.
76          * @param editor the Java editor
77          * @param workingSets the working sets to be used in the search
78          *
79          * @noreference This constructor is not intended to be referenced by clients.
80          */
81         public FindReadReferencesInWorkingSetAction(JavaEditor editor, IWorkingSet[] workingSets) {
82                 super(editor, workingSets);
83         }
84
85         @Override
86         Class<?>[] getValidTypes() {
87                 return new Class[] { IField.class, ILocalVariable.class };
88         }
89
90         @Override
91         void init() {
92                 setText(SearchMessages.Search_FindReadReferencesInWorkingSetAction_label);
93                 setToolTipText(SearchMessages.Search_FindReadReferencesInWorkingSetAction_tooltip);
94                 setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_REF);
95                 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_READ_REFERENCES_IN_WORKING_SET_ACTION);
96         }
97
98         @Override
99         int getLimitTo() {
100                 return IJavaSearchConstants.READ_ACCESSES;
101         }
102
103         @Override
104         String getOperationUnavailableMessage() {
105                 return SearchMessages.JavaElementAction_operationUnavailable_field;
106         }
107 }