KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > search > 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.pde.internal.ui.search;
12
13 import org.eclipse.pde.core.plugin.IFragment;
14 import org.eclipse.pde.core.plugin.IPlugin;
15 import org.eclipse.pde.core.plugin.IPluginExtension;
16 import org.eclipse.pde.core.plugin.IPluginImport;
17 import org.eclipse.pde.internal.core.search.PluginSearchInput;
18 import org.eclipse.pde.internal.core.search.PluginSearchScope;
19 import org.eclipse.pde.internal.ui.PDEPluginImages;
20 import org.eclipse.pde.internal.ui.PDEUIMessages;
21 import org.eclipse.search.ui.ISearchQuery;
22
23
24 public class FindDeclarationsAction extends BaseSearchAction {
25     
26     private Object JavaDoc fSelectedObject;
27
28     public FindDeclarationsAction(Object JavaDoc object) {
29         super(PDEUIMessages.SearchAction_Declaration);
30         setImageDescriptor(PDEPluginImages.DESC_PSEARCH_OBJ);
31         this.fSelectedObject = object;
32     }
33     
34     protected ISearchQuery createSearchQuery() {
35         PluginSearchInput input = new PluginSearchInput();
36
37         if (fSelectedObject instanceof IPluginImport) {
38             input.setSearchString(((IPluginImport) fSelectedObject).getId());
39             input.setSearchElement(PluginSearchInput.ELEMENT_PLUGIN);
40         } else if (fSelectedObject instanceof IPluginExtension) {
41             input.setSearchString(((IPluginExtension)fSelectedObject).getPoint());
42             input.setSearchElement(PluginSearchInput.ELEMENT_EXTENSION_POINT);
43         } else if (fSelectedObject instanceof IPlugin) {
44             input.setSearchString(((IPlugin)fSelectedObject).getId());
45             input.setSearchElement(PluginSearchInput.ELEMENT_PLUGIN);
46         } else if (fSelectedObject instanceof IFragment) {
47             input.setSearchString(((IFragment)fSelectedObject).getId());
48             input.setSearchElement(PluginSearchInput.ELEMENT_FRAGMENT);
49         }
50         input.setSearchLimit(PluginSearchInput.LIMIT_DECLARATIONS);
51         input.setSearchScope(new PluginSearchScope());
52         return new PluginSearchQuery(input);
53     }
54
55 }
56
Popular Tags