|
What this is
Other links
The source code/******************************************************************************* * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.pde.internal.ui.search; import org.eclipse.core.resources.IFile; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.core.plugin.PluginRegistry; import org.eclipse.pde.internal.core.search.PluginSearchInput; import org.eclipse.pde.internal.core.search.PluginSearchScope; import org.eclipse.search.ui.ISearchQuery; import org.eclipse.search.ui.NewSearchUI; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; public class FindPluginReferencesAction implements IObjectActionDelegate { private String fSearchString = null; /* * (non-Javadoc) * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) */ public void setActivePart(IAction action, IWorkbenchPart targetPart) { } /* * (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { if (fSearchString != null) { NewSearchUI.activateSearchResultView(); NewSearchUI.runQueryInBackground(createSearchQuery()); } } private ISearchQuery createSearchQuery() { PluginSearchInput input = new PluginSearchInput(); input.setSearchElement(PluginSearchInput.ELEMENT_PLUGIN); input.setSearchLimit(PluginSearchInput.LIMIT_REFERENCES); input.setSearchString(fSearchString); input.setSearchScope(new PluginSearchScope()); return new PluginSearchQuery(input); } /* * (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ public void selectionChanged(IAction action, ISelection selection) { fSearchString = null; if (selection instanceof IStructuredSelection) { IStructuredSelection sSelection = (IStructuredSelection) selection; if (sSelection.size() == 1) { IFile file = (IFile) sSelection.getFirstElement(); IPluginModelBase model = PluginRegistry.findModel(file.getProject()); if (model != null) fSearchString = model.getPluginBase().getId(); } } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.