KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > ui > actions > FindDeclarationsAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.ICompilationUnit;
17 import org.eclipse.jdt.core.IField;
18 import org.eclipse.jdt.core.IImportDeclaration;
19 import org.eclipse.jdt.core.ILocalVariable;
20 import org.eclipse.jdt.core.IMethod;
21 import org.eclipse.jdt.core.IPackageDeclaration;
22 import org.eclipse.jdt.core.IPackageFragment;
23 import org.eclipse.jdt.core.IType;
24 import org.eclipse.jdt.core.ITypeParameter;
25 import org.eclipse.jdt.core.search.IJavaSearchConstants;
26
27 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
28 import org.eclipse.jdt.internal.ui.JavaPluginImages;
29 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
30 import org.eclipse.jdt.internal.ui.search.SearchMessages;
31
32 /**
33  * Finds declarations of the selected element in the workspace.
34  * The action is applicable to selections representing a Java element.
35  *
36  * <p>
37  * This class may be instantiated; it is not intended to be subclassed.
38  * </p>
39  *
40  * @since 2.0
41  */

42 public class FindDeclarationsAction extends FindAction {
43     
44     /**
45      * Creates a new <code>FindDeclarationsAction</code>. The action requires
46      * that the selection provided by the site's selection provider is of type <code>
47      * org.eclipse.jface.viewers.IStructuredSelection</code>.
48      *
49      * @param site the site providing context information for this action
50      */

51     public FindDeclarationsAction(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     public FindDeclarationsAction(JavaEditor editor) {
60         super(editor);
61     }
62     
63     void init() {
64         setText(SearchMessages.Search_FindDeclarationAction_label);
65         setToolTipText(SearchMessages.Search_FindDeclarationAction_tooltip);
66         setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_DECL);
67         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_DECLARATIONS_IN_WORKSPACE_ACTION);
68     }
69     
70     Class JavaDoc[] getValidTypes() {
71         return new Class JavaDoc[] { IField.class, IMethod.class, IType.class, ICompilationUnit.class, IPackageDeclaration.class, IImportDeclaration.class, IPackageFragment.class, ILocalVariable.class, ITypeParameter.class };
72     }
73     
74     int getLimitTo() {
75         return IJavaSearchConstants.DECLARATIONS | IJavaSearchConstants.IGNORE_DECLARING_TYPE | IJavaSearchConstants.IGNORE_RETURN_TYPE;
76     }
77     
78 }
79
Popular Tags