01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 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.pde.internal.ui.search;
11:
12: import org.eclipse.pde.core.plugin.IFragment;
13: import org.eclipse.pde.core.plugin.IPlugin;
14: import org.eclipse.pde.core.plugin.IPluginExtension;
15: import org.eclipse.pde.core.plugin.IPluginImport;
16: import org.eclipse.pde.internal.core.search.ExtensionPluginSearchScope;
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: public class FindDeclarationsAction extends BaseSearchAction {
24:
25: private Object fSelectedObject;
26:
27: public FindDeclarationsAction(Object object) {
28: super (PDEUIMessages.SearchAction_Declaration);
29: setImageDescriptor(PDEPluginImages.DESC_PSEARCH_OBJ);
30: this .fSelectedObject = object;
31: }
32:
33: protected ISearchQuery createSearchQuery() {
34: PluginSearchInput input = new PluginSearchInput();
35: PluginSearchScope scope = null;
36:
37: if (fSelectedObject instanceof IPluginImport) {
38: input.setSearchString(((IPluginImport) fSelectedObject)
39: .getId());
40: input.setSearchElement(PluginSearchInput.ELEMENT_PLUGIN);
41: } else if (fSelectedObject instanceof IPluginExtension) {
42: input.setSearchString(((IPluginExtension) fSelectedObject)
43: .getPoint());
44: input
45: .setSearchElement(PluginSearchInput.ELEMENT_EXTENSION_POINT);
46: scope = new ExtensionPluginSearchScope(input);
47: } else if (fSelectedObject instanceof IPlugin) {
48: input.setSearchString(((IPlugin) fSelectedObject).getId());
49: input.setSearchElement(PluginSearchInput.ELEMENT_PLUGIN);
50: } else if (fSelectedObject instanceof IFragment) {
51: input
52: .setSearchString(((IFragment) fSelectedObject)
53: .getId());
54: input.setSearchElement(PluginSearchInput.ELEMENT_FRAGMENT);
55: }
56: input.setSearchLimit(PluginSearchInput.LIMIT_DECLARATIONS);
57: input.setSearchScope((scope == null) ? new PluginSearchScope()
58: : scope);
59: return new PluginSearchQuery(input);
60: }
61:
62: }
|