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.IPlugin;
13: import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
14: import org.eclipse.pde.core.plugin.IPluginImport;
15: import org.eclipse.pde.core.plugin.IPluginModelBase;
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 FindReferencesAction extends BaseSearchAction {
24:
25: private Object fSelectedObject;
26: private String fPluginID;
27:
28: public FindReferencesAction(Object object) {
29: this (object, null);
30: }
31:
32: public FindReferencesAction(Object object, String pluginID) {
33: super (PDEUIMessages.SearchAction_references);
34: fSelectedObject = object;
35: fPluginID = pluginID;
36: initialize();
37: }
38:
39: private void initialize() {
40: setImageDescriptor(PDEPluginImages.DESC_PSEARCH_OBJ);
41: }
42:
43: protected ISearchQuery createSearchQuery() {
44: PluginSearchInput input = new PluginSearchInput();
45: PluginSearchScope scope = null;
46: if (fSelectedObject instanceof IPlugin) {
47: input.setSearchElement(PluginSearchInput.ELEMENT_PLUGIN);
48: input.setSearchString(((IPlugin) fSelectedObject).getId());
49: } else if (fSelectedObject instanceof IPluginExtensionPoint) {
50: input
51: .setSearchElement(PluginSearchInput.ELEMENT_EXTENSION_POINT);
52: IPluginModelBase model = ((IPluginExtensionPoint) fSelectedObject)
53: .getPluginModel();
54: String id = model.getPluginBase().getId();
55: if (id == null || id.trim().length() == 0)
56: id = fPluginID;
57: if (id == null || id.trim().length() == 0)
58: id = "*"; //$NON-NLS-1$
59: input
60: .setSearchString(id
61: + "." //$NON-NLS-1$
62: + ((IPluginExtensionPoint) fSelectedObject)
63: .getId());
64: scope = new ExtensionPluginSearchScope(input);
65: } else if (fSelectedObject instanceof IPluginImport) {
66: input.setSearchElement(PluginSearchInput.ELEMENT_PLUGIN);
67: input.setSearchString(((IPluginImport) fSelectedObject)
68: .getId());
69: }
70: input.setSearchLimit(PluginSearchInput.LIMIT_REFERENCES);
71: input.setSearchScope((scope == null) ? new PluginSearchScope()
72: : scope);
73: return new PluginSearchQuery(input);
74: }
75:
76: }
|