01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.ui.actions;
11:
12: import org.eclipse.ui.IWorkbenchSite;
13: import org.eclipse.ui.PlatformUI;
14:
15: import org.eclipse.jdt.core.IField;
16: import org.eclipse.jdt.core.ILocalVariable;
17: import org.eclipse.jdt.core.search.IJavaSearchConstants;
18:
19: import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
20: import org.eclipse.jdt.internal.ui.JavaPluginImages;
21: import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
22: import org.eclipse.jdt.internal.ui.search.SearchMessages;
23:
24: /**
25: * Finds field read accesses of the selected element in the workspace.
26: * The action is applicable to selections representing a Java interface field.
27: * <p>
28: * This class may be instantiated; it is not intended to be subclassed.
29: * </p>
30: *
31: * @since 2.0
32: */
33: public class FindReadReferencesAction extends FindReferencesAction {
34:
35: /**
36: * Creates a new <code>FindReadReferencesAction</code>. The action
37: * requires that the selection provided by the site's selection provider is of type
38: * <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
39: *
40: * @param site the site providing context information for this action
41: */
42: public FindReadReferencesAction(IWorkbenchSite site) {
43: super (site);
44: }
45:
46: /**
47: * Note: This constructor is for internal use only. Clients should not call this constructor.
48: * @param editor the Java editor
49: */
50: public FindReadReferencesAction(JavaEditor editor) {
51: super (editor);
52: }
53:
54: Class[] getValidTypes() {
55: return new Class[] { IField.class, ILocalVariable.class };
56: }
57:
58: void init() {
59: setText(SearchMessages.Search_FindReadReferencesAction_label);
60: setToolTipText(SearchMessages.Search_FindReadReferencesAction_tooltip);
61: setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_REF);
62: PlatformUI
63: .getWorkbench()
64: .getHelpSystem()
65: .setHelp(
66: this ,
67: IJavaHelpContextIds.FIND_READ_REFERENCES_IN_WORKSPACE_ACTION);
68: }
69:
70: int getLimitTo() {
71: return IJavaSearchConstants.READ_ACCESSES;
72: }
73:
74: String getOperationUnavailableMessage() {
75: return SearchMessages.JavaElementAction_operationUnavailable_field;
76: }
77: }
|