1
/*******************************************************************************
2
* Copyright (c) 2005, 2008 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
9
* IBM Corporation - initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.internal.ui.search.actions;
13
import org.eclipse.cdt.core.model.CoreModel;
14
import org.eclipse.cdt.core.model.ICElement;
15
import org.eclipse.cdt.core.model.ICProject;
16
import org.eclipse.cdt.internal.ui.editor.CEditor;
17
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
18
import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery;
19
import org.eclipse.core.resources.IResource;
20
import org.eclipse.jface.viewers.ISelection;
21
import org.eclipse.jface.viewers.IStructuredSelection;
22
import org.eclipse.ui.IWorkbenchSite;
24
public class FindDeclarationsProjectAction extends FindAction {
26
public FindDeclarationsProjectAction(CEditor editor, String label, String tooltip){
29
setToolTipText(tooltip);
32
public FindDeclarationsProjectAction(CEditor editor){
34
CSearchMessages.CSearch_FindDeclarationsProjectAction_label,
35
CSearchMessages.CSearch_FindDeclarationsProjectAction_tooltip);
38
public FindDeclarationsProjectAction(IWorkbenchSite site){
40
CSearchMessages.CSearch_FindDeclarationsProjectAction_label,
41
CSearchMessages.CSearch_FindDeclarationsProjectAction_tooltip);
44
public FindDeclarationsProjectAction(IWorkbenchSite site, String label, String tooltip) {
47
setToolTipText(tooltip);
51
protected ICElement[] getScope() {
52
ICProject project = null;
53
if (fEditor != null) {
54
project = fEditor.getInputCElement().getCProject();
55
} else if (fSite != null){
56
ISelection selection = getSelection();
57
if (selection instanceof IStructuredSelection) {
58
Object element = ((IStructuredSelection)selection).getFirstElement();
59
if (element instanceof IResource)
60
project = CoreModel.getDefault().create(((IResource)element).getProject());
61
else if (element instanceof ICElement)
62
project = ((ICElement)element).getCProject();
66
return project != null ? new ICElement[] { project } : null;
70
protected String getScopeDescription() {
71
return CSearchMessages.ProjectScope;
75
protected int getLimitTo() {
76
return PDOMSearchQuery.FIND_DECLARATIONS_DEFINITIONS;